mirror of
https://github.com/trezor/blockbook.git
synced 2026-03-23 07:57:18 +01:00
ci: safety net timeout
This commit is contained in:
@@ -27,18 +27,18 @@ test: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest' `go list ./... | grep -vP '^github.com/trezor/blockbook/(contrib|tests)'` $(ARGS)
|
||||
|
||||
test-integration: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/(rpc|sync)' $(ARGS)
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/(rpc|sync)' -timeout 30m $(ARGS)
|
||||
|
||||
test-e2e: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/api' $(ARGS)
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/api' -timeout 30m $(ARGS)
|
||||
|
||||
e2e: test-e2e
|
||||
|
||||
test-connectivity: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/connectivity' $(ARGS)
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'integration' `go list github.com/trezor/blockbook/tests/...` -run 'TestIntegration/.*/connectivity' -timeout 30m $(ARGS)
|
||||
|
||||
test-all: prepare-sources
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` $(ARGS)
|
||||
cd $(BLOCKBOOK_SRC) && go test -tags 'unittest integration' `go list ./... | grep -v '^github.com/trezor/blockbook/contrib'` -timeout 30m $(ARGS)
|
||||
|
||||
prepare-sources:
|
||||
@ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1)
|
||||
|
||||
@@ -51,6 +51,8 @@ It perfectly fits with layered test definitions. For example, you can:
|
||||
* run e2e tests for all coins – `make test-e2e`
|
||||
* run e2e tests for single coin – `make test-e2e ARGS="-run=TestIntegration/bitcoin=main/api"`
|
||||
|
||||
Integration targets run with `go test -timeout 30m` inside Docker tooling.
|
||||
|
||||
Test fixtures are defined in *testdata* directory in package of particular test suite. They are separate JSON files named
|
||||
by coin. File schemes are very similar with verbose results of CLI tools and are described below. Integration tests
|
||||
follow the same concept, use live component or service and verify their results with fixtures.
|
||||
|
||||
@@ -20,6 +20,7 @@ const (
|
||||
txSearchWindow = 12
|
||||
blockPageSize = 1
|
||||
sampleBlockPageSize = 3
|
||||
sampleBlockProbeMax = 3
|
||||
)
|
||||
|
||||
type testCapability uint8
|
||||
|
||||
@@ -71,6 +71,19 @@ func (h *TestHandler) getSampleTxID(t *testing.T) (string, bool) {
|
||||
return h.sampleTxID, h.sampleTxID != ""
|
||||
}
|
||||
|
||||
if h.sampleBlockResolved && h.sampleBlockHash != "" {
|
||||
if blk, ok := h.getBlockByHash(t, h.sampleBlockHash, false); ok {
|
||||
for _, txid := range blk.TxIDs {
|
||||
txid = strings.TrimSpace(txid)
|
||||
if txid != "" {
|
||||
h.sampleTxResolved = true
|
||||
h.sampleTxID = txid
|
||||
return h.sampleTxID, true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status := h.getStatus(t)
|
||||
txid, _, _, found := h.findTransactionNearHeight(t, status.BestHeight, txSearchWindow)
|
||||
h.sampleTxResolved = true
|
||||
@@ -110,19 +123,22 @@ func (h *TestHandler) getSampleIndexedBlock(t *testing.T) (height int, hash stri
|
||||
return h.sampleBlockHeight, h.sampleBlockHash, h.sampleBlockHash != ""
|
||||
}
|
||||
|
||||
status := h.getStatus(t)
|
||||
start := status.BestHeight
|
||||
if start > 2 {
|
||||
start -= 2
|
||||
h.sampleBlockResolved = true
|
||||
startHeight, startHash, ok := h.getSampleIndexedHeight(t)
|
||||
if !ok {
|
||||
return 0, "", false
|
||||
}
|
||||
lower := start - txSearchWindow
|
||||
|
||||
lower := startHeight - sampleBlockProbeMax + 1
|
||||
if lower < 1 {
|
||||
lower = 1
|
||||
}
|
||||
|
||||
h.sampleBlockResolved = true
|
||||
for height = start; height >= lower; height-- {
|
||||
hash, ok := h.getBlockHashForHeight(t, height, false)
|
||||
for height = startHeight; height >= lower; height-- {
|
||||
hash = startHash
|
||||
if height != startHeight {
|
||||
hash, ok = h.getBlockHashForHeight(t, height, false)
|
||||
}
|
||||
if !ok || strings.TrimSpace(hash) == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user