mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-03 08:20:30 +02:00
lntest: reflect the updated fee estimator in tests
This commit is contained in:
parent
1870caf39c
commit
519a8749ef
@ -322,8 +322,9 @@ func sweepNodeWalletAndAssert(ht *lntest.HarnessTest, node *node.HarnessNode) {
|
||||
|
||||
// Send all funds back to the miner node.
|
||||
node.RPC.SendCoins(&lnrpc.SendCoinsRequest{
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Ensures we don't leave any transaction in the mempool after sweeping.
|
||||
|
@ -85,6 +85,7 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
|
||||
closeClient := alice.RPC.CloseChannel(&lnrpc.CloseChannelRequest{
|
||||
ChannelPoint: chanPoint,
|
||||
NoWait: true,
|
||||
TargetConf: 6,
|
||||
})
|
||||
ht.AssertChannelInactive(bob, chanPoint)
|
||||
|
||||
@ -184,6 +185,7 @@ func coopCloseWithHTLCsWithRestart(ht *lntest.HarnessTest) {
|
||||
ChannelPoint: chanPoint,
|
||||
NoWait: true,
|
||||
DeliveryAddress: newAddr.Address,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Assert that both nodes see the channel as waiting for close.
|
||||
|
@ -528,8 +528,9 @@ func sendAllCoinsConfirm(ht *lntest.HarnessTest, node *node.HarnessNode,
|
||||
addr string) {
|
||||
|
||||
sweepReq := &lnrpc.SendCoinsRequest{
|
||||
Addr: addr,
|
||||
SendAll: true,
|
||||
Addr: addr,
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
}
|
||||
node.RPC.SendCoins(sweepReq)
|
||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||
|
@ -778,16 +778,18 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
|
||||
|
||||
// Ensure that we can't send coins to our own Pubkey.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: ainz.RPC.GetInfo().IdentityPubkey,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
Addr: ainz.RPC.GetInfo().IdentityPubkey,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Ensure that we can't send coins to another user's Pubkey.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: ht.Alice.RPC.GetInfo().IdentityPubkey,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
Addr: ht.Alice.RPC.GetInfo().IdentityPubkey,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// With the two coins above mined, we'll now instruct Ainz to sweep all
|
||||
@ -799,23 +801,34 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
|
||||
|
||||
// Send coins to a testnet3 address.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
Addr: "tb1qfc8fusa98jx8uvnhzavxccqlzvg749tvjw82tg",
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Send coins to a mainnet address.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
|
||||
Addr: "1MPaXKp5HhsLNjVSqaL7fChE3TVyrTMRT3",
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Send coins to a compatible address without specifying fee rate or
|
||||
// conf target.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: ht.Miner.NewMinerAddress().String(),
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
})
|
||||
|
||||
// Send coins to a compatible address.
|
||||
ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{
|
||||
Addr: ht.Miner.NewMinerAddress().String(),
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
Addr: ht.Miner.NewMinerAddress().String(),
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// We'll mine a block which should include the sweep transaction we
|
||||
@ -912,10 +925,11 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
|
||||
// If we try again, but this time specifying an amount, then the call
|
||||
// should fail.
|
||||
ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
|
||||
Addr: ht.Miner.NewMinerAddress().String(),
|
||||
Amount: 10000,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
Addr: ht.Miner.NewMinerAddress().String(),
|
||||
Amount: 10000,
|
||||
SendAll: true,
|
||||
Label: sendCoinsLabel,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// With all the edge cases tested, we'll now test the happy paths of
|
||||
@ -941,8 +955,9 @@ func testSweepAllCoins(ht *lntest.HarnessTest) {
|
||||
// Let's send some coins to the main address.
|
||||
const amt = 123456
|
||||
resp := ainz.RPC.SendCoins(&lnrpc.SendCoinsRequest{
|
||||
Addr: mainAddrResp.Address,
|
||||
Amount: amt,
|
||||
Addr: mainAddrResp.Address,
|
||||
Amount: amt,
|
||||
TargetConf: 6,
|
||||
})
|
||||
block := ht.MineBlocksAndAssertNumTxes(1, 1)[0]
|
||||
sweepTx := block.Transactions[1]
|
||||
@ -1025,6 +1040,7 @@ func testListAddresses(ht *lntest.HarnessTest) {
|
||||
Addr: addr,
|
||||
Amount: addressDetail.Balance,
|
||||
SpendUnconfirmed: true,
|
||||
TargetConf: 6,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -240,8 +240,9 @@ func runCPFP(ht *lntest.HarnessTest, alice, bob *node.HarnessNode) {
|
||||
// Send the coins from Alice to Bob. We should expect a transaction to
|
||||
// be broadcast and seen in the mempool.
|
||||
sendReq := &lnrpc.SendCoinsRequest{
|
||||
Addr: resp.Address,
|
||||
Amount: btcutil.SatoshiPerBitcoin,
|
||||
Addr: resp.Address,
|
||||
Amount: btcutil.SatoshiPerBitcoin,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(sendReq)
|
||||
txid := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||
@ -383,8 +384,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
|
||||
resp := alice.RPC.NewAddress(req)
|
||||
|
||||
sweepReq := &lnrpc.SendCoinsRequest{
|
||||
Addr: resp.Address,
|
||||
SendAll: true,
|
||||
Addr: resp.Address,
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(sweepReq)
|
||||
|
||||
@ -432,8 +434,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
|
||||
minerAddr := ht.Miner.NewMinerAddress()
|
||||
|
||||
sweepReq = &lnrpc.SendCoinsRequest{
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(sweepReq)
|
||||
|
||||
@ -469,8 +472,9 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
|
||||
// We'll wait for the balance to reflect that the channel has been
|
||||
// closed and the funds are in the wallet.
|
||||
sweepReq = &lnrpc.SendCoinsRequest{
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(sweepReq)
|
||||
|
||||
@ -602,6 +606,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
|
||||
sweepReq := &lnrpc.SendCoinsRequest{
|
||||
Addr: minerAddr.String(),
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
MinConfs: 0,
|
||||
SpendUnconfirmed: true,
|
||||
}
|
||||
@ -755,8 +760,9 @@ func testRemoveTx(ht *lntest.HarnessTest) {
|
||||
// We send half the amount to that address generating two unconfirmed
|
||||
// outpoints in our internal wallet.
|
||||
sendReq := &lnrpc.SendCoinsRequest{
|
||||
Addr: resp.Address,
|
||||
Amount: initialWalletAmt / 2,
|
||||
Addr: resp.Address,
|
||||
Amount: initialWalletAmt / 2,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(sendReq)
|
||||
txID := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||
|
@ -1539,6 +1539,7 @@ func sendAllCoinsToAddrType(ht *lntest.HarnessTest,
|
||||
Addr: resp.Address,
|
||||
SendAll: true,
|
||||
SpendUnconfirmed: true,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
ht.MineBlocksAndAssertNumTxes(1, 1)
|
||||
|
@ -254,8 +254,9 @@ func testOnchainFundRecovery(ht *lntest.HarnessTest) {
|
||||
|
||||
minerAddr := ht.Miner.NewMinerAddress()
|
||||
req := &lnrpc.SendCoinsRequest{
|
||||
Addr: minerAddr.String(),
|
||||
Amount: minerAmt,
|
||||
Addr: minerAddr.String(),
|
||||
Amount: minerAmt,
|
||||
TargetConf: 6,
|
||||
}
|
||||
resp := node.RPC.SendCoins(req)
|
||||
|
||||
|
@ -289,8 +289,9 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
|
||||
|
||||
// Send some coins to the generated p2wpkh address.
|
||||
req := &lnrpc.SendCoinsRequest{
|
||||
Addr: targetAddr.String(),
|
||||
Amount: 800_000,
|
||||
Addr: targetAddr.String(),
|
||||
Amount: 800_000,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(req)
|
||||
|
||||
|
@ -101,8 +101,9 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
|
||||
// Send the coins from Alice's wallet to her own, but to the new p2tr
|
||||
// address.
|
||||
alice.RPC.SendCoins(&lnrpc.SendCoinsRequest{
|
||||
Addr: p2trResp.Address,
|
||||
Amount: 0.5 * btcutil.SatoshiPerBitcoin,
|
||||
Addr: p2trResp.Address,
|
||||
Amount: 0.5 * btcutil.SatoshiPerBitcoin,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
txid := ht.Miner.AssertNumTxsInMempool(1)[0]
|
||||
@ -125,8 +126,9 @@ func testTaprootSendCoinsKeySpendBip86(ht *lntest.HarnessTest,
|
||||
})
|
||||
|
||||
alice.RPC.SendCoins(&lnrpc.SendCoinsRequest{
|
||||
Addr: p2trResp.Address,
|
||||
SendAll: true,
|
||||
Addr: p2trResp.Address,
|
||||
SendAll: true,
|
||||
TargetConf: 6,
|
||||
})
|
||||
|
||||
// Make sure the coins sent to the address are confirmed correctly,
|
||||
@ -152,8 +154,9 @@ func testTaprootComputeInputScriptKeySpendBip86(ht *lntest.HarnessTest,
|
||||
// Send the coins from Alice's wallet to her own, but to the new p2tr
|
||||
// address.
|
||||
req := &lnrpc.SendCoinsRequest{
|
||||
Addr: p2trAddr.String(),
|
||||
Amount: testAmount,
|
||||
Addr: p2trAddr.String(),
|
||||
Amount: testAmount,
|
||||
TargetConf: 6,
|
||||
}
|
||||
alice.RPC.SendCoins(req)
|
||||
|
||||
@ -1469,8 +1472,9 @@ func sendToTaprootOutput(ht *lntest.HarnessTest, hn *node.HarnessNode,
|
||||
|
||||
// Send some coins to the generated tapscript address.
|
||||
req := &lnrpc.SendCoinsRequest{
|
||||
Addr: tapScriptAddr.String(),
|
||||
Amount: testAmount,
|
||||
Addr: tapScriptAddr.String(),
|
||||
Amount: testAmount,
|
||||
TargetConf: 6,
|
||||
}
|
||||
hn.RPC.SendCoins(req)
|
||||
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/kvdb/etcd"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
@ -922,6 +923,10 @@ type OpenChannelParams struct {
|
||||
// virtual byte of the transaction.
|
||||
SatPerVByte btcutil.Amount
|
||||
|
||||
// ConfTarget is the number of blocks that the funding transaction
|
||||
// should be confirmed in.
|
||||
ConfTarget fn.Option[int32]
|
||||
|
||||
// CommitmentType is the commitment type that should be used for the
|
||||
// channel to be opened.
|
||||
CommitmentType lnrpc.CommitmentType
|
||||
@ -992,18 +997,27 @@ func (h *HarnessTest) prepareOpenChannel(srcNode, destNode *node.HarnessNode,
|
||||
minConfs = 0
|
||||
}
|
||||
|
||||
// Get the requested conf target. If not set, default to 6.
|
||||
confTarget := p.ConfTarget.UnwrapOr(6)
|
||||
|
||||
// If there's fee rate set, unset the conf target.
|
||||
if p.SatPerVByte != 0 {
|
||||
confTarget = 0
|
||||
}
|
||||
|
||||
// Prepare the request.
|
||||
return &lnrpc.OpenChannelRequest{
|
||||
NodePubkey: destNode.PubKey[:],
|
||||
LocalFundingAmount: int64(p.Amt),
|
||||
PushSat: int64(p.PushAmt),
|
||||
Private: p.Private,
|
||||
TargetConf: confTarget,
|
||||
MinConfs: minConfs,
|
||||
SpendUnconfirmed: p.SpendUnconfirmed,
|
||||
MinHtlcMsat: int64(p.MinHtlc),
|
||||
RemoteMaxHtlcs: uint32(p.RemoteMaxHtlcs),
|
||||
FundingShim: p.FundingShim,
|
||||
SatPerByte: int64(p.SatPerVByte),
|
||||
SatPerVbyte: uint64(p.SatPerVByte),
|
||||
CommitmentType: p.CommitmentType,
|
||||
ZeroConf: p.ZeroConf,
|
||||
ScidAlias: p.ScidAlias,
|
||||
@ -1210,6 +1224,11 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
|
||||
NoWait: true,
|
||||
}
|
||||
|
||||
// For coop close, we use a default confg target of 6.
|
||||
if !force {
|
||||
closeReq.TargetConf = 6
|
||||
}
|
||||
|
||||
var (
|
||||
stream rpc.CloseChanClient
|
||||
event *lnrpc.CloseStatusUpdate
|
||||
|
Loading…
x
Reference in New Issue
Block a user