11package orchestrator
22
33import (
4+ "context"
45 "math/big"
56 "testing"
67
78 "github.com/stretchr/testify/assert"
89 "github.com/stretchr/testify/mock"
10+ "github.com/thirdweb-dev/indexer/internal/rpc"
911 "github.com/thirdweb-dev/indexer/internal/storage"
1012 mocks "github.com/thirdweb-dev/indexer/test/mocks"
1113)
@@ -19,6 +21,10 @@ func TestNewCommitter(t *testing.T) {
1921 MainStorage : mockMainStorage ,
2022 StagingStorage : mockStagingStorage ,
2123 }
24+
25+ // Mock the GetBlocksPerRequest call that happens in NewWorker
26+ mockRPC .EXPECT ().GetBlocksPerRequest ().Return (rpc.BlocksPerRequestConfig {Blocks : 100 })
27+
2228 poller := & Poller {}
2329 committer := NewCommitter (mockRPC , mockStorage , poller )
2430
@@ -61,20 +67,25 @@ func TestCleanupProcessedStagingBlocks(t *testing.T) {
6167 StagingStorage : mockStagingStorage ,
6268 OrchestratorStorage : mockOrchestratorStorage ,
6369 }
70+
71+ // Mock the GetBlocksPerRequest call that happens in NewWorker
72+ mockRPC .EXPECT ().GetBlocksPerRequest ().Return (rpc.BlocksPerRequestConfig {Blocks : 100 })
73+
6474 poller := & Poller {}
6575 committer := NewCommitter (mockRPC , mockStorage , poller )
6676
6777 chainID := big .NewInt (1 )
6878 committer .lastCommittedBlock .Store (100 )
6979 committer .lastPublishedBlock .Store (0 )
7080
71- committer .cleanupProcessedStagingBlocks ()
81+ ctx := context .Background ()
82+ committer .cleanupProcessedStagingBlocks (ctx )
7283 mockStagingStorage .AssertNotCalled (t , "DeleteStagingDataOlderThan" , mock .Anything , mock .Anything )
7384
7485 committer .lastPublishedBlock .Store (90 )
7586 mockRPC .EXPECT ().GetChainID ().Return (chainID )
7687 mockStagingStorage .EXPECT ().DeleteStagingDataOlderThan (chainID , big .NewInt (90 )).Return (nil )
77- committer .cleanupProcessedStagingBlocks ()
88+ committer .cleanupProcessedStagingBlocks (ctx )
7889}
7990
8091func TestStartCommitter (t * testing.T ) {
0 commit comments