Merge pull request #1178 from Roasbeef/travis-htlc-block-race-fix
test: attempt to account for internal block race in htlc force close …
This commit is contained in:
commit
9017d18f14
32
lnd_test.go
32
lnd_test.go
@ -7066,9 +7066,22 @@ func testMultHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
|||||||
|
|
||||||
// Bob's sweeping transaction should now be found in the mempool at
|
// Bob's sweeping transaction should now be found in the mempool at
|
||||||
// this point.
|
// this point.
|
||||||
_, err = waitForTxInMempool(net.Miner.Node, time.Second*20)
|
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to find bob's sweeping transaction: %v", err)
|
// If Bob's transaction isn't yet in the mempool, then due to
|
||||||
|
// internal message passing and the low period between blocks
|
||||||
|
// being mined, it may have been detected as a late
|
||||||
|
// registration. As a result, we'll mine another block and
|
||||||
|
// repeat the check. If it doesn't go through this time, then
|
||||||
|
// we'll fail.
|
||||||
|
if _, err := net.Miner.Node.Generate(1); err != nil {
|
||||||
|
t.Fatalf("unable to generate block: %v", err)
|
||||||
|
}
|
||||||
|
_, err = waitForTxInMempool(net.Miner.Node, time.Second*10)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to find bob's sweeping "+
|
||||||
|
"transaction: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we mine an additional block, then this should confirm Bob's
|
// If we mine an additional block, then this should confirm Bob's
|
||||||
@ -7083,9 +7096,20 @@ func testMultHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
|
|||||||
nodes = []*lntest.HarnessNode{net.Alice}
|
nodes = []*lntest.HarnessNode{net.Alice}
|
||||||
err = lntest.WaitPredicate(func() bool {
|
err = lntest.WaitPredicate(func() bool {
|
||||||
return assertNumActiveHtlcs(nodes, 0)
|
return assertNumActiveHtlcs(nodes, 0)
|
||||||
}, time.Second*15)
|
}, time.Second*8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("alice's channel still has active htlc's")
|
// It may be the case that due to a race, Bob's sweeping
|
||||||
|
// transaction hasn't yet been confirmed, so we'll mine another
|
||||||
|
// block to nudge it in. If after this it still Alice will has
|
||||||
|
// an HTLC, then it's actually a test failure.
|
||||||
|
if _, err := net.Miner.Node.Generate(1); err != nil {
|
||||||
|
t.Fatalf("unable to generate block: %v", err)
|
||||||
|
}
|
||||||
|
if err = lntest.WaitPredicate(func() bool {
|
||||||
|
return assertNumActiveHtlcs(nodes, 0)
|
||||||
|
}, time.Second*8); err != nil {
|
||||||
|
t.Fatalf("alice's channel still has active htlc's")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we'll check Bob's pending channel report. Since this was Carol's
|
// Now we'll check Bob's pending channel report. Since this was Carol's
|
||||||
|
Loading…
Reference in New Issue
Block a user