lntest/itest: update external funding test to exercise frozen chans
This commit is contained in:
1 file changed
+43
-10
+43
-10
@@ -15060,16 +15060,23 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to gen pending chan ID: %v", err)
|
t.Fatalf("unable to gen pending chan ID: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, currentHeight, err := net.Miner.Node.GetBestBlock()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to get current blockheight %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we have the pending channel ID, Dave (our responder) will
|
// Now that we have the pending channel ID, Dave (our responder) will
|
||||||
// register the intent to receive a new channel funding workflow using
|
// register the intent to receive a new channel funding workflow using
|
||||||
// the pending channel ID.
|
// the pending channel ID.
|
||||||
chanPointShim := &lnrpc.ChanPointShim{
|
chanPoint := &lnrpc.ChannelPoint{
|
||||||
Amt: int64(chanSize),
|
FundingTxid: &lnrpc.ChannelPoint_FundingTxidBytes{
|
||||||
ChanPoint: &lnrpc.ChannelPoint{
|
FundingTxidBytes: txid[:],
|
||||||
FundingTxid: &lnrpc.ChannelPoint_FundingTxidBytes{
|
|
||||||
FundingTxidBytes: txid[:],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
thawHeight := uint32(currentHeight + 10)
|
||||||
|
chanPointShim := &lnrpc.ChanPointShim{
|
||||||
|
Amt: int64(chanSize),
|
||||||
|
ChanPoint: chanPoint,
|
||||||
LocalKey: &lnrpc.KeyDescriptor{
|
LocalKey: &lnrpc.KeyDescriptor{
|
||||||
RawKeyBytes: daveFundingKey.RawKeyBytes,
|
RawKeyBytes: daveFundingKey.RawKeyBytes,
|
||||||
KeyLoc: &lnrpc.KeyLocator{
|
KeyLoc: &lnrpc.KeyLocator{
|
||||||
@@ -15079,6 +15086,7 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
},
|
},
|
||||||
RemoteKey: carolFundingKey.RawKeyBytes,
|
RemoteKey: carolFundingKey.RawKeyBytes,
|
||||||
PendingChanId: pendingChanID[:],
|
PendingChanId: pendingChanID[:],
|
||||||
|
ThawHeight: thawHeight,
|
||||||
}
|
}
|
||||||
fundingShim := &lnrpc.FundingShim{
|
fundingShim := &lnrpc.FundingShim{
|
||||||
Shim: &lnrpc.FundingShim_ChanPointShim{
|
Shim: &lnrpc.FundingShim_ChanPointShim{
|
||||||
@@ -15121,13 +15129,24 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// At this point, we'll now carry out the normal basic channel funding
|
// At this point, we'll now carry out the normal basic channel funding
|
||||||
// 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).
|
||||||
_, _, closeChans, err := basicChannelFundingTest(
|
carolChan, daveChan, _, err := basicChannelFundingTest(
|
||||||
t, net, carol, dave, fundingShim,
|
t, net, carol, dave, fundingShim,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channels: %v", err)
|
t.Fatalf("unable to open channels: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Both channels should be marked as frozen with the proper thaw
|
||||||
|
// height.
|
||||||
|
if carolChan.ThawHeight != thawHeight {
|
||||||
|
t.Fatalf("expected thaw height of %v, got %v",
|
||||||
|
carolChan.ThawHeight, thawHeight)
|
||||||
|
}
|
||||||
|
if daveChan.ThawHeight != thawHeight {
|
||||||
|
t.Fatalf("expected thaw height of %v, got %v",
|
||||||
|
daveChan.ThawHeight, thawHeight)
|
||||||
|
}
|
||||||
|
|
||||||
// Next, to make sure the channel functions as normal, we'll make some
|
// Next, to make sure the channel functions as normal, we'll make some
|
||||||
// payments within the channel.
|
// payments within the channel.
|
||||||
payAmt := btcutil.Amount(100000)
|
payAmt := btcutil.Amount(100000)
|
||||||
@@ -15148,10 +15167,24 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
t.Fatalf("unable to make payments between Carol and Dave")
|
t.Fatalf("unable to make payments between Carol and Dave")
|
||||||
}
|
}
|
||||||
|
|
||||||
// To conclude, we'll close the newly created channel between Carol and
|
// Now that the channels are open, and we've confirmed that they're
|
||||||
// Dave.
|
// operational, we'll now ensure that the channels are frozen as
|
||||||
closeChans()
|
// intended (if requested).
|
||||||
|
//
|
||||||
|
// First, we'll try to close the channel as Carol, the initiator. This
|
||||||
|
// should fail as a frozen channel only allows the responder to
|
||||||
|
// initiate a channel close.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
|
||||||
|
_, _, err = net.CloseChannel(ctxt, carol, chanPoint, false)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("carol wasn't denied a co-op close attempt for a " +
|
||||||
|
"frozen channel")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next we'll try but this time with Dave (the responder) as the
|
||||||
|
// initiator. This time the channel should be closed as normal.
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, channelCloseTimeout)
|
||||||
|
closeChannelAndAssert(ctxt, t, net, dave, chanPoint, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
type testCase struct {
|
type testCase struct {
|
||||||
|
|||||||
Reference in new issue
Block a user