mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
itest: use explicit chan type negotiation for taproot chan cases
The prior commit removed implicit negotiation, so we'll need to make sure to use the explicit chan type feature vector when we go to negotiate.
This commit is contained in:
parent
384b1b1c12
commit
94f45b2b82
4 changed files with 64 additions and 19 deletions
|
@ -279,9 +279,10 @@ func channelForceClosureTest(ht *lntest.HarnessTest,
|
||||||
|
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, carol, lntest.OpenChannelParams{
|
alice, carol, lntest.OpenChannelParams{
|
||||||
Private: privateChan,
|
Private: privateChan,
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
|
CommitmentType: channelType,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,6 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
|
||||||
lnrpc.CommitmentType_SIMPLE_TAPROOT,
|
lnrpc.CommitmentType_SIMPLE_TAPROOT,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): only testing implicit negotiation not also explicit?
|
|
||||||
|
|
||||||
// testFunding is a function closure that takes Carol and Dave's
|
// testFunding is a function closure that takes Carol and Dave's
|
||||||
// commitment types and test the funding flow.
|
// commitment types and test the funding flow.
|
||||||
testFunding := func(ht *lntest.HarnessTest, carolCommitType,
|
testFunding := func(ht *lntest.HarnessTest, carolCommitType,
|
||||||
|
@ -71,8 +69,28 @@ func testBasicChannelFunding(ht *lntest.HarnessTest) {
|
||||||
privateChan = true
|
privateChan = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If carol wants taproot, but dave wants something
|
||||||
|
// else, then we'll assert that the channel negotiation
|
||||||
|
// attempt fails.
|
||||||
|
if carolCommitType == lnrpc.CommitmentType_SIMPLE_TAPROOT &&
|
||||||
|
daveCommitType != lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
||||||
|
|
||||||
|
expectedErr := fmt.Errorf("requested channel type " +
|
||||||
|
"not supported")
|
||||||
|
amt := funding.MaxBtcFundingAmount
|
||||||
|
ht.OpenChannelAssertErr(
|
||||||
|
carol, dave, lntest.OpenChannelParams{
|
||||||
|
Private: privateChan,
|
||||||
|
Amt: amt,
|
||||||
|
CommitmentType: carolCommitType,
|
||||||
|
}, expectedErr,
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
carolChan, daveChan, closeChan := basicChannelFundingTest(
|
carolChan, daveChan, closeChan := basicChannelFundingTest(
|
||||||
ht, carol, dave, nil, privateChan,
|
ht, carol, dave, nil, privateChan, &carolCommitType,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Both nodes should report the same commitment
|
// Both nodes should report the same commitment
|
||||||
|
@ -155,6 +173,7 @@ test:
|
||||||
testName := fmt.Sprintf(
|
testName := fmt.Sprintf(
|
||||||
"carol_commit=%v,dave_commit=%v", cc, dc,
|
"carol_commit=%v,dave_commit=%v", cc, dc,
|
||||||
)
|
)
|
||||||
|
|
||||||
success := ht.Run(testName, func(t *testing.T) {
|
success := ht.Run(testName, func(t *testing.T) {
|
||||||
st := ht.Subtest(t)
|
st := ht.Subtest(t)
|
||||||
testFunding(st, cc, dc)
|
testFunding(st, cc, dc)
|
||||||
|
@ -172,8 +191,8 @@ test:
|
||||||
// then return a function closure that should be called to assert proper
|
// then return a function closure that should be called to assert proper
|
||||||
// channel closure.
|
// channel closure.
|
||||||
func basicChannelFundingTest(ht *lntest.HarnessTest,
|
func basicChannelFundingTest(ht *lntest.HarnessTest,
|
||||||
alice, bob *node.HarnessNode,
|
alice, bob *node.HarnessNode, fundingShim *lnrpc.FundingShim,
|
||||||
fundingShim *lnrpc.FundingShim, privateChan bool) (*lnrpc.Channel,
|
privateChan bool, commitType *lnrpc.CommitmentType) (*lnrpc.Channel,
|
||||||
*lnrpc.Channel, func()) {
|
*lnrpc.Channel, func()) {
|
||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
|
@ -206,6 +225,16 @@ func basicChannelFundingTest(ht *lntest.HarnessTest,
|
||||||
ht.AssertChannelBalanceResp(node, newResp)
|
ht.AssertChannelBalanceResp(node, newResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For taproot channels, the only way we can negotiate is using the
|
||||||
|
// explicit commitment type. This allows us to continue supporting the
|
||||||
|
// existing min version comparison for implicit negotiation.
|
||||||
|
var commitTypeParam lnrpc.CommitmentType
|
||||||
|
if commitType != nil &&
|
||||||
|
*commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
||||||
|
|
||||||
|
commitTypeParam = *commitType
|
||||||
|
}
|
||||||
|
|
||||||
// First establish a channel with a capacity of 0.5 BTC between Alice
|
// First establish a channel with a capacity of 0.5 BTC between Alice
|
||||||
// and Bob with Alice pushing 100k satoshis to Bob's side during
|
// and Bob with Alice pushing 100k satoshis to Bob's side during
|
||||||
// funding. This function will block until the channel itself is fully
|
// funding. This function will block until the channel itself is fully
|
||||||
|
@ -214,11 +243,12 @@ func basicChannelFundingTest(ht *lntest.HarnessTest,
|
||||||
// successfully.
|
// successfully.
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
alice, bob, lntest.OpenChannelParams{
|
alice, bob, lntest.OpenChannelParams{
|
||||||
Private: privateChan,
|
Private: privateChan,
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
FundingShim: fundingShim,
|
FundingShim: fundingShim,
|
||||||
SatPerVByte: satPerVbyte,
|
SatPerVByte: satPerVbyte,
|
||||||
|
CommitmentType: commitTypeParam,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -558,7 +588,7 @@ func testExternalFundingChanPoint(ht *lntest.HarnessTest) {
|
||||||
// test as everything should now proceed as normal (a regular channel
|
// test as everything should now proceed as normal (a regular channel
|
||||||
// funding flow).
|
// funding flow).
|
||||||
carolChan, daveChan, _ := basicChannelFundingTest(
|
carolChan, daveChan, _ := basicChannelFundingTest(
|
||||||
ht, carol, dave, fundingShim2, false,
|
ht, carol, dave, fundingShim2, false, nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Both channels should be marked as frozen with the proper thaw
|
// Both channels should be marked as frozen with the proper thaw
|
||||||
|
|
|
@ -2023,6 +2023,12 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
|
||||||
ZeroConf: zeroConf,
|
ZeroConf: zeroConf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the channel type is taproot, then use an explicit channel type to
|
||||||
|
// open it.
|
||||||
|
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
||||||
|
aliceParams.CommitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
|
||||||
|
}
|
||||||
|
|
||||||
// We'll create a channel from Bob to Carol. After this channel is
|
// We'll create a channel from Bob to Carol. After this channel is
|
||||||
// open, our topology looks like: A -> B -> C.
|
// open, our topology looks like: A -> B -> C.
|
||||||
var bobFundingShim *lnrpc.FundingShim
|
var bobFundingShim *lnrpc.FundingShim
|
||||||
|
@ -2041,6 +2047,12 @@ func createThreeHopNetwork(ht *lntest.HarnessTest,
|
||||||
ZeroConf: zeroConf,
|
ZeroConf: zeroConf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the channel type is taproot, then use an explicit channel type to
|
||||||
|
// open it.
|
||||||
|
if c == lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
||||||
|
bobParams.CommitmentType = lnrpc.CommitmentType_SIMPLE_TAPROOT
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
acceptStreamBob rpc.AcceptorClient
|
acceptStreamBob rpc.AcceptorClient
|
||||||
acceptStreamCarol rpc.AcceptorClient
|
acceptStreamCarol rpc.AcceptorClient
|
||||||
|
|
|
@ -250,8 +250,9 @@ func revokedCloseRetributionZeroValueRemoteOutputCase(ht *lntest.HarnessTest,
|
||||||
privateChan := commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT
|
privateChan := commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
dave, carol, lntest.OpenChannelParams{
|
dave, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
CommitmentType: commitType,
|
||||||
Private: privateChan,
|
Amt: chanAmt,
|
||||||
|
Private: privateChan,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -436,9 +437,10 @@ func revokedCloseRetributionRemoteHodlCase(ht *lntest.HarnessTest,
|
||||||
privateChan := commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT
|
privateChan := commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT
|
||||||
chanPoint := ht.OpenChannel(
|
chanPoint := ht.OpenChannel(
|
||||||
dave, carol, lntest.OpenChannelParams{
|
dave, carol, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
PushAmt: pushAmt,
|
PushAmt: pushAmt,
|
||||||
Private: privateChan,
|
Private: privateChan,
|
||||||
|
CommitmentType: commitType,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue