Skip to content

Commit

Permalink
fix tess
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Dec 3, 2024
1 parent a8f5230 commit 8898144
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
5 changes: 1 addition & 4 deletions indexer/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ func Test_ListenFinalizeBlock_Subscribe(t *testing.T) {
indexer := app.EVMIndexer()
defer app.Close()

blockChan, logsChan, pendChan := indexer.Subscribe()
defer close(blockChan)
defer close(logsChan)
defer close(pendChan)
blockChan, logsChan, _ := indexer.Subscribe()

tx, evmTxHash := tests.GenerateCreateERC20Tx(t, app, privKeys[0])

Expand Down
1 change: 1 addition & 0 deletions indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ type blockEvents struct {
// blockEventsEmitter emits block events to subscribers.
func (e *EVMIndexerImpl) blockEventsEmitter(blockEvents *blockEvents, done chan struct{}) {
defer close(done)

if blockEvents == nil {
return
}
Expand Down
21 changes: 18 additions & 3 deletions indexer/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import (
"context"
"sync"
"testing"
"time"

"github.com/initia-labs/minievm/tests"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/types/mempool"

coretypes "github.com/ethereum/go-ethereum/core/types"
)

func Test_Mempool_Subscribe(t *testing.T) {
Expand All @@ -17,9 +21,7 @@ func Test_Mempool_Subscribe(t *testing.T) {
defer app.Close()

blockChan, logsChan, pendChan := indexer.Subscribe()
defer close(blockChan)
defer close(logsChan)
defer close(pendChan)
go consumeBlockLogsChan(blockChan, logsChan, 5)

tx, evmTxHash := tests.GenerateCreateERC20Tx(t, app, privKeys[0])

Expand Down Expand Up @@ -52,3 +54,16 @@ func Test_Mempool_Subscribe(t *testing.T) {
wg.Wait()
done()
}

func consumeBlockLogsChan(blockCh <-chan *coretypes.Header, logChan <-chan []*coretypes.Log, duration int) {
timer := time.NewTimer(time.Second * time.Duration(duration))

for {
select {
case <-blockCh:
case <-logChan:
case <-timer.C:
return
}
}
}

0 comments on commit 8898144

Please sign in to comment.