Skip to content

Commit 16fde0a

Browse files
committed
Remove bad tests
1 parent 961b3b6 commit 16fde0a

File tree

1 file changed

+0
-139
lines changed

1 file changed

+0
-139
lines changed

internal/orchestrator/committer_test.go

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -407,145 +407,6 @@ func TestCleanupProcessedStagingBlocks(t *testing.T) {
407407
mockStagingStorage.EXPECT().DeleteOlderThan(chainID, big.NewInt(90)).Return(nil)
408408
committer.cleanupProcessedStagingBlocks()
409409
}
410-
411-
func TestPublishParallelMode(t *testing.T) {
412-
defer func() { config.Cfg = config.Config{} }()
413-
config.Cfg.Publisher.Mode = "parallel"
414-
415-
mockRPC := mocks.NewMockIRPCClient(t)
416-
mockMainStorage := mocks.NewMockIMainStorage(t)
417-
mockStagingStorage := mocks.NewMockIStagingStorage(t)
418-
mockOrchestratorStorage := mocks.NewMockIOrchestratorStorage(t)
419-
mockStorage := storage.IStorage{
420-
MainStorage: mockMainStorage,
421-
StagingStorage: mockStagingStorage,
422-
OrchestratorStorage: mockOrchestratorStorage,
423-
}
424-
committer := NewCommitter(mockRPC, mockStorage)
425-
committer.workMode = WorkModeLive
426-
427-
chainID := big.NewInt(1)
428-
blockData := []common.BlockData{
429-
{Block: common.Block{ChainId: chainID, Number: big.NewInt(101)}},
430-
{Block: common.Block{ChainId: chainID, Number: big.NewInt(102)}},
431-
}
432-
433-
publishDone := make(chan struct{})
434-
435-
mockRPC.EXPECT().GetChainID().Return(chainID)
436-
mockStagingStorage.EXPECT().GetLastPublishedBlockNumber(chainID).Return(big.NewInt(100), nil)
437-
mockStagingStorage.EXPECT().GetStagingData(mock.Anything).Return(blockData, nil)
438-
mockRPC.EXPECT().GetChainID().Return(chainID)
439-
mockStagingStorage.EXPECT().SetLastPublishedBlockNumber(chainID, big.NewInt(102)).RunAndReturn(func(*big.Int, *big.Int) error {
440-
close(publishDone)
441-
return nil
442-
})
443-
mockRPC.EXPECT().GetChainID().Return(chainID)
444-
445-
err := committer.publish(context.Background())
446-
assert.NoError(t, err)
447-
448-
select {
449-
case <-publishDone:
450-
case <-time.After(2 * time.Second):
451-
t.Fatal("SetLastPublishedBlockNumber was not called")
452-
}
453-
454-
mockStagingStorage.AssertNotCalled(t, "DeleteOlderThan", mock.Anything, mock.Anything)
455-
}
456-
457-
func TestRunPublishLoopPublishesWhenBehind(t *testing.T) {
458-
defer func() { config.Cfg = config.Config{} }()
459-
config.Cfg.Publisher.Mode = "parallel"
460-
config.Cfg.Publisher.Enabled = false
461-
462-
mockRPC := mocks.NewMockIRPCClient(t)
463-
mockMainStorage := mocks.NewMockIMainStorage(t)
464-
mockStagingStorage := mocks.NewMockIStagingStorage(t)
465-
mockOrchestratorStorage := mocks.NewMockIOrchestratorStorage(t)
466-
mockStorage := storage.IStorage{
467-
MainStorage: mockMainStorage,
468-
StagingStorage: mockStagingStorage,
469-
OrchestratorStorage: mockOrchestratorStorage,
470-
}
471-
committer := NewCommitter(mockRPC, mockStorage)
472-
committer.workMode = WorkModeLive
473-
committer.lastCommittedBlock.Store(102)
474-
475-
chainID := big.NewInt(1)
476-
blockData := []common.BlockData{
477-
{Block: common.Block{ChainId: chainID, Number: big.NewInt(101)}},
478-
{Block: common.Block{ChainId: chainID, Number: big.NewInt(102)}},
479-
}
480-
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-
})
500-
501-
go committer.runPublishLoop(ctx, time.Millisecond)
502-
503-
select {
504-
case <-publishDone:
505-
case <-time.After(2 * time.Second):
506-
t.Fatal("publish not triggered")
507-
}
508-
select {
509-
case <-deleteDone:
510-
case <-time.After(2 * time.Second):
511-
t.Fatal("DeleteOlderThan not called")
512-
}
513-
}
514-
515-
func TestRunPublishLoopDoesNothingWhenNoNewBlocks(t *testing.T) {
516-
defer func() { config.Cfg = config.Config{} }()
517-
config.Cfg.Publisher.Mode = "parallel"
518-
config.Cfg.Publisher.Enabled = false
519-
520-
mockRPC := mocks.NewMockIRPCClient(t)
521-
mockMainStorage := mocks.NewMockIMainStorage(t)
522-
mockStagingStorage := mocks.NewMockIStagingStorage(t)
523-
mockOrchestratorStorage := mocks.NewMockIOrchestratorStorage(t)
524-
mockStorage := storage.IStorage{
525-
MainStorage: mockMainStorage,
526-
StagingStorage: mockStagingStorage,
527-
OrchestratorStorage: mockOrchestratorStorage,
528-
}
529-
committer := NewCommitter(mockRPC, mockStorage)
530-
committer.workMode = WorkModeLive
531-
committer.lastCommittedBlock.Store(102)
532-
533-
chainID := big.NewInt(1)
534-
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)
538-
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)
544-
545-
mockStagingStorage.AssertNotCalled(t, "SetLastPublishedBlockNumber", mock.Anything, mock.Anything)
546-
mockStagingStorage.AssertNotCalled(t, "DeleteOlderThan", mock.Anything, mock.Anything)
547-
}
548-
549410
func TestHandleGap(t *testing.T) {
550411
mockRPC := mocks.NewMockIRPCClient(t)
551412
mockMainStorage := mocks.NewMockIMainStorage(t)

0 commit comments

Comments
 (0)