Skip to content

Commit 79b2076

Browse files
committed
lntest: reflect the updated fee estimator in tests
1 parent b8778c1 commit 79b2076

10 files changed

+98
-46
lines changed

itest/lnd_channel_funding_fund_max_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ func sweepNodeWalletAndAssert(ht *lntest.HarnessTest, node *node.HarnessNode) {
322322

323323
// Send all funds back to the miner node.
324324
node.RPC.SendCoins(&lnrpc.SendCoinsRequest{
325-
Addr: minerAddr.String(),
326-
SendAll: true,
325+
Addr: minerAddr.String(),
326+
SendAll: true,
327+
TargetConf: 6,
327328
})
328329

329330
// Ensures we don't leave any transaction in the mempool after sweeping.

itest/lnd_coop_close_with_htlcs_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
8585
closeClient := alice.RPC.CloseChannel(&lnrpc.CloseChannelRequest{
8686
ChannelPoint: chanPoint,
8787
NoWait: true,
88+
TargetConf: 6,
8889
})
8990
ht.AssertChannelInactive(bob, chanPoint)
9091

@@ -184,6 +185,7 @@ func coopCloseWithHTLCsWithRestart(ht *lntest.HarnessTest) {
184185
ChannelPoint: chanPoint,
185186
NoWait: true,
186187
DeliveryAddress: newAddr.Address,
188+
TargetConf: 6,
187189
})
188190

189191
// Assert that both nodes see the channel as waiting for close.

itest/lnd_funding_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,9 @@ func sendAllCoinsConfirm(ht *lntest.HarnessTest, node *node.HarnessNode,
528528
addr string) {
529529

530530
sweepReq := &lnrpc.SendCoinsRequest{
531-
Addr: addr,
532-
SendAll: true,
531+
Addr: addr,
532+
SendAll: true,
533+
TargetConf: 6,
533534
}
534535
node.RPC.SendCoins(sweepReq)
535536
ht.MineBlocksAndAssertNumTxes(1, 1)

itest/lnd_misc_test.go

+35-19
Original file line numberDiff line numberDiff line change
@@ -777,16 +777,18 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
777777

778778
// Ensure that we can't send coins to our own Pubkey.
779779
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
780-
Addr: ainz.RPC.GetInfo().IdentityPubkey,
781-
SendAll: true,
782-
Label: sendCoinsLabel,
780+
Addr: ainz.RPC.GetInfo().IdentityPubkey,
781+
SendAll: true,
782+
Label: sendCoinsLabel,
783+
TargetConf: 6,
783784
})
784785

785786
// Ensure that we can't send coins to another user's Pubkey.
786787
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
787-
Addr: ht.Alice.RPC.GetInfo().IdentityPubkey,
788-
SendAll: true,
789-
Label: sendCoinsLabel,
788+
Addr: ht.Alice.RPC.GetInfo().IdentityPubkey,
789+
SendAll: true,
790+
Label: sendCoinsLabel,
791+
TargetConf: 6,
790792
})
791793

792794
// With the two coins above mined, we'll now instruct Ainz to sweep all
@@ -798,23 +800,34 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
798800

799801
// Send coins to a testnet3 address.
800802
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
801-
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
802-
SendAll: true,
803-
Label: sendCoinsLabel,
803+
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
804+
SendAll: true,
805+
Label: sendCoinsLabel,
806+
TargetConf: 6,
804807
})
805808

806809
// Send coins to a mainnet address.
807810
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
808-
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
811+
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
812+
SendAll: true,
813+
Label: sendCoinsLabel,
814+
TargetConf: 6,
815+
})
816+
817+
// Send coins to a compatible address without specifying fee rate or
818+
// conf target.
819+
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
820+
Addr: ht.Miner.NewMinerAddress().String(),
809821
SendAll: true,
810822
Label: sendCoinsLabel,
811823
})
812824

813825
// Send coins to a compatible address.
814826
ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{
815-
Addr: ht.Miner.NewMinerAddress().String(),
816-
SendAll: true,
817-
Label: sendCoinsLabel,
827+
Addr: ht.Miner.NewMinerAddress().String(),
828+
SendAll: true,
829+
Label: sendCoinsLabel,
830+
TargetConf: 6,
818831
})
819832

820833
// We'll mine a block which should include the sweep transaction we
@@ -911,10 +924,11 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
911924
// If we try again, but this time specifying an amount, then the call
912925
// should fail.
913926
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
914-
Addr: ht.Miner.NewMinerAddress().String(),
915-
Amount: 10000,
916-
SendAll: true,
917-
Label: sendCoinsLabel,
927+
Addr: ht.Miner.NewMinerAddress().String(),
928+
Amount: 10000,
929+
SendAll: true,
930+
Label: sendCoinsLabel,
931+
TargetConf: 6,
918932
})
919933

920934
// With all the edge cases tested, we'll now test the happy paths of
@@ -940,8 +954,9 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
940954
// Let's send some coins to the main address.
941955
const amt = 123456
942956
resp := ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{
943-
Addr: mainAddrResp.Address,
944-
Amount: amt,
957+
Addr: mainAddrResp.Address,
958+
Amount: amt,
959+
TargetConf: 6,
945960
})
946961
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
947962
sweepTx := block.Transactions[1]
@@ -1024,6 +1039,7 @@ func testListAddresses(ht *lntest.HarnessTest) {
10241039
Addr: addr,
10251040
Amount: addressDetail.Balance,
10261041
SpendUnconfirmed: true,
1042+
TargetConf: 6,
10271043
})
10281044
}
10291045

itest/lnd_onchain_test.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ func runCPFP(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) {
240240
// Send the coins from Alice to Bob. We should expect a transaction to
241241
// be broadcast and seen in the mempool.
242242
sendReq := &lnrpc.SendCoinsRequest{
243-
Addr: resp.Address,
244-
Amount: btcutil.SatoshiPerBitcoin,
243+
Addr: resp.Address,
244+
Amount: btcutil.SatoshiPerBitcoin,
245+
TargetConf: 6,
245246
}
246247
alice.RPC.SendCoins(sendReq)
247248
txid := ht.Miner.AssertNumTxsInMempool(1)[0]
@@ -383,8 +384,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
383384
resp := alice.RPC.NewAddress(req)
384385

385386
sweepReq := &lnrpc.SendCoinsRequest{
386-
Addr: resp.Address,
387-
SendAll: true,
387+
Addr: resp.Address,
388+
SendAll: true,
389+
TargetConf: 6,
388390
}
389391
alice.RPC.SendCoins(sweepReq)
390392

@@ -432,8 +434,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
432434
minerAddr := ht.Miner.NewMinerAddress()
433435

434436
sweepReq = &lnrpc.SendCoinsRequest{
435-
Addr: minerAddr.String(),
436-
SendAll: true,
437+
Addr: minerAddr.String(),
438+
SendAll: true,
439+
TargetConf: 6,
437440
}
438441
alice.RPC.SendCoins(sweepReq)
439442

@@ -469,8 +472,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
469472
// We'll wait for the balance to reflect that the channel has been
470473
// closed and the funds are in the wallet.
471474
sweepReq = &lnrpc.SendCoinsRequest{
472-
Addr: minerAddr.String(),
473-
SendAll: true,
475+
Addr: minerAddr.String(),
476+
SendAll: true,
477+
TargetConf: 6,
474478
}
475479
alice.RPC.SendCoins(sweepReq)
476480

@@ -602,6 +606,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
602606
sweepReq := &lnrpc.SendCoinsRequest{
603607
Addr: minerAddr.String(),
604608
SendAll: true,
609+
TargetConf: 6,
605610
MinConfs: 0,
606611
SpendUnconfirmed: true,
607612
}
@@ -755,8 +760,9 @@ func testRemoveTx(ht *lntest.HarnessTest) {
755760
// We send half the amount to that address generating two unconfirmed
756761
// outpoints in our internal wallet.
757762
sendReq := &lnrpc.SendCoinsRequest{
758-
Addr: resp.Address,
759-
Amount: initialWalletAmt / 2,
763+
Addr: resp.Address,
764+
Amount: initialWalletAmt / 2,
765+
TargetConf: 6,
760766
}
761767
alice.RPC.SendCoins(sendReq)
762768
txID := ht.Miner.AssertNumTxsInMempool(1)[0]

itest/lnd_psbt_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,7 @@ func sendAllCoinsToAddrType(ht *lntest.HarnessTest,
15391539
Addr: resp.Address,
15401540
SendAll: true,
15411541
SpendUnconfirmed: true,
1542+
TargetConf: 6,
15421543
})
15431544

15441545
ht.MineBlocksAndAssertNumTxes(1, 1)

itest/lnd_recovery_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) {
254254

255255
minerAddr := ht.Miner.NewMinerAddress()
256256
req := &lnrpc.SendCoinsRequest{
257-
Addr: minerAddr.String(),
258-
Amount: minerAmt,
257+
Addr: minerAddr.String(),
258+
Amount: minerAmt,
259+
TargetConf: 6,
259260
}
260261
resp := node.RPC.SendCoins(req)
261262

itest/lnd_signer_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
289289

290290
// Send some coins to the generated p2wpkh address.
291291
req := &lnrpc.SendCoinsRequest{
292-
Addr: targetAddr.String(),
293-
Amount: 800_000,
292+
Addr: targetAddr.String(),
293+
Amount: 800_000,
294+
TargetConf: 6,
294295
}
295296
alice.RPC.SendCoins(req)
296297

itest/lnd_taproot_test.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
101101
// Send the coins from Alice's wallet to her own, but to the new p2tr
102102
// address.
103103
alice.RPC.SendCoins(&lnrpc.SendCoinsRequest{
104-
Addr: p2trResp.Address,
105-
Amount: 0.5 * btcutil.SatoshiPerBitcoin,
104+
Addr: p2trResp.Address,
105+
Amount: 0.5 * btcutil.SatoshiPerBitcoin,
106+
TargetConf: 6,
106107
})
107108

108109
txid := ht.Miner.AssertNumTxsInMempool(1)[0]
@@ -125,8 +126,9 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
125126
})
126127

127128
alice.RPC.SendCoins(&lnrpc.SendCoinsRequest{
128-
Addr: p2trResp.Address,
129-
SendAll: true,
129+
Addr: p2trResp.Address,
130+
SendAll: true,
131+
TargetConf: 6,
130132
})
131133

132134
// Make sure the coins sent to the address are confirmed correctly,
@@ -152,8 +154,9 @@ func testTaprootComputeInputScriptKeySpendBip86(ht *lntest.HarnessTest,
152154
// Send the coins from Alice's wallet to her own, but to the new p2tr
153155
// address.
154156
req := &lnrpc.SendCoinsRequest{
155-
Addr: p2trAddr.String(),
156-
Amount: testAmount,
157+
Addr: p2trAddr.String(),
158+
Amount: testAmount,
159+
TargetConf: 6,
157160
}
158161
alice.RPC.SendCoins(req)
159162

@@ -1469,8 +1472,9 @@ func sendToTaprootOutput(ht *lntest.HarnessTest, hn *node.HarnessNode,
14691472

14701473
// Send some coins to the generated tapscript address.
14711474
req := &lnrpc.SendCoinsRequest{
1472-
Addr: tapScriptAddr.String(),
1473-
Amount: testAmount,
1475+
Addr: tapScriptAddr.String(),
1476+
Amount: testAmount,
1477+
TargetConf: 6,
14741478
}
14751479
hn.RPC.SendCoins(req)
14761480

lntest/harness.go

+20-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/btcsuite/btcd/txscript"
1414
"github.com/btcsuite/btcd/wire"
1515
"github.com/go-errors/errors"
16+
"github.com/lightningnetwork/lnd/fn"
1617
"github.com/lightningnetwork/lnd/kvdb/etcd"
1718
"github.com/lightningnetwork/lnd/lnrpc"
1819
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
@@ -922,6 +923,10 @@ type OpenChannelParams struct {
922923
// virtual byte of the transaction.
923924
SatPerVByte btcutil.Amount
924925

926+
// ConfTarget is the number of blocks that the funding transaction
927+
// should be confirmed in.
928+
ConfTarget fn.Option[int32]
929+
925930
// CommitmentType is the commitment type that should be used for the
926931
// channel to be opened.
927932
CommitmentType lnrpc.CommitmentType
@@ -992,18 +997,27 @@ func (h *HarnessTest) prepareOpenChannel(srcNode, destNode *node.HarnessNode,
992997
minConfs = 0
993998
}
994999

1000+
// Get the requested conf target. If not set, default to 6.
1001+
confTarget := p.ConfTarget.UnwrapOr(6)
1002+
1003+
// If there's fee rate set, unset the conf target.
1004+
if p.SatPerVByte != 0 {
1005+
confTarget = 0
1006+
}
1007+
9951008
// Prepare the request.
9961009
return &lnrpc.OpenChannelRequest{
9971010
NodePubkey: destNode.PubKey[:],
9981011
LocalFundingAmount: int64(p.Amt),
9991012
PushSat: int64(p.PushAmt),
10001013
Private: p.Private,
1014+
TargetConf: confTarget,
10011015
MinConfs: minConfs,
10021016
SpendUnconfirmed: p.SpendUnconfirmed,
10031017
MinHtlcMsat: int64(p.MinHtlc),
10041018
RemoteMaxHtlcs: uint32(p.RemoteMaxHtlcs),
10051019
FundingShim: p.FundingShim,
1006-
SatPerByte: int64(p.SatPerVByte),
1020+
SatPerVbyte: uint64(p.SatPerVByte),
10071021
CommitmentType: p.CommitmentType,
10081022
ZeroConf: p.ZeroConf,
10091023
ScidAlias: p.ScidAlias,
@@ -1210,6 +1224,11 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
12101224
NoWait: true,
12111225
}
12121226

1227+
// For coop close, we use a default confg target of 6.
1228+
if !force {
1229+
closeReq.TargetConf = 6
1230+
}
1231+
12131232
var (
12141233
stream rpc.CloseChanClient
12151234
event *lnrpc.CloseStatusUpdate

0 commit comments

Comments
 (0)