integration tests connectivity target

This commit is contained in:
pragmaxim
2026-01-22 11:10:30 +01:00
parent a2274c9bbf
commit 3d25282996
3 changed files with 31 additions and 0 deletions

View File

@@ -26,6 +26,9 @@ test: .bin-image
test-integration: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) $(BB_RPC_ENV) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-integration ARGS="$(ARGS)"
test-connectivity: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) $(BB_RPC_ENV) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-connectivity ARGS="$(ARGS)"
test-all: .bin-image
docker run -t --rm -e PACKAGER=$(PACKAGER) $(BB_RPC_ENV) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)"

View File

@@ -29,6 +29,9 @@ test: prepare-sources
test-integration: prepare-sources
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` $(ARGS)
test-connectivity: prepare-sources
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/connectivity' $(ARGS)
test-all: prepare-sources
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` $(ARGS)

View File

@@ -7,6 +7,7 @@ distinguish which tests should be executed.
There are several ways to run tests:
* `make test` run unit tests only (note that `make deb*` and `make all*` commands always run also *test* target)
* `make test-connectivity` run connectivity checks only
* `make test-integration` run integration tests only
* `make test-all` run all tests above
@@ -39,6 +40,8 @@ are able to run. That is done in test definition file *blockbook/tests/tests.jso
test implementations call each level as separate subtest. Go's *test* command allows filter tests to run by `-run` flag.
It perfectly fits with layered test definitions. For example, you can:
* run connectivity tests for all coins `make test-connectivity`
* run connectivity tests for a single coin `make test-connectivity ARGS="-run=TestIntegration/bitcoin=main/connectivity"`
* run tests for single coin `make test-integration ARGS="-run=TestIntegration/bitcoin/"`
* run single test suite `make test-integration ARGS="-run=TestIntegration//sync/"`
* run single test `make test-integration ARGS="-run=TestIntegration//sync/HandleFork"`
@@ -58,6 +61,28 @@ URLs that link to *localhost*. If you need run tests against remote servers, the
* SSH tunneling `ssh -nNT -L 8030:localhost:8030 remote-server`
* HTTP proxy
### Connectivity integration tests
Connectivity tests are lightweight checks that verify back-end availability before running heavier RPC or sync suites.
They are configured per coin in *blockbook/tests/tests.json* using the `connectivity` list:
* `["http"]` verify HTTP RPC connectivity
* `["http", "ws"]` verify HTTP RPC plus WebSocket subscription connectivity
Example:
```
"bitcoin": {
"connectivity": ["http"]
},
"ethereum": {
"connectivity": ["http", "ws"]
}
```
HTTP connectivity for UTXO chains calls `getblockchaininfo`. For EVM chains it calls `web3_clientVersion`. WebSocket
connectivity validates `web3_clientVersion` and opens a `newHeads` subscription.
### Synchronization integration tests
Synchronization is crucial part of Blockbook and these tests test whether it is doing well. They sync few blocks from