diff --git a/e2e/e2etests/helper_bitcoin.go b/e2e/e2etests/helper_bitcoin.go index 338cd7027f..c5cd113f40 100644 --- a/e2e/e2etests/helper_bitcoin.go +++ b/e2e/e2etests/helper_bitcoin.go @@ -64,7 +64,7 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) } // mine blocks if testing on regnet - var stop chan struct{} + var stop func() isRegnet := chains.IsBitcoinRegnet(r.GetBitcoinChainID()) if isRegnet { stop = r.MineBlocks() @@ -119,7 +119,7 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int) // stop mining if isRegnet { - stop <- struct{}{} + stop() } return rawTx diff --git a/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go b/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go index 8d4698f489..a682aa5629 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go +++ b/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go @@ -47,7 +47,7 @@ func withdrawToInvalidAddress(r *runner.E2ERunner, amount *big.Int) { } // mine blocks if testing on regnet - var stop chan struct{} + var stop func() isRegnet := chains.IsBitcoinRegnet(r.GetBitcoinChainID()) if isRegnet { stop = r.MineBlocks() @@ -66,6 +66,6 @@ func withdrawToInvalidAddress(r *runner.E2ERunner, amount *big.Int) { // stop mining if isRegnet { - stop <- struct{}{} + stop() } } diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index cb74056710..5d5cd18c62 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -116,7 +116,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { } // mine blocks if testing on regnet - var stop chan struct{} + var stop func() isRegnet := chains.IsBitcoinRegnet(r.GetBitcoinChainID()) if isRegnet { stop = r.MineBlocks() @@ -240,6 +240,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { // stop mining if isRegnet { - stop <- struct{}{} + stop() } } diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 768c872743..4c5e15d298 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -366,12 +366,12 @@ func (runner *E2ERunner) GetBitcoinChainID() int64 { // MineBlocks mines blocks on the BTC chain at a rate of 1 blocks every 5 seconds // and returns a channel that can be used to stop the mining -func (runner *E2ERunner) MineBlocks() chan struct{} { - stop := make(chan struct{}) +func (runner *E2ERunner) MineBlocks() func() { + stopChan := make(chan struct{}) go func() { for { select { - case <-stop: + case <-stopChan: return default: _, err := runner.BtcRPCClient.GenerateToAddress(1, runner.BTCDeployerAddress, nil) @@ -382,7 +382,10 @@ func (runner *E2ERunner) MineBlocks() chan struct{} { } } }() - return stop + + return func() { + close(stopChan) + } } // ProveBTCTransaction proves that a BTC transaction is in a block header and that the block header is in ZetaChain