Skip to content

Commit

Permalink
Add tests for defering checkStartedLocked till block filters are created
Browse files Browse the repository at this point in the history
Signed-off-by: rodion <[email protected]>
  • Loading branch information
rodion-lim-partior committed Sep 3, 2024
1 parent 1031762 commit 6032fd2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/ethereum/blocklistener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,33 @@ func TestBlockListenerReestablishBlockFilterFail(t *testing.T) {

}

func TestBlockListenerWillNotCloseBlockFilterSignalChanMoreThanOnce(t *testing.T) {

_, c, mRPC, done := newTestConnector(t)
bl := c.blockListener
bl.blockPollingInterval = 1 * time.Microsecond

mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_blockNumber").Return(nil).Run(func(args mock.Arguments) {
hbh := args[1].(*ethtypes.HexInteger)
*hbh = *ethtypes.NewHexInteger64(1000)
}).Once()
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_newBlockFilter").Return(nil).Run(func(args mock.Arguments) {
hbh := args[1].(*string)
*hbh = "filter_id1"
})
mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getFilterChanges", mock.Anything).Return(nil).Run(func(args mock.Arguments) {
go done()
})

bl.checkStartedLocked(context.Background()) // start block listener loop
bl.setBlockFilterStatus() // ensure that block filter established signal channel is not closed more than once

c.WaitClosed()

mRPC.AssertExpectations(t)

}

func TestBlockListenerDispatchStopped(t *testing.T) {
_, c, _, done := newTestConnector(t)
done()
Expand Down

0 comments on commit 6032fd2

Please sign in to comment.