@@ -15,22 +15,26 @@ import (
15
15
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
16
16
)
17
17
18
- func parseBitcoinWithdrawArgs (args []string , defaultReceiver string ) (btcutil.Address , * big.Int ) {
18
+ func parseBitcoinWithdrawArgs (r * runner.E2ERunner , args []string , defaultReceiver string ) (btcutil.Address , * big.Int ) {
19
+ // get bitcoin chain id
20
+ chainID := r .GetBitcoinChainID ()
21
+
19
22
// parse receiver address
20
23
var err error
21
24
var receiver btcutil.Address
22
25
if args [0 ] == "" {
23
26
// use the default receiver
24
- receiver , err = chains .DecodeBtcAddress (defaultReceiver , chains . BtcRegtestChain . ChainId )
27
+ receiver , err = chains .DecodeBtcAddress (defaultReceiver , chainID )
25
28
if err != nil {
26
29
panic ("Invalid default receiver address specified for TestBitcoinWithdraw." )
27
30
}
28
31
} else {
29
- receiver , err = chains .DecodeBtcAddress (args [0 ], chains . BtcRegtestChain . ChainId )
32
+ receiver , err = chains .DecodeBtcAddress (args [0 ], chainID )
30
33
if err != nil {
31
34
panic ("Invalid receiver address specified for TestBitcoinWithdraw." )
32
35
}
33
36
}
37
+
34
38
// parse the withdrawal amount
35
39
withdrawalAmount , err := strconv .ParseFloat (args [1 ], 64 )
36
40
if err != nil {
@@ -59,8 +63,12 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)
59
63
panic (fmt .Errorf ("approve receipt status is not 1" ))
60
64
}
61
65
62
- // mine blocks
63
- stop := r .MineBlocks ()
66
+ // mine blocks if testing on regnet
67
+ var stop chan struct {}
68
+ isRegnet := chains .IsBitcoinRegnet (r .GetBitcoinChainID ())
69
+ if isRegnet {
70
+ stop = r .MineBlocks ()
71
+ }
64
72
65
73
// withdraw 'amount' of BTC from ZRC20 to BTC address
66
74
tx , err = r .BTCZRC20 .Withdraw (r .ZEVMAuth , []byte (to .EncodeAddress ()), amount )
@@ -110,7 +118,9 @@ func withdrawBTCZRC20(r *runner.E2ERunner, to btcutil.Address, amount *big.Int)
110
118
}
111
119
112
120
// stop mining
113
- stop <- struct {}{}
121
+ if isRegnet {
122
+ stop <- struct {}{}
123
+ }
114
124
115
125
return rawTx
116
126
}
0 commit comments