test: attempt to account for internal block race in htlc force close test
In this commit, we modify the testMultHopRemoteForceCloseOnChainHtlcTimeout test slightly to attempt to account for a block race between the arrival of a message betwen the contract resolver and the utxo nursery. If this message arrives "late" (relative to the speed with which we mine blocks in test), then it'll be detected as such by the utxo nursery. However, since we attempt to mine a precise number of blocks, if this happens, then we'll never actually mine that extra block to trigger a broadcast of the sweep transaction.
This commit is contained in:
parent
ddd12eff9c
commit
1e7f2c32e9
17
lnd_test.go
17
lnd_test.go
@ -7049,9 +7049,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
|
||||||
|
Loading…
Reference in New Issue
Block a user