itest+lntest: add new method FundNumCoins

Most of the time we only need to fund the node with given number of
UTXOs without concerning the amount, so we add the more efficient
funding method as it mines a single block in the end.
This commit is contained in:
yyforyongyu
2024-11-25 21:56:47 +08:00
parent 691a6267be
commit 5236c05dc6
2 changed files with 40 additions and 6 deletions

View File

@@ -779,24 +779,24 @@ func testSweepHTLCs(ht *lntest.HarnessTest) {
// Bob needs two more wallet utxos:
// - when sweeping anchors, he needs one utxo for each sweep.
// - when sweeping HTLCs, he needs one utxo for each sweep.
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
numUTXOs := 2
// Bob should have enough wallet UTXOs here to sweep the HTLC in the
// end of this test. However, due to a known issue, Bob's wallet may
// report there's no UTXO available. For details,
// - https://github.com/lightningnetwork/lnd/issues/8786
//
// TODO(yy): remove this step once the issue is resolved.
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
// TODO(yy): remove this extra UTXO once the issue is resolved.
numUTXOs++
// For neutrino backend, we need two more UTXOs for Bob to create his
// sweeping txns.
if ht.IsNeutrinoBackend() {
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
ht.FundCoins(btcutil.SatoshiPerBitcoin, bob)
numUTXOs += 2
}
ht.FundNumCoins(bob, numUTXOs)
// Subscribe the invoices.
stream1 := carol.RPC.SubscribeSingleInvoice(payHashSettled[:])
stream2 := carol.RPC.SubscribeSingleInvoice(payHashHold[:])