@@ -46,6 +46,7 @@ func TestGetBlockNumbersToCommit(t *testing.T) {
4646
4747 mockRPC .EXPECT ().GetChainID ().Return (chainID )
4848 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
49+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (100 )).Return ([]* big.Int {}, nil )
4950
5051 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
5152
@@ -70,6 +71,7 @@ func TestGetBlockNumbersToCommitWithoutConfiguredAndNotStored(t *testing.T) {
7071
7172 mockRPC .EXPECT ().GetChainID ().Return (chainID )
7273 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (0 ), nil )
74+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (- 1 )).Return ([]* big.Int {}, nil )
7375
7476 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
7577
@@ -97,6 +99,7 @@ func TestGetBlockNumbersToCommitWithConfiguredAndNotStored(t *testing.T) {
9799
98100 mockRPC .EXPECT ().GetChainID ().Return (chainID )
99101 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (0 ), nil )
102+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (49 )).Return ([]* big.Int {}, nil )
100103
101104 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
102105
@@ -124,6 +127,7 @@ func TestGetBlockNumbersToCommitWithConfiguredAndStored(t *testing.T) {
124127
125128 mockRPC .EXPECT ().GetChainID ().Return (chainID )
126129 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (2000 ), nil )
130+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (2000 )).Return ([]* big.Int {}, nil )
127131
128132 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
129133
@@ -148,6 +152,7 @@ func TestGetBlockNumbersToCommitWithoutConfiguredAndStored(t *testing.T) {
148152
149153 mockRPC .EXPECT ().GetChainID ().Return (chainID )
150154 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (2000 ), nil )
155+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (2000 )).Return ([]* big.Int {}, nil )
151156
152157 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
153158
@@ -175,6 +180,7 @@ func TestGetBlockNumbersToCommitWithStoredHigherThanInMemory(t *testing.T) {
175180
176181 mockRPC .EXPECT ().GetChainID ().Return (chainID )
177182 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (2000 ), nil )
183+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (2000 )).Return ([]* big.Int {}, nil )
178184
179185 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
180186
@@ -227,6 +233,7 @@ func TestGetBlockNumbersToCommitWithStoredEqualThanInMemory(t *testing.T) {
227233
228234 mockRPC .EXPECT ().GetChainID ().Return (chainID )
229235 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (2000 ), nil )
236+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (2000 )).Return ([]* big.Int {}, nil )
230237
231238 blockNumbers , err := committer .getBlockNumbersToCommit (context .Background ())
232239
@@ -253,6 +260,7 @@ func TestGetSequentialBlockDataToCommit(t *testing.T) {
253260
254261 mockRPC .EXPECT ().GetChainID ().Return (chainID )
255262 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
263+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (100 )).Return ([]* big.Int {}, nil )
256264
257265 blockData := []common.BlockData {
258266 {Block : common.Block {Number : big .NewInt (101 )}},
@@ -288,6 +296,7 @@ func TestGetSequentialBlockDataToCommitWithDuplicateBlocks(t *testing.T) {
288296
289297 mockRPC .EXPECT ().GetChainID ().Return (chainID )
290298 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
299+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (100 )).Return ([]* big.Int {}, nil )
291300
292301 blockData := []common.BlockData {
293302 {Block : common.Block {Number : big .NewInt (101 )}},
@@ -403,6 +412,7 @@ func TestStartCommitter(t *testing.T) {
403412 chainID := big .NewInt (1 )
404413 mockRPC .EXPECT ().GetChainID ().Return (chainID )
405414 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
415+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (100 )).Return ([]* big.Int {}, nil )
406416
407417 blockData := []common.BlockData {
408418 {Block : common.Block {Number : big .NewInt (101 )}},
@@ -437,6 +447,7 @@ func TestCommitterRespectsSIGTERM(t *testing.T) {
437447 chainID := big .NewInt (1 )
438448 mockRPC .EXPECT ().GetChainID ().Return (chainID )
439449 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
450+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (100 )).Return ([]* big.Int {}, nil )
440451
441452 blockData := []common.BlockData {
442453 {Block : common.Block {Number : big .NewInt (101 )}},
@@ -502,6 +513,7 @@ func TestHandleMissingStagingData(t *testing.T) {
502513 mockStagingStorage .EXPECT ().InsertStagingData (mock .Anything ).Return (nil )
503514
504515 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (0 ), nil )
516+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (- 1 )).Return ([]* big.Int {}, nil )
505517 expectedEndBlock := big .NewInt (4 )
506518 mockStagingStorage .EXPECT ().GetLastStagedBlockNumber (chainID , expectedEndBlock , big .NewInt (0 )).Return (big .NewInt (20 ), nil )
507519
@@ -547,6 +559,7 @@ func TestHandleMissingStagingDataIsPolledWithCorrectBatchSize(t *testing.T) {
547559 mockStagingStorage .EXPECT ().InsertStagingData (mock .Anything ).Return (nil )
548560
549561 mockMainStorage .EXPECT ().GetMaxBlockNumber (chainID ).Return (big .NewInt (0 ), nil )
562+ mockStagingStorage .EXPECT ().GetBlockNumbersLessThan (chainID , big .NewInt (- 1 )).Return ([]* big.Int {}, nil )
550563 expectedEndBlock := big .NewInt (4 )
551564 mockStagingStorage .EXPECT ().GetLastStagedBlockNumber (chainID , expectedEndBlock , big .NewInt (0 )).Return (big .NewInt (20 ), nil )
552565
0 commit comments