Skip to content

Commit

Permalink
try sleeping before listing unspent
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed May 10, 2024
1 parent 6c2b73f commit fb39055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
4 changes: 4 additions & 0 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutTxParam().OutboundTxHash)

r.Logger.Info("******* Second test: BTC -> ERC20ZRC20")

// wait a few seconds before listing utxos
time.Sleep(5 * time.Second)

utxos, err := r.BtcRPCClient.ListUnspent()
if err != nil {
panic(err)
Expand Down
25 changes: 4 additions & 21 deletions e2e/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
}
}

stx, err := signRawTransactionWithWallet2WithRetry(btcRPC, tx, inputsForSign)
stx, signed, err := btcRPC.SignRawTransactionWithWallet2(tx, inputsForSign)
if err != nil {
panic(err)
}
if signed {
panic("not signed")
}
txid, err := btcRPC.SendRawTransaction(stx, true)
if err != nil {
panic(err)
Expand Down Expand Up @@ -404,23 +407,3 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) {
}
runner.Logger.Info("OK: txProof verified for inTx: %s", txHash.String())
}

// SignRawTransactionWithWallet2WithRetry signs a raw transaction with wallet2 and retries if it's not signed
func signRawTransactionWithWallet2WithRetry(
btcRPC *rpcclient.Client,
tx *wire.MsgTx,
inputsForSign []btcjson.RawTxWitnessInput,
) (*wire.MsgTx, error) {
for i := 0; i < 5; i++ {
stx, signed, err := btcRPC.SignRawTransactionWithWallet2(tx, inputsForSign)
if err != nil {
return nil, err
}
if signed {
return stx, nil
}
time.Sleep(2 * time.Second)
}

return nil, fmt.Errorf("signRawTransactionWithWallet2WithRetry: not signed")
}

0 comments on commit fb39055

Please sign in to comment.