Commit dbbfe55b authored by Adrian Sutton's avatar Adrian Sutton

op-e2e: Use helper to send deposit tx in TestMixedDepositValidity

Helper avoid flakiness by padding the gas limit for the L1 tx.
parent 62245a02
...@@ -13,7 +13,6 @@ import ( ...@@ -13,7 +13,6 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys" "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils" "github.com/ethereum-optimism/optimism/op-node/testutils/fuzzerutils"
"github.com/ethereum-optimism/optimism/op-node/withdrawals" "github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
...@@ -246,10 +245,6 @@ func TestMixedDepositValidity(t *testing.T) { ...@@ -246,10 +245,6 @@ func TestMixedDepositValidity(t *testing.T) {
// Define our L1 transaction timeout duration. // Define our L1 transaction timeout duration.
txTimeoutDuration := 10 * time.Duration(cfg.DeployConfig.L1BlockTime) * time.Second txTimeoutDuration := 10 * time.Duration(cfg.DeployConfig.L1BlockTime) * time.Second
// Bind to the deposit contract
depositContract, err := bindings.NewOptimismPortal(cfg.L1Deployments.OptimismPortalProxy, l1Client)
require.NoError(t, err)
// Create a struct used to track our transactors and their transactions sent. // Create a struct used to track our transactors and their transactions sent.
type TestAccountState struct { type TestAccountState struct {
Account *TestAccount Account *TestAccount
...@@ -320,27 +315,18 @@ func TestMixedDepositValidity(t *testing.T) { ...@@ -320,27 +315,18 @@ func TestMixedDepositValidity(t *testing.T) {
} else { } else {
transferValue = new(big.Int).Mul(common.Big2, transactor.ExpectedL2Balance) // trigger a revert by trying to transfer our current balance * 2 transferValue = new(big.Int).Mul(common.Big2, transactor.ExpectedL2Balance) // trigger a revert by trying to transfer our current balance * 2
} }
tx, err := depositContract.DepositTransaction(transactor.Account.L1Opts, toAddr, transferValue, 100_000, false, nil) SendDepositTx(t, cfg, l1Client, l2Verif, transactor.Account.L1Opts, func(l2Opts *DepositTxOpts) {
require.Nil(t, err, "with deposit tx") l2Opts.GasLimit = 100_000
l2Opts.IsCreation = false
// Wait for the deposit tx to appear in L1. l2Opts.Data = nil
receipt, err := waitForTransaction(tx.Hash(), l1Client, txTimeoutDuration) l2Opts.ToAddr = toAddr
require.Nil(t, err, "Waiting for deposit tx on L1") l2Opts.Value = transferValue
require.Equal(t, receipt.Status, types.ReceiptStatusSuccessful) if validTransfer {
l2Opts.ExpectedStatus = types.ReceiptStatusSuccessful
// Reconstruct the L2 tx hash to wait for the deposit in L2. } else {
reconstructedDep, err := derive.UnmarshalDepositLogEvent(receipt.Logs[0]) l2Opts.ExpectedStatus = types.ReceiptStatusFailed
require.NoError(t, err, "Could not reconstruct L2 Deposit") }
tx = types.NewTx(reconstructedDep) })
receipt, err = waitForTransaction(tx.Hash(), l2Verif, txTimeoutDuration)
require.NoError(t, err)
// Verify the result of the L2 tx receipt. Based on how much we transferred it should be successful/failed.
if validTransfer {
require.Equal(t, types.ReceiptStatusSuccessful, receipt.Status, "Transaction should have succeeded")
} else {
require.Equal(t, types.ReceiptStatusFailed, receipt.Status, "Transaction should have failed")
}
// Update our expected balances. // Update our expected balances.
if validTransfer && transactor != receiver { if validTransfer && transactor != receiver {
......
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
"time" "time"
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -26,7 +25,7 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l ...@@ -26,7 +25,7 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l
applyL2Opts(l2Opts) applyL2Opts(l2Opts)
// Find deposit contract // Find deposit contract
depositContract, err := bindings.NewOptimismPortal(config.L1Deployments.OptimismPortalProxy, l1Client) depositContract, err := bindings.NewOptimismPortal(cfg.L1Deployments.OptimismPortalProxy, l1Client)
require.Nil(t, err) require.Nil(t, err)
// Finally send TX // Finally send TX
...@@ -54,7 +53,7 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l ...@@ -54,7 +53,7 @@ func SendDepositTx(t *testing.T, cfg SystemConfig, l1Client *ethclient.Client, l
tx = types.NewTx(reconstructedDep) tx = types.NewTx(reconstructedDep)
receipt, err = waitForTransaction(tx.Hash(), l2Client, 10*time.Duration(cfg.DeployConfig.L2BlockTime)*time.Second) receipt, err = waitForTransaction(tx.Hash(), l2Client, 10*time.Duration(cfg.DeployConfig.L2BlockTime)*time.Second)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, l2Opts.ExpectedStatus, receipt.Status) require.Equal(t, l2Opts.ExpectedStatus, receipt.Status, "l2 transaction status")
} }
type DepositTxOptsFn func(l2Opts *DepositTxOpts) type DepositTxOptsFn func(l2Opts *DepositTxOpts)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment