From 04a15039d79ee13fdd7060a6d73bd9c069070338 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 8 Nov 2024 22:30:57 +0800 Subject: [PATCH] itest: break all multihop test cases --- itest/lnd_multi-hop_force_close_test.go | 1512 +++++++++++------------ 1 file changed, 730 insertions(+), 782 deletions(-) diff --git a/itest/lnd_multi-hop_force_close_test.go b/itest/lnd_multi-hop_force_close_test.go index f35ad8f47..dc18792ea 100644 --- a/itest/lnd_multi-hop_force_close_test.go +++ b/itest/lnd_multi-hop_force_close_test.go @@ -1,8 +1,6 @@ package itest import ( - "testing" - "github.com/btcsuite/btcd/btcutil" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" @@ -34,130 +32,207 @@ var multiHopForceCloseTestCases = []*lntest.TestCase{ Name: "multihop local claim outgoing htlc anchor", TestFunc: testLocalClaimOutgoingHTLCAnchor, }, + { + Name: "multihop local claim outgoing htlc anchor zero conf", + TestFunc: testLocalClaimOutgoingHTLCAnchorZeroConf, + }, { Name: "multihop local claim outgoing htlc simple taproot", TestFunc: testLocalClaimOutgoingHTLCSimpleTaproot, }, + { + Name: "multihop local claim outgoing htlc simple taproot zero conf", + TestFunc: testLocalClaimOutgoingHTLCSimpleTaprootZeroConf, + }, { Name: "multihop local claim outgoing htlc leased", TestFunc: testLocalClaimOutgoingHTLCLeased, }, + { + Name: "multihop local claim outgoing htlc leased zero conf", + TestFunc: testLocalClaimOutgoingHTLCLeasedZeroConf, + }, { Name: "multihop receiver preimage claim anchor", TestFunc: testMultiHopReceiverPreimageClaimAnchor, }, + { + Name: "multihop receiver preimage claim anchor zero conf", + TestFunc: testMultiHopReceiverPreimageClaimAnchorZeroConf, + }, { Name: "multihop receiver preimage claim simple taproot", TestFunc: testMultiHopReceiverPreimageClaimSimpleTaproot, }, + { + Name: "multihop receiver preimage claim simple taproot zero conf", + TestFunc: testMultiHopReceiverPreimageClaimSimpleTaprootZeroConf, + }, { Name: "multihop receiver preimage claim leased", TestFunc: testMultiHopReceiverPreimageClaimLeased, }, + { + Name: "multihop receiver preimage claim leased zero conf", + TestFunc: testMultiHopReceiverPreimageClaimLeasedZeroConf, + }, { Name: "multihop local force close before timeout anchor", TestFunc: testLocalForceCloseBeforeTimeoutAnchor, }, + { + Name: "multihop local force close before timeout anchor zero conf", + TestFunc: testLocalForceCloseBeforeTimeoutAnchorZeroConf, + }, { Name: "multihop local force close before timeout simple taproot", TestFunc: testLocalForceCloseBeforeTimeoutSimpleTaproot, }, + { + Name: "multihop local force close before timeout simple taproot zero conf", + TestFunc: testLocalForceCloseBeforeTimeoutSimpleTaprootZeroConf, + }, { Name: "multihop local force close before timeout leased", TestFunc: testLocalForceCloseBeforeTimeoutLeased, }, + { + Name: "multihop local force close before timeout leased zero conf", + TestFunc: testLocalForceCloseBeforeTimeoutLeasedZeroConf, + }, { Name: "multihop remote force close before timeout anchor", TestFunc: testRemoteForceCloseBeforeTimeoutAnchor, }, + { + Name: "multihop remote force close before timeout anchor zero conf", + TestFunc: testRemoteForceCloseBeforeTimeoutAnchorZeroConf, + }, { Name: "multihop remote force close before timeout simple taproot", TestFunc: testRemoteForceCloseBeforeTimeoutSimpleTaproot, }, + { + Name: "multihop remote force close before timeout simple taproot zero conf", + TestFunc: testRemoteForceCloseBeforeTimeoutSimpleTaprootZeroConf, + }, { Name: "multihop remote force close before timeout leased", TestFunc: testRemoteForceCloseBeforeTimeoutLeased, }, + { + Name: "multihop remote force close before timeout leased zero conf", + TestFunc: testRemoteForceCloseBeforeTimeoutLeasedZeroConf, + }, { Name: "multihop local claim incoming htlc anchor", TestFunc: testLocalClaimIncomingHTLCAnchor, }, + { + Name: "multihop local claim incoming htlc anchor zero conf", + TestFunc: testLocalClaimIncomingHTLCAnchorZeroConf, + }, { Name: "multihop local claim incoming htlc simple taproot", TestFunc: testLocalClaimIncomingHTLCSimpleTaproot, }, + { + Name: "multihop local claim incoming htlc simple taproot zero conf", + TestFunc: testLocalClaimIncomingHTLCSimpleTaprootZeroConf, + }, { Name: "multihop local claim incoming htlc leased", TestFunc: testLocalClaimIncomingHTLCLeased, }, + { + Name: "multihop local claim incoming htlc leased zero conf", + TestFunc: testLocalClaimIncomingHTLCLeasedZeroConf, + }, { Name: "multihop local preimage claim anchor", TestFunc: testLocalPreimageClaimAnchor, }, + { + Name: "multihop local preimage claim anchor zero conf", + TestFunc: testLocalPreimageClaimAnchorZeroConf, + }, { Name: "multihop local preimage claim simple taproot", TestFunc: testLocalPreimageClaimSimpleTaproot, }, + { + Name: "multihop local preimage claim simple taproot zero conf", + TestFunc: testLocalPreimageClaimSimpleTaprootZeroConf, + }, { Name: "multihop local preimage claim leased", TestFunc: testLocalPreimageClaimLeased, }, + { + Name: "multihop local preimage claim leased zero conf", + TestFunc: testLocalPreimageClaimLeasedZeroConf, + }, { Name: "multihop htlc aggregation anchor", TestFunc: testHtlcAggregaitonAnchor, }, + { + Name: "multihop htlc aggregation anchor zero conf", + TestFunc: testHtlcAggregaitonAnchorZeroConf, + }, { Name: "multihop htlc aggregation simple taproot", TestFunc: testHtlcAggregaitonSimpleTaproot, }, + { + Name: "multihop htlc aggregation simple taproot zero conf", + TestFunc: testHtlcAggregaitonSimpleTaprootZeroConf, + }, { Name: "multihop htlc aggregation leased", TestFunc: testHtlcAggregaitonLeased, }, + { + Name: "multihop htlc aggregation leased zero conf", + TestFunc: testHtlcAggregaitonLeasedZeroConf, + }, } // testLocalClaimOutgoingHTLCAnchor tests `runLocalClaimOutgoingHTLC` with // anchor channel. func testLocalClaimOutgoingHTLCAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - cfg := node.CfgAnchor - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) +} - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) - if !success { - return +// testLocalClaimOutgoingHTLCAnchorZeroConf tests `runLocalClaimOutgoingHTLC` +// with zero conf anchor channel. +func testLocalClaimOutgoingHTLCAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } - - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) } // testLocalClaimOutgoingHTLCSimpleTaproot tests `runLocalClaimOutgoingHTLC` @@ -165,101 +240,87 @@ func testLocalClaimOutgoingHTLCAnchor(ht *lntest.HarnessTest) { func testLocalClaimOutgoingHTLCSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testLocalClaimOutgoingHTLCSimpleTaprootZeroConf tests +// `runLocalClaimOutgoingHTLC` with zero-conf simple taproot channel. +func testLocalClaimOutgoingHTLCSimpleTaprootZeroConf(ht *lntest.HarnessTest) { + c := lnrpc.CommitmentType_SIMPLE_TAPROOT - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) } // testLocalClaimOutgoingHTLCLeased tests `runLocalClaimOutgoingHTLC` with // script enforced lease channel. func testLocalClaimOutgoingHTLCLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testLocalClaimOutgoingHTLCLeasedZeroConf tests `runLocalClaimOutgoingHTLC` +// with zero-conf script enforced lease channel. +func testLocalClaimOutgoingHTLCLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } - runLocalClaimOutgoingHTLC(st, cfgs, openChannelParams) - }) + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runLocalClaimOutgoingHTLC(ht, cfgs, openChannelParams) } // runLocalClaimOutgoingHTLC tests that in a multi-hop scenario, if the @@ -476,43 +537,36 @@ func runLocalClaimOutgoingHTLC(ht *lntest.HarnessTest, // testMultiHopReceiverPreimageClaimAnchor tests // `runMultiHopReceiverPreimageClaim` with anchor channels. func testMultiHopReceiverPreimageClaimAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgs := [][]string{cfg, cfg, cfg} - cfg := node.CfgAnchor - cfgs := [][]string{cfg, cfg, cfg} + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) +} - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) - if !success { - return +// testMultiHopReceiverPreimageClaimAnchorZeroConf tests +// `runMultiHopReceiverPreimageClaim` with zero-conf anchor channels. +func testMultiHopReceiverPreimageClaimAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } - - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgs := [][]string{cfg, cfg, cfg} - - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) } // testMultiHopReceiverPreimageClaimSimpleTaproot tests @@ -520,97 +574,88 @@ func testMultiHopReceiverPreimageClaimAnchor(ht *lntest.HarnessTest) { func testMultiHopReceiverPreimageClaimSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgs := [][]string{cfg, cfg, cfg} - - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} +// testMultiHopReceiverPreimageClaimSimpleTaproot tests +// `runMultiHopReceiverPreimageClaim` with zero-conf simple taproot channels. +func testMultiHopReceiverPreimageClaimSimpleTaprootZeroConf( + ht *lntest.HarnessTest) { - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, + } + + // Prepare Carol's node config to enable zero-conf and leased + // channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) } // testMultiHopReceiverPreimageClaimLeased tests // `runMultiHopReceiverPreimageClaim` with script enforce lease channels. func testMultiHopReceiverPreimageClaimLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgs := [][]string{cfg, cfg, cfg} - - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - openChannelParams := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} +// testMultiHopReceiverPreimageClaimLeased tests +// `runMultiHopReceiverPreimageClaim` with zero-conf script enforce lease +// channels. +func testMultiHopReceiverPreimageClaimLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + openChannelParams := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } - runMultiHopReceiverPreimageClaim(st, cfgs, openChannelParams) - }) + // Prepare Carol's node config to enable zero-conf and leased + // channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runMultiHopReceiverPreimageClaim(ht, cfgs, openChannelParams) } // runMultiHopReceiverClaim tests that in the multi-hop setting, if the @@ -878,45 +923,38 @@ func runMultiHopReceiverPreimageClaim(ht *lntest.HarnessTest, // testLocalForceCloseBeforeTimeoutAnchor tests // `runLocalForceCloseBeforeHtlcTimeout` with anchor channel. func testLocalForceCloseBeforeTimeoutAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - cfg := node.CfgAnchor - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return +// testLocalForceCloseBeforeTimeoutAnchorZeroConf tests +// `runLocalForceCloseBeforeHtlcTimeout` with zero-conf anchor channel. +func testLocalForceCloseBeforeTimeoutAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } - - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // testLocalForceCloseBeforeTimeoutSimpleTaproot tests @@ -924,101 +962,90 @@ func testLocalForceCloseBeforeTimeoutAnchor(ht *lntest.HarnessTest) { func testLocalForceCloseBeforeTimeoutSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testLocalForceCloseBeforeTimeoutSimpleTaproot tests +// `runLocalForceCloseBeforeHtlcTimeout` with zero-conf simple taproot channel. +func testLocalForceCloseBeforeTimeoutSimpleTaprootZeroConf( + ht *lntest.HarnessTest) { - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // testLocalForceCloseBeforeTimeoutLeased tests // `runLocalForceCloseBeforeHtlcTimeout` with script enforced lease channel. func testLocalForceCloseBeforeTimeoutLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testLocalForceCloseBeforeTimeoutLeased tests +// `runLocalForceCloseBeforeHtlcTimeout` with zero-conf script enforced lease +// channel. +func testLocalForceCloseBeforeTimeoutLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } - runLocalForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runLocalForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // runLocalForceCloseBeforeHtlcTimeout tests that in a multi-hop HTLC scenario, @@ -1210,45 +1237,65 @@ func runLocalForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest, // testRemoteForceCloseBeforeTimeoutAnchor tests // `runRemoteForceCloseBeforeHtlcTimeout` with anchor channel. func testRemoteForceCloseBeforeTimeoutAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - cfg := node.CfgAnchor - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return +// testRemoteForceCloseBeforeTimeoutAnchor tests +// `runRemoteForceCloseBeforeHtlcTimeout` with zero-conf anchor channel. +func testRemoteForceCloseBeforeTimeoutAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testRemoteForceCloseBeforeTimeoutSimpleTaproot tests +// `runLocalForceCloseBeforeHtlcTimeout` with zero-conf simple taproot channel. +func testRemoteForceCloseBeforeTimeoutSimpleTaprootZeroConf( + ht *lntest.HarnessTest) { - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // testRemoteForceCloseBeforeTimeoutSimpleTaproot tests @@ -1256,101 +1303,64 @@ func testRemoteForceCloseBeforeTimeoutAnchor(ht *lntest.HarnessTest) { func testRemoteForceCloseBeforeTimeoutSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} +// testRemoteForceCloseBeforeTimeoutLeasedZeroConf tests +// `runRemoteForceCloseBeforeHtlcTimeout` with zero-conf script enforced lease +// channel. +func testRemoteForceCloseBeforeTimeoutLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + // Prepare Carol's node config to enable zero-conf and leased + // channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} + + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // testRemoteForceCloseBeforeTimeoutLeased tests // `runRemoteForceCloseBeforeHtlcTimeout` with script enforced lease channel. func testRemoteForceCloseBeforeTimeoutLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) + cfgs := [][]string{cfg, cfg, cfgCarol} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgCarol := append([]string{"--hodl.exit-settle"}, cfg...) - cfgs := [][]string{cfg, cfg, cfgCarol} - - runRemoteForceCloseBeforeHtlcTimeout(st, cfgs, params) - }) + runRemoteForceCloseBeforeHtlcTimeout(ht, cfgs, params) } // runRemoteForceCloseBeforeHtlcTimeout tests that if we extend a multi-hop @@ -1521,46 +1531,63 @@ func runRemoteForceCloseBeforeHtlcTimeout(ht *lntest.HarnessTest, ht.AssertInvoiceState(stream, lnrpc.Invoice_CANCELED) } +// testLocalClaimIncomingHTLCAnchorZeroConf tests `runLocalClaimIncomingHTLC` +// with zero-conf anchor channel. +func testLocalClaimIncomingHTLCAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, + } + + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgs := [][]string{cfg, cfg, cfg} + + runLocalClaimIncomingHTLC(ht, cfgs, params) +} + // testLocalClaimIncomingHTLCAnchor tests `runLocalClaimIncomingHTLC` with // anchor channel. func testLocalClaimIncomingHTLCAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgs := [][]string{cfg, cfg, cfg} - cfg := node.CfgAnchor - cfgs := [][]string{cfg, cfg, cfg} + runLocalClaimIncomingHTLC(ht, cfgs, params) +} - runLocalClaimIncomingHTLC(st, cfgs, params) - }) - if !success { - return +// testLocalClaimIncomingHTLCSimpleTaprootZeroConf tests +// `runLocalClaimIncomingHTLC` with zero-conf simple taproot channel. +func testLocalClaimIncomingHTLCSimpleTaprootZeroConf(ht *lntest.HarnessTest) { + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } - - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgs := [][]string{cfg, cfg, cfg} - - runLocalClaimIncomingHTLC(st, cfgs, params) - }) + runLocalClaimIncomingHTLC(ht, cfgs, params) } // testLocalClaimIncomingHTLCSimpleTaproot tests `runLocalClaimIncomingHTLC` @@ -1568,50 +1595,20 @@ func testLocalClaimIncomingHTLCAnchor(ht *lntest.HarnessTest) { func testLocalClaimIncomingHTLCSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgs := [][]string{cfg, cfg, cfg} - - runLocalClaimIncomingHTLC(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} - - runLocalClaimIncomingHTLC(st, cfgs, params) - }) + runLocalClaimIncomingHTLC(ht, cfgs, params) } // runLocalClaimIncomingHTLC tests that in a multi-hop HTLC scenario, if we @@ -1885,51 +1882,44 @@ func runLocalClaimIncomingHTLC(ht *lntest.HarnessTest, ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED) } +// testLocalClaimIncomingHTLCLeasedZeroConf tests +// `runLocalClaimIncomingHTLCLeased` with zero-conf script enforced lease +// channel. +func testLocalClaimIncomingHTLCLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runLocalClaimIncomingHTLCLeased(ht, cfgs, params) +} + // testLocalClaimIncomingHTLCLeased tests `runLocalClaimIncomingHTLCLeased` // with script enforced lease channel. func testLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgs := [][]string{cfg, cfg, cfg} - - runLocalClaimIncomingHTLCLeased(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} - - runLocalClaimIncomingHTLCLeased(st, cfgs, params) - }) + runLocalClaimIncomingHTLCLeased(ht, cfgs, params) } // runLocalClaimIncomingHTLCLeased tests that in a multi-hop HTLC scenario, if @@ -2196,46 +2186,63 @@ func runLocalClaimIncomingHTLCLeased(ht *lntest.HarnessTest, ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED) } +// testLocalPreimageClaimAnchorZeroConf tests `runLocalPreimageClaim` with +// zero-conf anchor channel. +func testLocalPreimageClaimAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, + } + + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgs := [][]string{cfg, cfg, cfg} + + runLocalPreimageClaim(ht, cfgs, params) +} + // testLocalPreimageClaimAnchor tests `runLocalPreimageClaim` with anchor // channel. func testLocalPreimageClaimAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{Amt: chanAmt} - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{Amt: chanAmt} + cfg := node.CfgAnchor + cfgs := [][]string{cfg, cfg, cfg} - cfg := node.CfgAnchor - cfgs := [][]string{cfg, cfg, cfg} + runLocalPreimageClaim(ht, cfgs, params) +} - runLocalPreimageClaim(st, cfgs, params) - }) - if !success { - return +// testLocalPreimageClaimSimpleTaprootZeroConf tests +// `runLocalClaimIncomingHTLC` with zero-conf simple taproot channel. +func testLocalPreimageClaimSimpleTaprootZeroConf(ht *lntest.HarnessTest) { + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } - - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgs := [][]string{cfg, cfg, cfg} - - runLocalPreimageClaim(st, cfgs, params) - }) + runLocalPreimageClaim(ht, cfgs, params) } // testLocalPreimageClaimSimpleTaproot tests `runLocalClaimIncomingHTLC` with @@ -2243,50 +2250,20 @@ func testLocalPreimageClaimAnchor(ht *lntest.HarnessTest) { func testLocalPreimageClaimSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgs := [][]string{cfg, cfg, cfg} - - runLocalPreimageClaim(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} - - runLocalPreimageClaim(st, cfgs, params) - }) + runLocalPreimageClaim(ht, cfgs, params) } // runLocalPreimageClaim tests that in the multi-hop HTLC scenario, if the @@ -2564,51 +2541,43 @@ func runLocalPreimageClaim(ht *lntest.HarnessTest, ht.AssertPaymentStatus(alice, preimage, lnrpc.Payment_SUCCEEDED) } +// testLocalPreimageClaimLeasedZeroConf tests `runLocalPreimageClaim` with +// zero-conf script enforced lease channel. +func testLocalPreimageClaimLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runLocalPreimageClaimLeased(ht, cfgs, params) +} + // testLocalPreimageClaimLeased tests `runLocalPreimageClaim` with script // enforced lease channel. func testLocalPreimageClaimLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgs := [][]string{cfg, cfg, cfg} - - runLocalPreimageClaimLeased(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} - - runLocalPreimageClaimLeased(st, cfgs, params) - }) + runLocalPreimageClaimLeased(ht, cfgs, params) } // runLocalPreimageClaimLeased tests that in the multi-hop HTLC scenario, if @@ -2862,45 +2831,62 @@ func runLocalPreimageClaimLeased(ht *lntest.HarnessTest, ht.AssertNumPendingForceClose(bob, 0) } -// testHtlcAggregaitonAnchor tests `runHtlcAggregation` with anchor channel. -func testHtlcAggregaitonAnchor(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{Amt: chanAmt} - - cfg := node.CfgAnchor - cfgs := [][]string{cfg, cfg, cfg} - - runHtlcAggregation(st, cfgs, params) - }) - if !success { - return +// testHtlcAggregaitonAnchor tests `runHtlcAggregation` with zero-conf anchor +// channel. +func testHtlcAggregaitonAnchorZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: lnrpc.CommitmentType_ANCHORS, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + // Prepare Carol's node config to enable zero-conf and anchor. + cfg := node.CfgZeroConf + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: lnrpc.CommitmentType_ANCHORS, - } + runHtlcAggregation(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and anchor. - cfg := node.CfgZeroConf - cfgs := [][]string{cfg, cfg, cfg} +// testHtlcAggregaitonAnchor tests `runHtlcAggregation` with anchor channel. +func testHtlcAggregaitonAnchor(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using anchor + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{Amt: chanAmt} - runHtlcAggregation(st, cfgs, params) - }) + cfg := node.CfgAnchor + cfgs := [][]string{cfg, cfg, cfg} + + runHtlcAggregation(ht, cfgs, params) +} + +// testHtlcAggregaitonSimpleTaprootZeroConf tests `runHtlcAggregation` with +// zero-conf simple taproot channel. +func testHtlcAggregaitonSimpleTaprootZeroConf(ht *lntest.HarnessTest) { + c := lnrpc.CommitmentType_SIMPLE_TAPROOT + + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // simple taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: c, + Private: true, + } + + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgSimpleTaproot + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runHtlcAggregation(ht, cfgs, params) } // testHtlcAggregaitonSimpleTaproot tests `runHtlcAggregation` with simple @@ -2908,97 +2894,59 @@ func testHtlcAggregaitonAnchor(ht *lntest.HarnessTest) { func testHtlcAggregaitonSimpleTaproot(ht *lntest.HarnessTest) { c := lnrpc.CommitmentType_SIMPLE_TAPROOT - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: c, - Private: true, - } - - cfg := node.CfgSimpleTaproot - cfgs := [][]string{cfg, cfg, cfg} - - runHtlcAggregation(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using simple + // taproot channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: c, + Private: true, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgSimpleTaproot + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf simple taproot channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: c, - Private: true, - } + runHtlcAggregation(ht, cfgs, params) +} - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgSimpleTaproot - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} +// testHtlcAggregaitonLeasedZeroConf tests `runHtlcAggregation` with zero-conf +// script enforced lease channel. +func testHtlcAggregaitonLeasedZeroConf(ht *lntest.HarnessTest) { + // Create a three hop network: Alice -> Bob -> Carol, using zero-conf + // anchor channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + ZeroConf: true, + CommitmentType: leasedType, + } - runHtlcAggregation(st, cfgs, params) - }) + // Prepare Carol's node config to enable zero-conf and leased channel. + cfg := node.CfgLeased + cfg = append(cfg, node.CfgZeroConf...) + cfgs := [][]string{cfg, cfg, cfg} + + runHtlcAggregation(ht, cfgs, params) } // testHtlcAggregaitonLeased tests `runHtlcAggregation` with script enforced // lease channel. func testHtlcAggregaitonLeased(ht *lntest.HarnessTest) { - success := ht.Run("no zero conf", func(t *testing.T) { - st := ht.Subtest(t) - - // Create a three hop network: Alice -> Bob -> Carol, using - // leased channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - CommitmentType: leasedType, - } - - cfg := node.CfgLeased - cfgs := [][]string{cfg, cfg, cfg} - - runHtlcAggregation(st, cfgs, params) - }) - if !success { - return + // Create a three hop network: Alice -> Bob -> Carol, using leased + // channels. + // + // Prepare params. + params := lntest.OpenChannelParams{ + Amt: chanAmt, + CommitmentType: leasedType, } - ht.Run("zero conf", func(t *testing.T) { - st := ht.Subtest(t) + cfg := node.CfgLeased + cfgs := [][]string{cfg, cfg, cfg} - // Create a three hop network: Alice -> Bob -> Carol, using - // zero-conf anchor channels. - // - // Prepare params. - params := lntest.OpenChannelParams{ - Amt: chanAmt, - ZeroConf: true, - CommitmentType: leasedType, - } - - // Prepare Carol's node config to enable zero-conf and leased - // channel. - cfg := node.CfgLeased - cfg = append(cfg, node.CfgZeroConf...) - cfgs := [][]string{cfg, cfg, cfg} - - runHtlcAggregation(st, cfgs, params) - }) + runHtlcAggregation(ht, cfgs, params) } // runHtlcAggregation tests that in a multi-hop HTLC scenario, if we force