lntest: reflect the updated fee estimator in tests

This commit is contained in:
yyforyongyu
2024-01-26 04:00:54 +08:00
parent 1870caf39c
commit 519a8749ef
10 changed files with 98 additions and 46 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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)

View File

@@ -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,
})
}

View File

@@ -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]

View File

@@ -1539,6 +1539,7 @@ func sendAllCoinsToAddrType(ht *lntest.HarnessTest,
Addr: resp.Address,
SendAll: true,
SpendUnconfirmed: true,
TargetConf: 6,
})
ht.MineBlocksAndAssertNumTxes(1, 1)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)