diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 187582fd89d22..62b72cbccc394 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -1376,29 +1376,38 @@ func TestForkResendTx(t *testing.T) { defer sim.Close() // 1. parent := sim.blockchain.CurrentBlock() + // 2. head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1)) - _tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil) - tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey) - sim.SendTransaction(context.Background(), tx) + tx, err := types.SignTx(_tx, types.HomesteadSigner{}, testKey) + if err != nil { + t.Fatalf("could not sign transaction: %v", err) + } + if err = sim.SendTransaction(context.Background(), tx); err != nil { + t.Fatalf("sending transaction: %v", err) + } sim.Commit() + // 3. receipt, _ := sim.TransactionReceipt(context.Background(), tx.Hash()) if h := receipt.BlockNumber.Uint64(); h != 1 { t.Errorf("TX included in wrong block: %d", h) } + // 4. if err := sim.Fork(context.Background(), parent.Hash()); err != nil { t.Errorf("forking: %v", err) } + // 5. sim.Commit() if err := sim.SendTransaction(context.Background(), tx); err != nil { t.Errorf("sending transaction: %v", err) } sim.Commit() + // 6. receipt, _ = sim.TransactionReceipt(context.Background(), tx.Hash()) if h := receipt.BlockNumber.Uint64(); h != 2 { @@ -1425,7 +1434,10 @@ func TestCommitReturnValue(t *testing.T) { gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1)) _tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil) tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey) - sim.SendTransaction(context.Background(), tx) + if err := sim.SendTransaction(context.Background(), tx); err != nil { + t.Errorf("sending transaction: %v", err) + } + h2 := sim.Commit() // Create another block in the original chain diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index 89deb2c5599b0..839d31cb73d18 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -86,7 +86,9 @@ func TestWaitDeployed(t *testing.T) { }() // Send and mine the transaction. - backend.SendTransaction(ctx, tx) + if err := backend.SendTransaction(ctx, tx); err != nil { + t.Errorf("test %q: failed to send transaction: %v", name, err) + } backend.Commit() select { @@ -125,7 +127,9 @@ func TestWaitDeployedCornerCases(t *testing.T) { tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - backend.SendTransaction(ctx, tx) + if err := backend.SendTransaction(ctx, tx); err != nil { + t.Errorf("failed to send transaction: %q", err) + } backend.Commit() notContractCreation := errors.New("tx is not contract creation") if _, err := bind.WaitDeployed(ctx, backend, tx); err.Error() != notContractCreation.Error() { @@ -143,6 +147,8 @@ func TestWaitDeployedCornerCases(t *testing.T) { } }() - backend.SendTransaction(ctx, tx) + if err := backend.SendTransaction(ctx, tx); err != nil { + t.Errorf("failed to send transaction: %q", err) + } cancel() }