Skip to content

Commit

Permalink
fix UT
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin committed May 8, 2024
1 parent 0ac33dc commit 48bda66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions block/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func TestCreateEmptyBlocksEnableDisable(t *testing.T) {
go manager.ProduceBlockLoop(mCtx)
go managerWithEmptyBlocks.ProduceBlockLoop(mCtx)

buf1 := make(chan bool, 100) //dummy to avoid unhealthy event
buf2 := make(chan bool, 100) //dummy to avoid unhealthy event
buf1 := make(chan struct{}, 100) //dummy to avoid unhealthy event
buf2 := make(chan struct{}, 100) //dummy to avoid unhealthy event
go manager.AccumulatedDataLoop(mCtx, buf1)
go managerWithEmptyBlocks.AccumulatedDataLoop(mCtx, buf2)
<-mCtx.Done()
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestStopBlockProduction(t *testing.T) {
wg.Done() // Decrease counter when this goroutine finishes
}()

toSubmit := make(chan bool)
toSubmit := make(chan struct{})
go func() {
manager.AccumulatedDataLoop(ctx, toSubmit)
wg.Done() // Decrease counter when this goroutine finishes
Expand Down
2 changes: 1 addition & 1 deletion block/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (m *Manager) SubmitLoop(ctx context.Context) {
}

// AccumulatedDataLoop is the main loop for accumulating the produced data size.
// It is triggered by the ProducedSizeCh channel, which is triggered by the block production loop when a new block is produced.
// It is triggered by the ProducedSizeCh channel, which is populated by the block production loop when a new block is produced.
// It accumulates the size of the produced data and triggers the submission of the batch when the accumulated size is greater than the max size.
// It also emits a health status event when the submission channel is full.
func (m *Manager) AccumulatedDataLoop(ctx context.Context, toSubmit chan struct{}) {
Expand Down
6 changes: 3 additions & 3 deletions block/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestBatchSubmissionHappyFlow(t *testing.T) {
assert.Zero(t, manager.SyncTarget.Load())

// submit and validate sync target
manager.HandleSubmissionTrigger(ctx)
manager.HandleSubmissionTrigger()
assert.EqualValues(t, manager.Store.Height(), manager.SyncTarget.Load())
}

Expand Down Expand Up @@ -96,11 +96,11 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) {

// try to submit, we expect failure
mockLayerI.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("Failed to submit batch")).Once()
assert.Error(t, manager.HandleSubmissionTrigger(ctx))
assert.Error(t, manager.HandleSubmissionTrigger())

// try to submit again, we expect success
mockLayerI.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
manager.HandleSubmissionTrigger(ctx)
manager.HandleSubmissionTrigger()
assert.EqualValues(t, manager.Store.Height(), manager.SyncTarget.Load())
}

Expand Down

0 comments on commit 48bda66

Please sign in to comment.