From a053d408efd5c2d1d92f509b13003b5500d86506 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Sat, 24 Aug 2024 17:13:47 +0300 Subject: [PATCH] accounts, ethclient: check SendTransaction returned err --- accounts/abi/bind/util_test.go | 12 +++++++++--- ethclient/simulated/backend_test.go | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go index 592465f2ac..04d1bb63bc 100644 --- a/accounts/abi/bind/util_test.go +++ b/accounts/abi/bind/util_test.go @@ -82,7 +82,9 @@ func TestWaitDeployed(t *testing.T) { }() // Send and mine the transaction. - backend.Client().SendTransaction(ctx, tx) + if err := backend.Client().SendTransaction(ctx, tx); err != nil { + t.Errorf("test %q: failed to send transaction: %v", name, err) + } backend.Commit() select { @@ -116,7 +118,9 @@ func TestWaitDeployedCornerCases(t *testing.T) { tx, _ = types.SignTx(tx, types.LatestSigner(params.AllDevChainProtocolChanges), testKey) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - backend.Client().SendTransaction(ctx, tx) + if err := backend.Client().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.Client(), tx); err.Error() != notContractCreation.Error() { @@ -134,6 +138,8 @@ func TestWaitDeployedCornerCases(t *testing.T) { } }() - backend.Client().SendTransaction(ctx, tx) + if err := backend.Client().SendTransaction(ctx, tx); err != nil { + t.Errorf("failed to send transaction: %q", err) + } cancel() } diff --git a/ethclient/simulated/backend_test.go b/ethclient/simulated/backend_test.go index b70086b385..3d7430b882 100644 --- a/ethclient/simulated/backend_test.go +++ b/ethclient/simulated/backend_test.go @@ -213,7 +213,9 @@ func TestForkResendTx(t *testing.T) { if err != nil { t.Fatalf("could not create transaction: %v", err) } - client.SendTransaction(ctx, tx) + if err := client.SendTransaction(ctx, tx); err != nil { + t.Fatalf("sending transaction: %v", err) + } sim.Commit() // 3. @@ -260,7 +262,9 @@ 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) - client.SendTransaction(ctx, tx) + if err := client.SendTransaction(ctx, tx); err != nil { + t.Errorf("sending transaction: %v", err) + } h2 := sim.Commit()