Skip to content

Commit 0f49e9c

Browse files
committed
added log prints to crosschain_swap E2E test
1 parent 1d2edd1 commit 0f49e9c

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

e2e/e2etests/test_crosschain_swap.go

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
141141
if err != nil {
142142
panic(err)
143143
}
144+
r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos)))
144145
r.Logger.Info("#utxos %d", len(utxos))
145146
r.Logger.Info("memo address %s", r.ERC20ZRC20Addr)
146147
memo, err := r.ZEVMSwapApp.EncodeMemo(&bind.CallOpts{}, r.ERC20ZRC20Addr, r.DeployerAddress.Bytes())
@@ -150,6 +151,8 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
150151
memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...)
151152
r.Logger.Info("memo length %d", len(memo))
152153

154+
r.Logger.Print(fmt.Sprintf("SendToTSSFromDeployerWithMemo deploer address: %s\n", r.BTCDeployerAddress))
155+
r.Logger.Print("SendToTSSFromDeployerWithMemo-1")
153156
txID, err := r.SendToTSSFromDeployerWithMemo(
154157
r.BTCTSSAddress,
155158
0.01,
@@ -198,6 +201,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
198201
memo = append(r.ZEVMSwapAppAddr.Bytes(), memo...)
199202
r.Logger.Info("memo length %d", len(memo))
200203

204+
r.Logger.Print("SendToTSSFromDeployerWithMemo-2")
201205
amount := 0.1
202206
txid, err := r.SendToTSSFromDeployerWithMemo(
203207
r.BTCTSSAddress,

e2e/runner/bitcoin.go

+35-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
214214
scriptPubkeys := make([]string, len(inputUTXOs))
215215

216216
for i, utxo := range inputUTXOs {
217-
inputs[i] = btcjson.TransactionInput{utxo.TxID, utxo.Vout}
217+
inputs[i] = btcjson.TransactionInput{
218+
Txid: utxo.TxID,
219+
Vout: utxo.Vout,
220+
}
218221
inputSats += btcutil.Amount(utxo.Amount * btcutil.SatoshiPerBitcoin)
219222
amounts[i] = utxo.Amount
220223
scriptPubkeys[i] = utxo.ScriptPubKey
@@ -253,7 +256,7 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
253256
tx.TxOut[1], tx.TxOut[2] = tx.TxOut[2], tx.TxOut[1]
254257

255258
// make sure that TxOut[0] is sent to "to" address; TxOut[2] is change to oneself. TxOut[1] is memo.
256-
if bytes.Compare(tx.TxOut[0].PkScript[2:], to.ScriptAddress()) != 0 {
259+
if !bytes.Equal(tx.TxOut[0].PkScript[2:], to.ScriptAddress()) {
257260
runner.Logger.Info("tx.TxOut[0].PkScript: %x", tx.TxOut[0].PkScript)
258261
runner.Logger.Info("to.ScriptAddress(): %x", to.ScriptAddress())
259262
runner.Logger.Info("swapping txout[0] with txout[2]")
@@ -281,6 +284,36 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
281284
if err != nil {
282285
panic(err)
283286
}
287+
288+
// print transaction inputs
289+
runner.Logger.Info("SignRawTransactionWithWallet2 input: %+v", inputsForSign)
290+
for _, input := range inputUTXOs {
291+
runner.Logger.Print(" txid: %s", input.TxID)
292+
runner.Logger.Print(" vout: %d", input.Vout)
293+
runner.Logger.Print(" address: %s", input.Address)
294+
runner.Logger.Print(" amount: %f", input.Amount)
295+
runner.Logger.Print(" confirmations: %d", input.Confirmations)
296+
}
297+
298+
// retry for 10 times if not signed
299+
if !signed {
300+
for i := 0; i < 10; i++ {
301+
runner.Logger.Print(fmt.Sprintf("retrying SignRawTransactionWithWallet2: %d", i+1))
302+
stx, signed, err = btcRPC.SignRawTransactionWithWallet2(tx, inputsForSign)
303+
if err != nil {
304+
panic(err)
305+
}
306+
if signed {
307+
break
308+
}
309+
time.Sleep(1 * time.Second)
310+
_, err = btcRPC.GenerateToAddress(1, btcDeployerAddress, nil)
311+
if err != nil {
312+
panic(err)
313+
}
314+
}
315+
}
316+
284317
if !signed {
285318
panic("btc transaction not signed")
286319
}

0 commit comments

Comments
 (0)