@@ -470,33 +470,33 @@ func TestRunPublishLoopPublishesWhenBehind(t *testing.T) {
470470 }
471471 committer := NewCommitter (mockRPC , mockStorage )
472472 committer .workMode = WorkModeLive
473- committer .setLastCommittedBlock ( big . NewInt (102 ) )
473+ committer .lastCommittedBlock . Store (102 )
474474
475475 chainID := big .NewInt (1 )
476476 blockData := []common.BlockData {
477477 {Block : common.Block {ChainId : chainID , Number : big .NewInt (101 )}},
478478 {Block : common.Block {ChainId : chainID , Number : big .NewInt (102 )}},
479479 }
480480
481- publishDone := make (chan struct {})
482- deleteDone := make (chan struct {})
483-
484- mockRPC .EXPECT ().GetChainID ().Return (chainID )
485- mockStagingStorage .EXPECT ().GetLastPublishedBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
486- mockStagingStorage .EXPECT ().GetStagingData (mock .Anything ).Return (blockData , nil )
487- mockRPC .EXPECT ().GetChainID ().Return (chainID )
488-
489- ctx , cancel := context .WithCancel (context .Background ())
490- mockStagingStorage .EXPECT ().SetLastPublishedBlockNumber (chainID , big .NewInt (102 )).RunAndReturn (func (* big.Int , * big.Int ) error {
491- close (publishDone )
492- cancel ()
493- return nil
494- })
495- mockRPC .EXPECT ().GetChainID ().Return (chainID )
496- mockStagingStorage .EXPECT ().DeleteOlderThan (chainID , big .NewInt (102 )).RunAndReturn (func (* big.Int , * big.Int ) error {
497- close (deleteDone )
498- return nil
499- })
481+ publishDone := make (chan struct {})
482+ deleteDone := make (chan struct {})
483+
484+ mockRPC .EXPECT ().GetChainID ().Return (chainID )
485+ mockStagingStorage .EXPECT ().GetLastPublishedBlockNumber (chainID ).Return (big .NewInt (100 ), nil )
486+ mockStagingStorage .EXPECT ().GetStagingData (mock .Anything ).Return (blockData , nil )
487+ mockRPC .EXPECT ().GetChainID ().Return (chainID )
488+
489+ ctx , cancel := context .WithCancel (context .Background ())
490+ mockStagingStorage .EXPECT ().SetLastPublishedBlockNumber (chainID , big .NewInt (102 )).RunAndReturn (func (* big.Int , * big.Int ) error {
491+ close (publishDone )
492+ cancel ()
493+ return nil
494+ })
495+ mockRPC .EXPECT ().GetChainID ().Return (chainID )
496+ mockStagingStorage .EXPECT ().DeleteOlderThan (chainID , big .NewInt (102 )).RunAndReturn (func (* big.Int , * big.Int ) error {
497+ close (deleteDone )
498+ return nil
499+ })
500500
501501 go committer .runPublishLoop (ctx , time .Millisecond )
502502
@@ -528,22 +528,22 @@ func TestRunPublishLoopDoesNothingWhenNoNewBlocks(t *testing.T) {
528528 }
529529 committer := NewCommitter (mockRPC , mockStorage )
530530 committer .workMode = WorkModeLive
531- committer .setLastCommittedBlock ( big . NewInt (102 ) )
531+ committer .lastCommittedBlock . Store (102 )
532532
533- chainID := big .NewInt (1 )
533+ chainID := big .NewInt (1 )
534534
535- mockRPC .EXPECT ().GetChainID ().Return (chainID )
536- mockStagingStorage .EXPECT ().GetLastPublishedBlockNumber (chainID ).Return (big .NewInt (105 ), nil )
537- mockStagingStorage .EXPECT ().GetStagingData (mock .Anything ).Return ([]common.BlockData {}, nil )
535+ mockRPC .EXPECT ().GetChainID ().Return (chainID )
536+ mockStagingStorage .EXPECT ().GetLastPublishedBlockNumber (chainID ).Return (big .NewInt (105 ), nil )
537+ mockStagingStorage .EXPECT ().GetStagingData (mock .Anything ).Return ([]common.BlockData {}, nil )
538538
539- ctx , cancel := context .WithCancel (context .Background ())
540- go committer .runPublishLoop (ctx , time .Millisecond )
541- time .Sleep (2 * time .Millisecond )
542- cancel ()
543- time .Sleep (10 * time .Millisecond )
539+ ctx , cancel := context .WithCancel (context .Background ())
540+ go committer .runPublishLoop (ctx , time .Millisecond )
541+ time .Sleep (2 * time .Millisecond )
542+ cancel ()
543+ time .Sleep (10 * time .Millisecond )
544544
545- mockStagingStorage .AssertNotCalled (t , "SetLastPublishedBlockNumber" , mock .Anything , mock .Anything )
546- mockStagingStorage .AssertNotCalled (t , "DeleteOlderThan" , mock .Anything , mock .Anything )
545+ mockStagingStorage .AssertNotCalled (t , "SetLastPublishedBlockNumber" , mock .Anything , mock .Anything )
546+ mockStagingStorage .AssertNotCalled (t , "DeleteOlderThan" , mock .Anything , mock .Anything )
547547}
548548
549549func TestHandleGap (t * testing.T ) {
0 commit comments