Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Nov 29, 2024
1 parent f8d78a5 commit 72f3e33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions indexer/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"math/big"
"sync"
"testing"
"time"

"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions jsonrpc/namespaces/eth/filters/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72f3e33

Please sign in to comment.