From aee40a81fceeb937725db0bcc2a4c7963d0681dd Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:23:14 +0000 Subject: [PATCH] Network tests: fix local run gas error (#1789) --- .../networktest/actions/native_fund_actions.go | 6 +----- integration/networktest/env/testnet.go | 2 +- integration/networktest/userwallet/userwallet.go | 15 +++++++-------- integration/simulation/devnetwork/dev_network.go | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/integration/networktest/actions/native_fund_actions.go b/integration/networktest/actions/native_fund_actions.go index 2f27dc42cd..d356867cac 100644 --- a/integration/networktest/actions/native_fund_actions.go +++ b/integration/networktest/actions/native_fund_actions.go @@ -35,11 +35,7 @@ func (s *SendNativeFunds) Run(ctx context.Context, _ networktest.NetworkConnecto if err != nil { return ctx, err } - gas := uint64(1_000_000) - if s.GasLimit != nil { - gas = s.GasLimit.Uint64() - } - txHash, err := user.SendFunds(ctx, target.Address(), s.Amount, gas) + txHash, err := user.SendFunds(ctx, target.Address(), s.Amount) if err != nil { return nil, err } diff --git a/integration/networktest/env/testnet.go b/integration/networktest/env/testnet.go index 7e0d9cb810..fbe5a3e08d 100644 --- a/integration/networktest/env/testnet.go +++ b/integration/networktest/env/testnet.go @@ -113,7 +113,7 @@ func (t *testnetConnector) GetValidatorNode(_ int) networktest.NodeOperator { } func (t *testnetConnector) AllocateFaucetFundsWithWallet(ctx context.Context, account gethcommon.Address) error { - txHash, err := t.faucetWallet.SendFunds(ctx, account, _defaultFaucetAmount, 1_000_000) + txHash, err := t.faucetWallet.SendFunds(ctx, account, _defaultFaucetAmount) if err != nil { return err } diff --git a/integration/networktest/userwallet/userwallet.go b/integration/networktest/userwallet/userwallet.go index aa580037b9..6cbd6c6c9d 100644 --- a/integration/networktest/userwallet/userwallet.go +++ b/integration/networktest/userwallet/userwallet.go @@ -85,19 +85,18 @@ func (s *UserWallet) ChainID() *big.Int { return big.NewInt(integration.TenChainID) } -func (s *UserWallet) SendFunds(ctx context.Context, addr gethcommon.Address, value *big.Int, gas uint64) (*gethcommon.Hash, error) { +func (s *UserWallet) SendFunds(ctx context.Context, addr gethcommon.Address, value *big.Int) (*gethcommon.Hash, error) { err := s.EnsureClientSetup(ctx) if err != nil { return nil, fmt.Errorf("unable to prepare client to send funds - %w", err) } - tx := &types.LegacyTx{ - Nonce: s.nonce, - Value: value, - Gas: gas, - GasPrice: gethcommon.Big1, - To: &addr, + txData := &types.LegacyTx{ + Nonce: s.nonce, + Value: value, + To: &addr, } + tx := s.client.EstimateGasAndGasPrice(txData) //nolint: contextcheck txHash, err := s.SendTransaction(ctx, tx) if err != nil { @@ -107,7 +106,7 @@ func (s *UserWallet) SendFunds(ctx context.Context, addr gethcommon.Address, val return txHash, nil } -func (s *UserWallet) SendTransaction(ctx context.Context, tx *types.LegacyTx) (*gethcommon.Hash, error) { +func (s *UserWallet) SendTransaction(ctx context.Context, tx types.TxData) (*gethcommon.Hash, error) { signedTx, err := s.SignTransaction(tx) if err != nil { return nil, fmt.Errorf("unable to sign transaction - %w", err) diff --git a/integration/simulation/devnetwork/dev_network.go b/integration/simulation/devnetwork/dev_network.go index ea85e7ed5d..a668bdc5d5 100644 --- a/integration/simulation/devnetwork/dev_network.go +++ b/integration/simulation/devnetwork/dev_network.go @@ -71,7 +71,7 @@ func (s *InMemDevNetwork) AllocateFaucetFunds(ctx context.Context, account gethc s.faucetLock.Lock() defer s.faucetLock.Unlock() - txHash, err := s.faucet.SendFunds(ctx, account, _defaultFaucetAmount, 1_000_000) + txHash, err := s.faucet.SendFunds(ctx, account, _defaultFaucetAmount) if err != nil { return err }