Skip to content

Commit

Permalink
fix: ut fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jul 24, 2024
1 parent cebfd04 commit b8e0804
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions reorgdetector/reorgdetector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,29 +314,6 @@ func TestReorgDetector_AddBlockToTrack(t *testing.T) {
require.ErrorIs(t, err, ErrNotSubscribed)
})

t.Run("no unfinalised blocks - block already finalised", func(t *testing.T) {
t.Parallel()

client := NewEthClientMock(t)
db := newTestDB(t)

client.On("HeaderByNumber", ctx, big.NewInt(int64(rpc.FinalizedBlockNumber))).Return(
&types.Header{Number: big.NewInt(10)}, nil,
).Twice()

rd, err := newReorgDetector(ctx, client, db)
require.NoError(t, err)

_, err = rd.Subscribe(testSubscriber)
require.NoError(t, err)

err = rd.AddBlockToTrack(ctx, testSubscriber, 9, common.HexToHash("0x123")) // block already finalized
require.NoError(t, err)

subBlocks := rd.trackedBlocks[testSubscriber]
require.Len(t, subBlocks, 0) // since block to track is already finalized no need to track it
})

t.Run("no unfinalised blocks - block not finalised", func(t *testing.T) {
t.Parallel()

Expand All @@ -345,7 +322,7 @@ func TestReorgDetector_AddBlockToTrack(t *testing.T) {

client.On("HeaderByNumber", ctx, big.NewInt(int64(rpc.FinalizedBlockNumber))).Return(
&types.Header{Number: big.NewInt(10)}, nil,
).Twice()
).Once()

rd, err := newReorgDetector(ctx, client, db)
require.NoError(t, err)
Expand Down

0 comments on commit b8e0804

Please sign in to comment.