From 5d18fccd423cd42f11797e8701f21da6fa04a4cd Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 7 Feb 2023 22:15:08 +0100 Subject: [PATCH] itest: reproduce remote signing issue This commit attempts to reproduce the issue as described in #7276. --- lntest/itest/lnd_funding_test.go | 49 ++++++++++++++++++-------- lntest/itest/lnd_remote_signer_test.go | 6 ++++ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/lntest/itest/lnd_funding_test.go b/lntest/itest/lnd_funding_test.go index bd57997ee..d9e66d792 100644 --- a/lntest/itest/lnd_funding_test.go +++ b/lntest/itest/lnd_funding_test.go @@ -330,23 +330,43 @@ func testUnconfirmedChannelFunding(ht *lntemp.HarnessTest) { // testChannelFundingInputTypes tests that any type of supported input type can // be used to fund channels. func testChannelFundingInputTypes(ht *lntemp.HarnessTest) { - const ( - chanAmt = funding.MaxBtcFundingAmount - burnAddr = "bcrt1qxsnqpdc842lu8c0xlllgvejt6rhy49u6fmpgyz" - ) - - fundWithTypes := []func(amt btcutil.Amount, target *node.HarnessNode){ - ht.FundCoins, ht.FundCoinsNP2WKH, ht.FundCoinsP2TR, - } - - alice := ht.Alice - // We'll start off by creating a node for Carol. carol := ht.NewNode("Carol", nil) // Now, we'll connect her to Alice so that they can open a // channel together. - ht.ConnectNodes(carol, alice) + ht.ConnectNodes(carol, ht.Alice) + + runChannelFundingInputTypes(ht, ht.Alice, carol) +} + +// runChannelFundingInputTypes tests that any type of supported input type can +// be used to fund channels. +func runChannelFundingInputTypes(ht *lntemp.HarnessTest, alice, + carol *node.HarnessNode) { + + const ( + chanAmt = funding.MaxBtcFundingAmount + burnAddr = "bcrt1qxsnqpdc842lu8c0xlllgvejt6rhy49u6fmpgyz" + ) + + fundMixed := func(amt btcutil.Amount, target *node.HarnessNode) { + ht.FundCoins(amt/5, target) + ht.FundCoins(amt/5, target) + ht.FundCoinsP2TR(amt/5, target) + ht.FundCoinsP2TR(amt/5, target) + ht.FundCoinsP2TR(amt/5, target) + } + fundMultipleP2TR := func(amt btcutil.Amount, target *node.HarnessNode) { + ht.FundCoinsP2TR(amt/4, target) + ht.FundCoinsP2TR(amt/4, target) + ht.FundCoinsP2TR(amt/4, target) + ht.FundCoinsP2TR(amt/4, target) + } + fundWithTypes := []func(amt btcutil.Amount, target *node.HarnessNode){ + ht.FundCoins, ht.FundCoinsNP2WKH, ht.FundCoinsP2TR, fundMixed, + fundMultipleP2TR, + } // Creates a helper closure to be used below which asserts the // proper response to a channel balance RPC. @@ -386,8 +406,9 @@ func testChannelFundingInputTypes(ht *lntemp.HarnessTest) { } for _, funder := range fundWithTypes { - // We'll send her some confirmed funds. - funder(chanAmt*2, carol) + // We'll send her some confirmed funds. We send 10% more than + // we need to account for fees. + funder((chanAmt*11)/10, carol) chanOpenUpdate := ht.OpenChannelAssertStream( carol, alice, lntemp.OpenChannelParams{ diff --git a/lntest/itest/lnd_remote_signer_test.go b/lntest/itest/lnd_remote_signer_test.go index eccf396b9..0afdf9bc4 100644 --- a/lntest/itest/lnd_remote_signer_test.go +++ b/lntest/itest/lnd_remote_signer_test.go @@ -84,6 +84,12 @@ func testRemoteSigner(ht *lntemp.HarnessTest) { fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) { runBasicChannelCreationAndUpdates(tt, wo, carol) }, + }, { + name: "channel funding input types", + sendCoins: false, + fn: func(tt *lntemp.HarnessTest, wo, carol *node.HarnessNode) { + runChannelFundingInputTypes(tt, carol, wo) + }, }, { name: "async payments", sendCoins: true,