diff --git a/indexer/abci_test.go b/indexer/abci_test.go index b4982bd..2dab573 100644 --- a/indexer/abci_test.go +++ b/indexer/abci_test.go @@ -5,7 +5,6 @@ import ( "math/big" "sync" "testing" - "time" "github.com/stretchr/testify/require" @@ -68,9 +67,6 @@ func Test_ListenFinalizeBlock_Subscribe(t *testing.T) { indexer := app.EVMIndexer() defer app.Close() - // wait indexer to be ready - time.Sleep(3 * time.Second) - blockChan, logsChan, pendChan := indexer.Subscribe() defer close(blockChan) defer close(logsChan) @@ -86,11 +82,18 @@ func Test_ListenFinalizeBlock_Subscribe(t *testing.T) { for { select { case block := <-blockChan: + if block == nil || block.Number.Int64() < reqHeight { + continue + } + require.NotNil(t, block) require.Equal(t, reqHeight, block.Number.Int64()) wg.Done() case logs := <-logsChan: require.NotNil(t, logs) + if logs[0].BlockNumber < uint64(reqHeight) { + continue + } for _, log := range logs { require.Equal(t, evmTxHash, log.TxHash) diff --git a/jsonrpc/namespaces/eth/filters/api_test.go b/jsonrpc/namespaces/eth/filters/api_test.go index be3412a..2121038 100644 --- a/jsonrpc/namespaces/eth/filters/api_test.go +++ b/jsonrpc/namespaces/eth/filters/api_test.go @@ -128,6 +128,9 @@ func Test_NewPendingTransactionFilter_FullTx(t *testing.T) { rpcTx2, err := backend.GetTransactionByHash(txHash2) require.NoError(t, err) + // wait txs to be indexed + time.Sleep(1 * time.Second) + // there should be 2 changes changes, err := input.filterAPI.GetFilterChanges(filterID) require.NoError(t, err) @@ -207,6 +210,9 @@ func Test_NewPendingTransactionFilter(t *testing.T) { _, finalizeRes = tests.ExecuteTxs(t, app, tx2) tests.CheckTxResult(t, finalizeRes.TxResults[0], true) + // wait txs to be indexed + time.Sleep(1 * time.Second) + // there should be 2 changes changes, err := input.filterAPI.GetFilterChanges(filterID) require.NoError(t, err)