@@ -236,3 +236,70 @@ func TestRetryDeployWithGasBoostSkipsZkSync(t *testing.T) {
236236func ptrUint64 (v uint64 ) * uint64 {
237237 return & v
238238}
239+
240+ func TestRetryWriteWithGasBoostRetriesOnGasError (t * testing.T ) {
241+ t .Parallel ()
242+
243+ failures := 2
244+ var gasLimits []uint64
245+ op := operations .NewOperation (
246+ "write-gas-boost-retry" ,
247+ semver .MustParse ("1.0.0" ),
248+ "test" ,
249+ func (_ operations.Bundle , _ evm.Chain , input FunctionInput [struct {}]) (struct {}, error ) {
250+ gasLimits = append (gasLimits , input .GasLimit )
251+ if failures > 0 {
252+ failures --
253+ return struct {}{}, errors .New ("out of gas: gas required exceeds allowance" )
254+ }
255+
256+ return struct {}{}, nil
257+ },
258+ )
259+
260+ cfg := & GasBoostConfig {
261+ InitialGasLimit : 1_000_000 ,
262+ GasLimitIncrement : ptrUint64 (100_000 ),
263+ }
264+ bundle := optest .NewBundle (t )
265+ _ , err := operations .ExecuteOperation (
266+ bundle ,
267+ op ,
268+ evm.Chain {Selector : 1 },
269+ FunctionInput [struct {}]{},
270+ RetryWriteWithGasBoost [struct {}](cfg ),
271+ )
272+ require .NoError (t , err )
273+ require .Equal (t , []uint64 {0 , 1_000_000 , 1_100_000 }, gasLimits )
274+ }
275+
276+ func TestRetryWriteWithGasBoostNilConfigEnablesRetry (t * testing.T ) {
277+ t .Parallel ()
278+
279+ attempts := 0
280+ op := operations .NewOperation (
281+ "write-retry-nil-config" ,
282+ semver .MustParse ("1.0.0" ),
283+ "test" ,
284+ func (_ operations.Bundle , _ evm.Chain , _ FunctionInput [struct {}]) (struct {}, error ) {
285+ attempts ++
286+ if attempts < 2 {
287+ return struct {}{}, errors .New ("transient failure" )
288+ }
289+
290+ return struct {}{}, nil
291+ },
292+ )
293+
294+ bundle := optest .NewBundle (t )
295+ _ , err := operations .ExecuteOperation (
296+ bundle ,
297+ op ,
298+ evm.Chain {Selector : 1 },
299+ FunctionInput [struct {}]{},
300+ RetryWriteWithGasBoost [struct {}](nil ),
301+ )
302+ require .NoError (t , err )
303+ require .Equal (t , 2 , attempts )
304+ }
305+
0 commit comments