lnd_test: assert existence of unconfirmed tx in mempool

This commit is contained in:
Johan T. Halseth 2018-11-29 12:31:40 +01:00
parent fc4fe07010
commit cdcb7105b3
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -851,6 +851,12 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to send coins to carol: %v", err)
}
// Make sure the unconfirmed tx is seen in the mempool.
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("failed to find tx in miner mempool: %v", err)
}
// Now, we'll connect her to Alice so that they can open a channel
// together. The funding flow should select Carol's unconfirmed output
// as she doesn't have any other funds since it's a new node.
@ -1574,6 +1580,12 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to open channel: %v", err)
}
// Wait for miner to have seen the funding tx.
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("failed to find funding tx in mempool: %v", err)
}
// At this point, the channel's funding transaction will have been
// broadcast, but not confirmed, and the channel should be pending.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -2346,6 +2358,11 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
// Mine a block which should confirm the commitment transaction
// broadcast as a result of the force closure.
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("failed to find commitment in miner mempool: %v", err)
}
if _, err := net.Miner.Node.Generate(1); err != nil {
t.Fatalf("unable to generate block: %v", err)
}
@ -2411,6 +2428,14 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("Node restart failed: %v", err)
}
// Carol's sweep tx should be in the mempool already, as her output is
// not timelocked.
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("failed to find Carol's sweep in miner mempool: %v",
err)
}
// Currently within the codebase, the default CSV is 4 relative blocks.
// For the persistence test, we generate three blocks, then trigger
// a restart and then generate the final block that should trigger
@ -9652,6 +9677,13 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
bobForceClose := closeChannelAndAssert(ctxt, t, net, net.Bob,
aliceChanPoint, true)
// Alice will sweep her output immediately.
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("unable to find alice's sweep tx in miner mempool: %v",
err)
}
// We'll now mine enough blocks so Carol decides that she needs to go
// on-chain to claim the HTLC as Bob has been inactive.
numBlocks := uint32(defaultBitcoinTimeLockDelta - (2 * defaultBroadcastDelta))