Skip to content

Commit

Permalink
itest: enable anchor commitment for multi-hop test
Browse files Browse the repository at this point in the history
These tests exercise the different ways of sweeping a commitment, so
we'll cover the modified scripts used for anchor commitments.

The only change we need for the tests to pass is to not assert exactly
which output is being swept, since this index depends on whether the
anchors are there or not.
  • Loading branch information
halseth committed Mar 19, 2020
1 parent d142a3d commit d8e0324
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions lntest/itest/lnd_multi-hop_htlc_local_chain_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
allTypes := []commitType{
commitTypeLegacy,
commitTypeTweakless,
commitTypeAnchors,
}

for _, commitType := range allTypes {
Expand Down
21 changes: 15 additions & 6 deletions lntest/itest/lnd_multi-hop_htlc_local_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,21 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest,
// We'll mine the remaining blocks in order to generate the sweep
// transaction of Bob's commitment output.
mineBlocks(t, net, defaultCSV, 1)
assertSpendingTxInMempool(
t, net.Miner.Node, minerMempoolTimeout, wire.OutPoint{
Hash: *closeTxid,
Index: 1,
},
)

// Check that the sweep spends from the mined commitment.
sweepHash, err := waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
if err != nil {
t.Fatalf("unable to find bob's sweep tx: %v", err)
}
sweepTx, err := net.Miner.Node.GetRawTransaction(sweepHash)
if err != nil {
t.Fatalf("unable to get txn: %v", err)
}
// Since we cannot know for sure which index is swept, check only txid.
if sweepTx.MsgTx().TxIn[0].PreviousOutPoint.Hash != *closeTxid {
t.Fatalf("sweep transaction not spending close tx: %v",
spew.Sdump(sweepTx))
}

// Bob's pending channel report should show that he has a commitment
// output awaiting sweeping, and also that there's an outgoing HTLC
Expand Down

0 comments on commit d8e0324

Please sign in to comment.