mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-19 08:10:07 +02:00
funding: integration test to verify the value of FundingExpiryBlock on
pending channels that are waiting for funding confirmation.
This commit is contained in:
parent
663b28808a
commit
f7bdbb9e73
@ -57,6 +57,10 @@ var allTestCases = []*lntest.TestCase{
|
|||||||
Name: "sphinx replay persistence",
|
Name: "sphinx replay persistence",
|
||||||
TestFunc: testSphinxReplayPersistence,
|
TestFunc: testSphinxReplayPersistence,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "funding expiry blocks on pending",
|
||||||
|
TestFunc: testFundingExpiryBlocksOnPending,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "list channels",
|
Name: "list channels",
|
||||||
TestFunc: testListChannels,
|
TestFunc: testListChannels,
|
||||||
|
@ -621,3 +621,34 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// testFundingExpiryBlocksOnPending checks that after an OpenChannel, and
|
||||||
|
// before the funding transaction is confirmed, that the FundingExpiryBlocks
|
||||||
|
// field of a PendingChannels decreases.
|
||||||
|
func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
|
||||||
|
alice, bob := ht.Alice, ht.Bob
|
||||||
|
param := lntest.OpenChannelParams{Amt: 100000}
|
||||||
|
update := ht.OpenChannelAssertPending(alice, bob, param)
|
||||||
|
|
||||||
|
// At this point, the channel's funding transaction will have been
|
||||||
|
// broadcast, but not confirmed. Alice and Bob's nodes should reflect
|
||||||
|
// this when queried via RPC. FundingExpiryBlock should decrease
|
||||||
|
// as blocks are mined, until the channel is confirmed. Empty blocks
|
||||||
|
// won't confirm the funding transaction, so let's mine a few empty
|
||||||
|
// blocks and verify the value of FundingExpiryBlock at each step.
|
||||||
|
const numEmptyBlocks = 3
|
||||||
|
for i := int32(0); i < numEmptyBlocks; i++ {
|
||||||
|
expectedVal := funding.MaxWaitNumBlocksFundingConf - i
|
||||||
|
pending := ht.AssertNumPendingOpenChannels(alice, 1)
|
||||||
|
require.Equal(ht, expectedVal, pending[0].FundingExpiryBlocks)
|
||||||
|
pending = ht.AssertNumPendingOpenChannels(bob, 1)
|
||||||
|
require.Equal(ht, expectedVal, pending[0].FundingExpiryBlocks)
|
||||||
|
ht.MineEmptyBlocks(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mine 1 block to confirm the funding transaction, and then close the
|
||||||
|
// channel.
|
||||||
|
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||||
|
chanPoint := lntest.ChanPointFromPendingUpdate(update)
|
||||||
|
ht.CloseChannel(alice, chanPoint)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user