Skip to content

Commit 560cc03

Browse files
committed
add gas handling to tests for batch
1 parent d75805d commit 560cc03

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

block/submitter_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,24 @@ func TestSubmitBatchToDA_Failure(t *testing.T) {
6767
for _, tc := range testCases {
6868
t.Run(tc.name, func(t *testing.T) {
6969
// Reset mock expectations for each error scenario
70+
var gasPriceHistory []float64
7071
da.ExpectedCalls = nil
7172
da.On("GasMultiplier", mock.Anything).Return(2.0, nil)
7273
da.On("SubmitWithOptions", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
74+
Run(func(args mock.Arguments) { gasPriceHistory = append(gasPriceHistory, args.Get(2).(float64)) }). //save the gas price to verify it later
7375
Return(nil, tc.daError)
7476

7577
// Expect an error from submitBatchToDA
7678
err := m.submitBatchToDA(context.Background(), batch)
7779
assert.Error(t, err, "expected error")
80+
81+
// Validate that gas price increased according to gas multiplier
82+
previousGasPrice := m.gasPrice
83+
assert.Equal(t, gasPriceHistory[0], m.gasPrice) // verify that the first call is done with the right price
84+
for _, gasPrice := range gasPriceHistory[1:] {
85+
assert.Equal(t, gasPrice, previousGasPrice*m.gasMultiplier)
86+
previousGasPrice = gasPrice
87+
}
7888
})
7989
}
8090
}

0 commit comments

Comments
 (0)