Skip to content

Commit

Permalink
Fix: retry approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasse committed Nov 26, 2024
1 parent 8e2a161 commit 39cd060
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions services/rfq/e2e/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,15 @@ func (i *IntegrationSuite) Approve(backend backends.SimulatedTestBackend, token

if allowance.Cmp(big.NewInt(0)) == 0 {
txOpts := backend.GetTxContext(i.GetTestContext(), user.AddressPtr())
tx, err := erc20.Approve(txOpts.TransactOpts, fastBridgeV1.Address(), core.CopyBigInt(abi.MaxUint256))
err := retry.WithBackoff(i.GetTestContext(), func(_ context.Context) error {
tx, err := erc20.Approve(txOpts.TransactOpts, fastBridgeV1.Address(), core.CopyBigInt(abi.MaxUint256))
if err != nil {
return fmt.Errorf("failed to approve: %w", err)
}
backend.WaitForConfirmation(i.GetTestContext(), tx)
return nil
}, retry.WithMaxTotalTime(30*time.Second))
i.Require().NoError(err, "Failed to approve")
backend.WaitForConfirmation(i.GetTestContext(), tx)
}

// approve fastbridgev2
Expand All @@ -287,9 +293,15 @@ func (i *IntegrationSuite) Approve(backend backends.SimulatedTestBackend, token

if allowance.Cmp(big.NewInt(0)) == 0 {
txOpts := backend.GetTxContext(i.GetTestContext(), user.AddressPtr())
tx, err := erc20.Approve(txOpts.TransactOpts, fastBridgeV2.Address(), core.CopyBigInt(abi.MaxUint256))
err := retry.WithBackoff(i.GetTestContext(), func(_ context.Context) error {
tx, err := erc20.Approve(txOpts.TransactOpts, fastBridgeV2.Address(), core.CopyBigInt(abi.MaxUint256))
if err != nil {
return fmt.Errorf("failed to approve: %w", err)
}
backend.WaitForConfirmation(i.GetTestContext(), tx)
return nil
}, retry.WithMaxTotalTime(30*time.Second))
i.Require().NoError(err, "Failed to approve")
backend.WaitForConfirmation(i.GetTestContext(), tx)
}
}

Expand Down

0 comments on commit 39cd060

Please sign in to comment.