From c3ba41a8115ea1417dd283e9423b33adf91c64d1 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Fri, 24 May 2024 14:46:52 -0500 Subject: [PATCH 1/8] try fixing E2E crosschain_swap failure --- e2e/e2etests/test_crosschain_swap.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index ef5680b331..8ad70e04f8 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -153,7 +153,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { txID, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, 0.01, - utxos[0:2], + utxos[0:1], r.BtcRPCClient, memo, r.BTCDeployerAddress, @@ -161,11 +161,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { if err != nil { panic(err) } - r.Logger.Info("Sent BTC to TSS txid %s; now mining 10 blocks for confirmation", txID) - _, err = r.BtcRPCClient.GenerateToAddress(10, r.BTCDeployerAddress, nil) - if err != nil { - panic(err) - } cctx3 := utils.WaitCctxMinedByInboundHash(r.Ctx, txID.String(), r.CctxClient, r.Logger, r.CctxTimeout) if cctx3.CctxStatus.Status != types.CctxStatus_OutboundMined { @@ -194,11 +189,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { { r.Logger.Info("******* Third test: BTC -> ETH with contract call reverted; should refund BTC") - utxos, err := r.BtcRPCClient.ListUnspent() - if err != nil { - panic(err) - } - r.Logger.Info("#utxos %d", len(utxos)) // the following memo will result in a revert in the contract call as targetZRC20 is set to DeployerAddress // which is apparently not a ZRC20 contract; the UNISWAP call will revert memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.DeployerAddress, r.DeployerAddress.Bytes()) @@ -212,7 +202,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { txid, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, amount, - utxos[0:2], + utxos[1:2], r.BtcRPCClient, memo, r.BTCDeployerAddress, @@ -220,11 +210,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { if err != nil { panic(err) } - r.Logger.Info("Sent BTC to TSS txid %s; now mining 10 blocks for confirmation", txid) - _, err = r.BtcRPCClient.GenerateToAddress(10, r.BTCDeployerAddress, nil) - if err != nil { - panic(err) - } cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txid.String(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.Info("cctx3 index %s", cctx.Index) From 6e364d28624a85194703644ba02e277e5c03ffe3 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Fri, 24 May 2024 14:54:20 -0500 Subject: [PATCH 2/8] added changelog entry --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index d3f774081d..858a6e3297 100644 --- a/changelog.md +++ b/changelog.md @@ -37,6 +37,7 @@ * [2184](https://github.com/zeta-chain/node/pull/2184) - add tx priority checks to e2e tests * [2199](https://github.com/zeta-chain/node/pull/2199) - custom priority mempool unit tests * [2240](https://github.com/zeta-chain/node/pull/2240) - removed hard-coded Bitcoin regnet chainID in E2E withdraw tests +* [2266](https://github.com/zeta-chain/node/pull/2266) - try fixing E2E test `crosschain_swap` failure `btc transaction not signed` ### Fixes From 0f49e9ce042612fcbaea702a7ed9c1b25babf379 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 29 May 2024 00:30:51 -0500 Subject: [PATCH 3/8] added log prints to crosschain_swap E2E test --- e2e/e2etests/test_crosschain_swap.go | 4 +++ e2e/runner/bitcoin.go | 37 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 8ad70e04f8..4df1ac129c 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -141,6 +141,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { if err != nil { panic(err) } + r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos))) r.Logger.Info("#utxos %d", len(utxos)) r.Logger.Info("memo address %s", r.ERC20ZRC20Addr) memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ERC20ZRC20Addr, r.DeployerAddress.Bytes()) @@ -150,6 +151,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...) r.Logger.Info("memo length %d", len(memo)) + r.Logger.Print(fmt.Sprintf("SendToTSSFromDeployerWithMemo deploer address: %s\n", r.BTCDeployerAddress)) + r.Logger.Print("SendToTSSFromDeployerWithMemo-1") txID, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, 0.01, @@ -198,6 +201,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...) r.Logger.Info("memo length %d", len(memo)) + r.Logger.Print("SendToTSSFromDeployerWithMemo-2") amount := 0.1 txid, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index f1d10339fa..9d9bfc48cf 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -214,7 +214,10 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo( scriptPubkeys := make([]string, len(inputUTXOs)) for i, utxo := range inputUTXOs { - inputs[i] = btcjson.TransactionInput{utxo.TxID, utxo.Vout} + inputs[i] = btcjson.TransactionInput{ + Txid: utxo.TxID, + Vout: utxo.Vout, + } inputSats += btcutil.Amount(utxo.Amount * btcutil.SatoshiPerBitcoin) amounts[i] = utxo.Amount scriptPubkeys[i] = utxo.ScriptPubKey @@ -253,7 +256,7 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo( tx.TxOut[1], tx.TxOut[2] = tx.TxOut[2], tx.TxOut[1] // make sure that TxOut[0] is sent to "to" address; TxOut[2] is change to oneself. TxOut[1] is memo. - if bytes.Compare(tx.TxOut[0].PkScript[2:], to.ScriptAddress()) != 0 { + if !bytes.Equal(tx.TxOut[0].PkScript[2:], to.ScriptAddress()) { runner.Logger.Info("tx.TxOut[0].PkScript: %x", tx.TxOut[0].PkScript) runner.Logger.Info("to.ScriptAddress(): %x", to.ScriptAddress()) runner.Logger.Info("swapping txout[0] with txout[2]") @@ -281,6 +284,36 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo( if err != nil { panic(err) } + + // print transaction inputs + runner.Logger.Info("SignRawTransactionWithWallet2 input: %+v", inputsForSign) + for _, input := range inputUTXOs { + runner.Logger.Print(" txid: %s", input.TxID) + runner.Logger.Print(" vout: %d", input.Vout) + runner.Logger.Print(" address: %s", input.Address) + runner.Logger.Print(" amount: %f", input.Amount) + runner.Logger.Print(" confirmations: %d", input.Confirmations) + } + + // retry for 10 times if not signed + if !signed { + for i := 0; i < 10; i++ { + runner.Logger.Print(fmt.Sprintf("retrying SignRawTransactionWithWallet2: %d", i+1)) + stx, signed, err = btcRPC.SignRawTransactionWithWallet2(tx, inputsForSign) + if err != nil { + panic(err) + } + if signed { + break + } + time.Sleep(1 * time.Second) + _, err = btcRPC.GenerateToAddress(1, btcDeployerAddress, nil) + if err != nil { + panic(err) + } + } + } + if !signed { panic("btc transaction not signed") } From 887ef27c87f76aa0ac551ec472f643ed51c5f1b6 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 29 May 2024 09:46:56 -0500 Subject: [PATCH 4/8] filter by deployer address when listing UTXOs --- e2e/e2etests/test_crosschain_swap.go | 5 +---- e2e/runner/bitcoin.go | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 4df1ac129c..1b23d11993 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -137,10 +137,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash) r.Logger.Info("******* Second test: BTC -> ERC20ZRC20") - utxos, err := r.BtcRPCClient.ListUnspent() - if err != nil { - panic(err) - } + utxos := r.ListDeployerUTXOs() r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos))) r.Logger.Info("#utxos %d", len(utxos)) r.Logger.Info("memo address %s", r.ERC20ZRC20Addr) diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 9d9bfc48cf..62a52a8014 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -29,11 +29,8 @@ import ( var blockHeaderBTCTimeout = 5 * time.Minute -// DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount -func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) { - runner.Logger.Print("⏳ depositing BTC into ZEVM") - - // fetch utxos +// ListDeployerUTXOs lists the deployer's UTXOs +func (runner *E2ERunner) ListDeployerUTXOs() []btcjson.ListUnspentResult { utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses( 1, 9999999, @@ -42,6 +39,15 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash if err != nil { panic(err) } + return utxos +} + +// DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount +func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) { + runner.Logger.Print("⏳ depositing BTC into ZEVM") + + // fetch utxos + utxos := runner.ListDeployerUTXOs() spendableAmount := 0.0 spendableUTXOs := 0 @@ -62,7 +68,7 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash runner.Logger.Info("Now sending two txs to TSS address...") amount = amount + zetabitcoin.DefaultDepositorFee - txHash, err = runner.SendToTSSFromDeployerToDeposit( + txHash, err := runner.SendToTSSFromDeployerToDeposit( runner.BTCTSSAddress, amount, utxos, @@ -87,10 +93,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { // fetch utxos btc := runner.BtcRPCClient - utxos, err := runner.BtcRPCClient.ListUnspent() - if err != nil { - panic(err) - } + utxos := runner.ListDeployerUTXOs() spendableAmount := 0.0 spendableUTXOs := 0 for _, utxo := range utxos { From 0e38245382abb741ee04450a0b82edbe250ab459 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 29 May 2024 10:41:18 -0500 Subject: [PATCH 5/8] filter UTXOs by amount in E2E test to avoid 'not enough input amount' --- e2e/e2etests/test_crosschain_swap.go | 3 ++- e2e/runner/bitcoin.go | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 1b23d11993..000020a7e2 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -137,7 +137,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash) r.Logger.Info("******* Second test: BTC -> ERC20ZRC20") - utxos := r.ListDeployerUTXOs() + // Note: the test needs at least 0.1001 BTC + utxos := r.ListDeployerUTXOs(1.0) r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos))) r.Logger.Info("#utxos %d", len(utxos)) r.Logger.Info("memo address %s", r.ERC20ZRC20Addr) diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 62a52a8014..13e9993873 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -29,8 +29,9 @@ import ( var blockHeaderBTCTimeout = 5 * time.Minute -// ListDeployerUTXOs lists the deployer's UTXOs -func (runner *E2ERunner) ListDeployerUTXOs() []btcjson.ListUnspentResult { +// ListDeployerUTXOs list and filter the deployer's UTXOs +func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) []btcjson.ListUnspentResult { + // query UTXOs from node utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses( 1, 9999999, @@ -39,7 +40,16 @@ func (runner *E2ERunner) ListDeployerUTXOs() []btcjson.ListUnspentResult { if err != nil { panic(err) } - return utxos + + // filter UTXOs by `minAmount` + filtered := []btcjson.ListUnspentResult{} + for _, utxo := range utxos { + if utxo.Amount >= minAmount { + filtered = append(filtered, utxo) + } + } + + return filtered } // DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount @@ -47,7 +57,7 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash runner.Logger.Print("⏳ depositing BTC into ZEVM") // fetch utxos - utxos := runner.ListDeployerUTXOs() + utxos := runner.ListDeployerUTXOs(1.0) spendableAmount := 0.0 spendableUTXOs := 0 @@ -93,7 +103,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { // fetch utxos btc := runner.BtcRPCClient - utxos := runner.ListDeployerUTXOs() + utxos := runner.ListDeployerUTXOs(1.0) spendableAmount := 0.0 spendableUTXOs := 0 for _, utxo := range utxos { From db85efce23271c02ed2faeb00823f05f9eadf28d Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 29 May 2024 11:19:28 -0500 Subject: [PATCH 6/8] revert the log prints for debugging --- e2e/e2etests/test_crosschain_swap.go | 4 ---- e2e/runner/bitcoin.go | 29 ---------------------------- 2 files changed, 33 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 000020a7e2..16f04ab656 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -139,7 +139,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("******* Second test: BTC -> ERC20ZRC20") // Note: the test needs at least 0.1001 BTC utxos := r.ListDeployerUTXOs(1.0) - r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos))) r.Logger.Info("#utxos %d", len(utxos)) r.Logger.Info("memo address %s", r.ERC20ZRC20Addr) memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ERC20ZRC20Addr, r.DeployerAddress.Bytes()) @@ -149,8 +148,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...) r.Logger.Info("memo length %d", len(memo)) - r.Logger.Print(fmt.Sprintf("SendToTSSFromDeployerWithMemo deploer address: %s\n", r.BTCDeployerAddress)) - r.Logger.Print("SendToTSSFromDeployerWithMemo-1") txID, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, 0.01, @@ -199,7 +196,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...) r.Logger.Info("memo length %d", len(memo)) - r.Logger.Print("SendToTSSFromDeployerWithMemo-2") amount := 0.1 txid, err := r.SendToTSSFromDeployerWithMemo( r.BTCTSSAddress, diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 13e9993873..19f8796e6a 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -298,35 +298,6 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo( panic(err) } - // print transaction inputs - runner.Logger.Info("SignRawTransactionWithWallet2 input: %+v", inputsForSign) - for _, input := range inputUTXOs { - runner.Logger.Print(" txid: %s", input.TxID) - runner.Logger.Print(" vout: %d", input.Vout) - runner.Logger.Print(" address: %s", input.Address) - runner.Logger.Print(" amount: %f", input.Amount) - runner.Logger.Print(" confirmations: %d", input.Confirmations) - } - - // retry for 10 times if not signed - if !signed { - for i := 0; i < 10; i++ { - runner.Logger.Print(fmt.Sprintf("retrying SignRawTransactionWithWallet2: %d", i+1)) - stx, signed, err = btcRPC.SignRawTransactionWithWallet2(tx, inputsForSign) - if err != nil { - panic(err) - } - if signed { - break - } - time.Sleep(1 * time.Second) - _, err = btcRPC.GenerateToAddress(1, btcDeployerAddress, nil) - if err != nil { - panic(err) - } - } - } - if !signed { panic("btc transaction not signed") } From f40ac9277fc52f01c2145888d605296b5f89a39d Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 29 May 2024 16:31:24 -0500 Subject: [PATCH 7/8] remove panic from btc runner method ListDeployerUTXOs() --- e2e/e2etests/test_crosschain_swap.go | 6 +++++- e2e/runner/bitcoin.go | 30 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 16f04ab656..b96625a56a 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -137,8 +137,12 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash) r.Logger.Info("******* Second test: BTC -> ERC20ZRC20") + // list deployer utxos // Note: the test needs at least 0.1001 BTC - utxos := r.ListDeployerUTXOs(1.0) + utxos, err := r.ListDeployerUTXOs(1.0) + if err != nil { + panic(err) + } r.Logger.Info("#utxos %d", len(utxos)) r.Logger.Info("memo address %s", r.ERC20ZRC20Addr) memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ERC20ZRC20Addr, r.DeployerAddress.Bytes()) diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 19f8796e6a..a7df6b13db 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -30,7 +30,7 @@ import ( var blockHeaderBTCTimeout = 5 * time.Minute // ListDeployerUTXOs list and filter the deployer's UTXOs -func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) []btcjson.ListUnspentResult { +func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) ([]btcjson.ListUnspentResult, error) { // query UTXOs from node utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses( 1, @@ -38,7 +38,7 @@ func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) []btcjson.ListUnsp []btcutil.Address{runner.BTCDeployerAddress}, ) if err != nil { - panic(err) + return nil, err } // filter UTXOs by `minAmount` @@ -49,15 +49,18 @@ func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) []btcjson.ListUnsp } } - return filtered + return filtered, nil } // DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) { runner.Logger.Print("⏳ depositing BTC into ZEVM") - // fetch utxos - utxos := runner.ListDeployerUTXOs(1.0) + // list deployer utxos + utxos, err := runner.ListDeployerUTXOs(1.0) + if err != nil { + panic(err) + } spendableAmount := 0.0 spendableUTXOs := 0 @@ -78,7 +81,7 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash runner.Logger.Info("Now sending two txs to TSS address...") amount = amount + zetabitcoin.DefaultDepositorFee - txHash, err := runner.SendToTSSFromDeployerToDeposit( + txHash, err = runner.SendToTSSFromDeployerToDeposit( runner.BTCTSSAddress, amount, utxos, @@ -101,9 +104,12 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { runner.Logger.Print("✅ BTC deposited in %s", time.Since(startTime)) }() - // fetch utxos - btc := runner.BtcRPCClient - utxos := runner.ListDeployerUTXOs(1.0) + // list deployer utxos + utxos, err := runner.ListDeployerUTXOs(1.0) + if err != nil { + panic(err) + } + spendableAmount := 0.0 spendableUTXOs := 0 for _, utxo := range utxos { @@ -131,7 +137,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { runner.BTCTSSAddress, amount1, utxos[:2], - btc, + runner.BtcRPCClient, runner.BTCDeployerAddress, ) if err != nil { @@ -142,7 +148,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { runner.BTCTSSAddress, amount2, utxos[2:4], - btc, + runner.BtcRPCClient, runner.BTCDeployerAddress, ) if err != nil { @@ -155,7 +161,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { runner.BTCTSSAddress, 0.11, utxos[4:5], - btc, + runner.BtcRPCClient, []byte(constant.DonationMessage), runner.BTCDeployerAddress, ) From ff2794296e7ea41ddf9d47f187be274866f5146f Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Thu, 30 May 2024 09:40:38 -0500 Subject: [PATCH 8/8] added comments to ListDeployerUTXOs method and places it is used --- e2e/e2etests/test_crosschain_swap.go | 3 +-- e2e/runner/bitcoin.go | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index b96625a56a..cb74056710 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -137,8 +137,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash) r.Logger.Info("******* Second test: BTC -> ERC20ZRC20") - // list deployer utxos - // Note: the test needs at least 0.1001 BTC + // list deployer utxos that have at least 1 BTC utxos, err := r.ListDeployerUTXOs(1.0) if err != nil { panic(err) diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index a7df6b13db..9143926d06 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -29,7 +29,7 @@ import ( var blockHeaderBTCTimeout = 5 * time.Minute -// ListDeployerUTXOs list and filter the deployer's UTXOs +// ListDeployerUTXOs list the deployer's UTXOs that have at least `minAmount` func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) ([]btcjson.ListUnspentResult, error) { // query UTXOs from node utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses( @@ -56,7 +56,7 @@ func (runner *E2ERunner) ListDeployerUTXOs(minAmount float64) ([]btcjson.ListUns func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) { runner.Logger.Print("⏳ depositing BTC into ZEVM") - // list deployer utxos + // list deployer utxos that have at least 1 BTC utxos, err := runner.ListDeployerUTXOs(1.0) if err != nil { panic(err) @@ -104,7 +104,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) { runner.Logger.Print("✅ BTC deposited in %s", time.Since(startTime)) }() - // list deployer utxos + // list deployer utxos that have at least 1 BTC utxos, err := runner.ListDeployerUTXOs(1.0) if err != nil { panic(err)