test: wait for 2 transactions to enter mempool at the end of testMultiHopHtlcRemoteChainClaim
In this commit, we fix an existing flake on Travis related to the new set of on-chain HTLC tests. In this timing flake, Bob would broadcast his sweeping transaction, but *mid block mining*. As a result, the output would never be properly swept, needing an additional block to be mined. We’ll now wait for both Bob’s sweeping transaction, and Carol’s sweep transaction to be confirmed before we attempt our assertions.
This commit is contained in:
parent
5dc0d669a6
commit
2d104b7ec0
@ -487,8 +487,9 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("%T(%x): using %v sat/weight to sweep htlc",
|
log.Debugf("%T(%x): using %v sat/weight to sweep htlc"+
|
||||||
"incoming+remote htlc confirmed", h, h.payHash[:])
|
"incoming+remote htlc confirmed", h,
|
||||||
|
h.payHash[:], int64(satWeight))
|
||||||
|
|
||||||
// Using a weight estimator, we'll compute the total
|
// Using a weight estimator, we'll compute the total
|
||||||
// fee required, and from that the value we'll end up
|
// fee required, and from that the value we'll end up
|
||||||
@ -511,9 +512,6 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
Value: sweepAmt,
|
Value: sweepAmt,
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Infof("%T(%v): crafted sweep tx=%v", h,
|
|
||||||
h.payHash[:], spew.Sdump(h.sweepTx))
|
|
||||||
|
|
||||||
// With the transaction fully assembled, we can now
|
// With the transaction fully assembled, we can now
|
||||||
// generate a valid witness for the transaction.
|
// generate a valid witness for the transaction.
|
||||||
h.htlcResolution.SweepSignDesc.SigHashes = txscript.NewTxSigHashes(
|
h.htlcResolution.SweepSignDesc.SigHashes = txscript.NewTxSigHashes(
|
||||||
@ -527,6 +525,9 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("%T(%x): crafted sweep tx=%v", h,
|
||||||
|
h.payHash[:], spew.Sdump(h.sweepTx))
|
||||||
|
|
||||||
// With the sweep transaction confirmed, we'll now
|
// With the sweep transaction confirmed, we'll now
|
||||||
// Checkpoint our state.
|
// Checkpoint our state.
|
||||||
if err := h.Checkpoint(h); err != nil {
|
if err := h.Checkpoint(h); err != nil {
|
||||||
@ -538,6 +539,8 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
//
|
//
|
||||||
// TODO(roasbeef): validate first?
|
// TODO(roasbeef): validate first?
|
||||||
if err := h.PublishTx(h.sweepTx); err != nil {
|
if err := h.PublishTx(h.sweepTx); err != nil {
|
||||||
|
log.Infof("%T(%x): unable to publish tx: %v",
|
||||||
|
h, h.payHash[:], err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,6 +554,10 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("%T(%x): waiting for sweep tx (txid=%v) to be "+
|
||||||
|
"confirmed", h, h.payHash[:], sweepTXID)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case _, ok := <-confNtfn.Confirmed:
|
case _, ok := <-confNtfn.Confirmed:
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -561,9 +568,6 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
|
|||||||
return nil, fmt.Errorf("quitting")
|
return nil, fmt.Errorf("quitting")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("%T(%x): waiting for sweep tx (txid=%v) to be "+
|
|
||||||
"confirmed", h, h.payHash[:], sweepTXID)
|
|
||||||
|
|
||||||
// Once the transaction has received a sufficient number of
|
// Once the transaction has received a sufficient number of
|
||||||
// confirmations, we'll mark ourselves as fully resolved and exit.
|
// confirmations, we'll mark ourselves as fully resolved and exit.
|
||||||
h.resolved = true
|
h.resolved = true
|
||||||
|
@ -6233,7 +6233,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
|
|||||||
// With the block mined above, Bob should detect that Carol is
|
// With the block mined above, Bob should detect that Carol is
|
||||||
// attempting to sweep the HTLC on-chain, and should obtain the
|
// attempting to sweep the HTLC on-chain, and should obtain the
|
||||||
// preimage.
|
// preimage.
|
||||||
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
|
_, err = waitForNTxsInMempool(net.Miner.Node, 2, time.Second*15)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to find bob's sweeping transaction")
|
t.Fatalf("unable to find bob's sweeping transaction")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user