mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 23:37:33 +02:00
itest: add taproot tower itest
This commit is contained in:
@@ -715,30 +715,24 @@ func testRevokedCloseRetributionRemoteHodl(ht *lntest.HarnessTest) {
|
|||||||
// asserts that Willy responds by broadcasting the justice transaction on
|
// asserts that Willy responds by broadcasting the justice transaction on
|
||||||
// Carol's behalf sweeping her funds without a reward.
|
// Carol's behalf sweeping her funds without a reward.
|
||||||
func testRevokedCloseRetributionAltruistWatchtower(ht *lntest.HarnessTest) {
|
func testRevokedCloseRetributionAltruistWatchtower(ht *lntest.HarnessTest) {
|
||||||
testCases := []struct {
|
for _, commitType := range []lnrpc.CommitmentType{
|
||||||
name string
|
lnrpc.CommitmentType_LEGACY,
|
||||||
anchors bool
|
lnrpc.CommitmentType_ANCHORS,
|
||||||
}{{
|
lnrpc.CommitmentType_SIMPLE_TAPROOT,
|
||||||
name: "anchors",
|
} {
|
||||||
anchors: true,
|
testName := fmt.Sprintf("%v", commitType.String())
|
||||||
}, {
|
ct := commitType
|
||||||
name: "legacy",
|
|
||||||
anchors: false,
|
|
||||||
}}
|
|
||||||
|
|
||||||
for _, tc := range testCases {
|
|
||||||
tc := tc
|
|
||||||
testFunc := func(ht *lntest.HarnessTest) {
|
testFunc := func(ht *lntest.HarnessTest) {
|
||||||
testRevokedCloseRetributionAltruistWatchtowerCase(
|
testRevokedCloseRetributionAltruistWatchtowerCase(
|
||||||
ht, tc.anchors,
|
ht, ct,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
success := ht.Run(tc.name, func(tt *testing.T) {
|
success := ht.Run(testName, func(tt *testing.T) {
|
||||||
st := ht.Subtest(tt)
|
st := ht.Subtest(tt)
|
||||||
|
|
||||||
st.RunTestCase(&lntest.TestCase{
|
st.RunTestCase(&lntest.TestCase{
|
||||||
Name: tc.name,
|
Name: testName,
|
||||||
TestFunc: testFunc,
|
TestFunc: testFunc,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -756,7 +750,7 @@ func testRevokedCloseRetributionAltruistWatchtower(ht *lntest.HarnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
||||||
anchors bool) {
|
commitType lnrpc.CommitmentType) {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
chanAmt = funding.MaxBtcFundingAmount
|
chanAmt = funding.MaxBtcFundingAmount
|
||||||
@@ -767,18 +761,19 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
|||||||
|
|
||||||
// Since we'd like to test some multi-hop failure scenarios, we'll
|
// Since we'd like to test some multi-hop failure scenarios, we'll
|
||||||
// introduce another node into our test network: Carol.
|
// introduce another node into our test network: Carol.
|
||||||
carolArgs := []string{"--hodl.exit-settle"}
|
carolArgs := lntest.NodeArgsForCommitType(commitType)
|
||||||
if anchors {
|
carolArgs = append(carolArgs, "--hodl.exit-settle")
|
||||||
carolArgs = append(carolArgs, "--protocol.anchors")
|
|
||||||
}
|
|
||||||
carol := ht.NewNode("Carol", carolArgs)
|
carol := ht.NewNode("Carol", carolArgs)
|
||||||
|
|
||||||
// Willy the watchtower will protect Dave from Carol's breach. He will
|
// Willy the watchtower will protect Dave from Carol's breach. He will
|
||||||
// remain online in order to punish Carol on Dave's behalf, since the
|
// remain online in order to punish Carol on Dave's behalf, since the
|
||||||
// breach will happen while Dave is offline.
|
// breach will happen while Dave is offline.
|
||||||
willy := ht.NewNode(
|
willy := ht.NewNode(
|
||||||
"Willy", []string{"--watchtower.active",
|
"Willy", []string{
|
||||||
"--watchtower.externalip=" + externalIP},
|
"--watchtower.active",
|
||||||
|
"--watchtower.externalip=" + externalIP,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
willyInfo := willy.RPC.GetInfoWatchtower()
|
willyInfo := willy.RPC.GetInfoWatchtower()
|
||||||
@@ -801,13 +796,8 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
|||||||
// Dave will be the breached party. We set --nolisten to ensure Carol
|
// Dave will be the breached party. We set --nolisten to ensure Carol
|
||||||
// won't be able to connect to him and trigger the channel data
|
// won't be able to connect to him and trigger the channel data
|
||||||
// protection logic automatically.
|
// protection logic automatically.
|
||||||
daveArgs := []string{
|
daveArgs := lntest.NodeArgsForCommitType(commitType)
|
||||||
"--nolisten",
|
daveArgs = append(daveArgs, "--nolisten", "--wtclient.active")
|
||||||
"--wtclient.active",
|
|
||||||
}
|
|
||||||
if anchors {
|
|
||||||
daveArgs = append(daveArgs, "--protocol.anchors")
|
|
||||||
}
|
|
||||||
dave := ht.NewNode("Dave", daveArgs)
|
dave := ht.NewNode("Dave", daveArgs)
|
||||||
|
|
||||||
addTowerReq := &wtclientrpc.AddTowerRequest{
|
addTowerReq := &wtclientrpc.AddTowerRequest{
|
||||||
@@ -833,8 +823,10 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
|||||||
// closure by Carol, we'll first open up a channel between them with a
|
// closure by Carol, we'll first open up a channel between them with a
|
||||||
// 0.5 BTC value.
|
// 0.5 BTC value.
|
||||||
params := lntest.OpenChannelParams{
|
params := lntest.OpenChannelParams{
|
||||||
Amt: 3 * (chanAmt / 4),
|
Amt: 3 * (chanAmt / 4),
|
||||||
PushAmt: chanAmt / 4,
|
PushAmt: chanAmt / 4,
|
||||||
|
CommitmentType: commitType,
|
||||||
|
Private: true,
|
||||||
}
|
}
|
||||||
chanPoint := ht.OpenChannel(dave, carol, params)
|
chanPoint := ht.OpenChannel(dave, carol, params)
|
||||||
|
|
||||||
@@ -956,7 +948,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
|||||||
willyBalResp := willy.RPC.WalletBalance()
|
willyBalResp := willy.RPC.WalletBalance()
|
||||||
|
|
||||||
if willyBalResp.ConfirmedBalance != 0 {
|
if willyBalResp.ConfirmedBalance != 0 {
|
||||||
return fmt.Errorf("Expected Willy to have no funds "+
|
return fmt.Errorf("expected Willy to have no funds "+
|
||||||
"after justice transaction was mined, found %v",
|
"after justice transaction was mined, found %v",
|
||||||
willyBalResp)
|
willyBalResp)
|
||||||
}
|
}
|
||||||
@@ -994,7 +986,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
|
|||||||
ht.AssertNumPendingForceClose(dave, 0)
|
ht.AssertNumPendingForceClose(dave, 0)
|
||||||
|
|
||||||
// If this is an anchor channel, Dave would sweep the anchor.
|
// If this is an anchor channel, Dave would sweep the anchor.
|
||||||
if anchors {
|
if lntest.CommitTypeHasAnchors(commitType) {
|
||||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user