From 4189e794fc156b85b854b6f11894bce9eae67030 Mon Sep 17 00:00:00 2001 From: Ralph Pichler Date: Wed, 18 Dec 2019 15:19:38 +0100 Subject: [PATCH] swap: pass the context to waitForTx directly --- contracts/swap/factory.go | 2 +- contracts/swap/swap.go | 10 +++++----- swap/swap_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/swap/factory.go b/contracts/swap/factory.go index cd029c6449..5c3c7a0be1 100644 --- a/contracts/swap/factory.go +++ b/contracts/swap/factory.go @@ -83,7 +83,7 @@ func (sf simpleSwapFactory) DeploySimpleSwap(auth *bind.TransactOpts, issuer com return nil, err } - receipt, err := WaitFunc(auth, sf.backend, tx) + receipt, err := WaitFunc(auth.Context, sf.backend, tx) if err != nil { return nil, err } diff --git a/contracts/swap/swap.go b/contracts/swap/swap.go index 74134ea0eb..3be7f3203c 100644 --- a/contracts/swap/swap.go +++ b/contracts/swap/swap.go @@ -106,7 +106,7 @@ func (s simpleContract) Withdraw(auth *bind.TransactOpts, amount *big.Int) (*typ if err != nil { return nil, err } - return WaitFunc(auth, s.backend, tx) + return WaitFunc(auth.Context, s.backend, tx) } // Deposit sends an amount in ERC20 token to the chequebook and blocks until the transaction is mined @@ -136,7 +136,7 @@ func (s simpleContract) Deposit(auth *bind.TransactOpts, amount *big.Int) (*type if err != nil { return nil, err } - return WaitFunc(auth, s.backend, tx) + return WaitFunc(auth.Context, s.backend, tx) } // CashChequeBeneficiary cashes the cheque on the blockchain and blocks until the transaction is mined. @@ -145,7 +145,7 @@ func (s simpleContract) CashChequeBeneficiary(opts *bind.TransactOpts, beneficia if err != nil { return nil, nil, err } - receipt, err := WaitFunc(opts, s.backend, tx) + receipt, err := WaitFunc(opts.Context, s.backend, tx) if err != nil { return nil, nil, err } @@ -225,9 +225,9 @@ func (s simpleContract) PaidOut(opts *bind.CallOpts, addr common.Address) (*big. var WaitFunc = waitForTx // waitForTx waits for transaction to be mined and returns the receipt -func waitForTx(auth *bind.TransactOpts, backend Backend, tx *types.Transaction) (*types.Receipt, error) { +func waitForTx(ctx context.Context, backend Backend, tx *types.Transaction) (*types.Receipt, error) { // it blocks here until tx is mined - receipt, err := bind.WaitMined(auth.Context, backend, tx) + receipt, err := bind.WaitMined(ctx, backend, tx) if err != nil { return nil, err } diff --git a/swap/swap_test.go b/swap/swap_test.go index 5eabba26a9..87f0d4c81f 100644 --- a/swap/swap_test.go +++ b/swap/swap_test.go @@ -1245,7 +1245,7 @@ func TestContractIntegration(t *testing.T) { } // when testing, we don't need to wait for a transaction to be mined -func testWaitForTx(auth *bind.TransactOpts, backend cswap.Backend, tx *types.Transaction) (*types.Receipt, error) { +func testWaitForTx(ctx context.Context, backend cswap.Backend, tx *types.Transaction) (*types.Receipt, error) { var stb *swapTestBackend var ok bool @@ -1254,7 +1254,7 @@ func testWaitForTx(auth *bind.TransactOpts, backend cswap.Backend, tx *types.Tra } stb.Commit() - receipt, err := backend.TransactionReceipt(context.TODO(), tx.Hash()) + receipt, err := backend.TransactionReceipt(ctx, tx.Hash()) if err != nil { return nil, err }