itest: remove direct reference to stanby nodes

Prepares the upcoming refactor. We now never call `ht.Alice` directly,
instead, we always init `alice := ht.Alice` so it's easier to see how
they are removed in a following commit.
This commit is contained in:
yyforyongyu committed 2024-12-20 19:38:05 +08:00
1 parent ef167835dd
commit 3eda87fff9
16 files changed
+157 -108

No files matched your search

+12 -10
View File
@@ -13,6 +13,8 @@ import (
// sets. For completeness, it also asserts that features aren't set in places // sets. For completeness, it also asserts that features aren't set in places
// where they aren't intended to be. // where they aren't intended to be.
func testCustomFeatures(ht *lntest.HarnessTest) { func testCustomFeatures(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
var ( var (
// Odd custom features so that we don't need to worry about // Odd custom features so that we don't need to worry about
// issues connecting to peers. // issues connecting to peers.
@@ -27,20 +29,20 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
fmt.Sprintf("--protocol.custom-nodeann=%v", customNodeAnn), fmt.Sprintf("--protocol.custom-nodeann=%v", customNodeAnn),
fmt.Sprintf("--protocol.custom-invoice=%v", customInvoice), fmt.Sprintf("--protocol.custom-invoice=%v", customInvoice),
} }
ht.RestartNodeWithExtraArgs(ht.Alice, extraArgs) ht.RestartNodeWithExtraArgs(alice, extraArgs)
// Connect nodes and open a channel so that Alice will be included // Connect nodes and open a channel so that Alice will be included
// in Bob's graph. // in Bob's graph.
ht.ConnectNodes(ht.Alice, ht.Bob) ht.ConnectNodes(alice, bob)
chanPoint := ht.OpenChannel( chanPoint := ht.OpenChannel(
ht.Alice, ht.Bob, lntest.OpenChannelParams{Amt: 1000000}, alice, bob, lntest.OpenChannelParams{Amt: 1000000},
) )
// Check that Alice's custom feature bit was sent to Bob in her init // Check that Alice's custom feature bit was sent to Bob in her init
// message. // message.
peers := ht.Bob.RPC.ListPeers() peers := bob.RPC.ListPeers()
require.Len(ht, peers.Peers, 1) require.Len(ht, peers.Peers, 1)
require.Equal(ht, peers.Peers[0].PubKey, ht.Alice.PubKeyStr) require.Equal(ht, peers.Peers[0].PubKey, alice.PubKeyStr)
_, customInitSet := peers.Peers[0].Features[customInit] _, customInitSet := peers.Peers[0].Features[customInit]
require.True(ht, customInitSet) require.True(ht, customInitSet)
@@ -51,7 +53,7 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
// Assert that Alice's custom feature bit is contained in the node // Assert that Alice's custom feature bit is contained in the node
// announcement sent to Bob. // announcement sent to Bob.
updates := ht.AssertNumNodeAnns(ht.Bob, ht.Alice.PubKeyStr, 1) updates := ht.AssertNumNodeAnns(bob, alice.PubKeyStr, 1)
features := updates[len(updates)-1].Features features := updates[len(updates)-1].Features
_, customFeature := features[customNodeAnn] _, customFeature := features[customNodeAnn]
require.True(ht, customFeature) require.True(ht, customFeature)
@@ -60,8 +62,8 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
) )
// Assert that Alice's custom feature bit is included in invoices. // Assert that Alice's custom feature bit is included in invoices.
invoice := ht.Alice.RPC.AddInvoice(&lnrpc.Invoice{}) invoice := alice.RPC.AddInvoice(&lnrpc.Invoice{})
payReq := ht.Alice.RPC.DecodePayReq(invoice.PaymentRequest) payReq := alice.RPC.DecodePayReq(invoice.PaymentRequest)
_, customInvoiceSet := payReq.Features[customInvoice] _, customInvoiceSet := payReq.Features[customInvoice]
require.True(ht, customInvoiceSet) require.True(ht, customInvoiceSet)
assertFeatureNotInSet( assertFeatureNotInSet(
@@ -79,9 +81,9 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
}, },
}, },
} }
ht.Alice.RPC.UpdateNodeAnnouncementErr(nodeAnnReq) alice.RPC.UpdateNodeAnnouncementErr(nodeAnnReq)
ht.CloseChannel(ht.Alice, chanPoint) ht.CloseChannel(alice, chanPoint)
} }
// assertFeatureNotInSet checks that the features provided aren't contained in // assertFeatureNotInSet checks that the features provided aren't contained in
+1 -1
View File
@@ -109,7 +109,7 @@ func testEstimateRouteFee(ht *lntest.HarnessTest) {
}, },
) )
bobsPrivChannels := ht.Bob.RPC.ListChannels(&lnrpc.ListChannelsRequest{ bobsPrivChannels := mts.bob.RPC.ListChannels(&lnrpc.ListChannelsRequest{
PrivateOnly: true, PrivateOnly: true,
}) })
require.Len(ht, bobsPrivChannels.Channels, 1) require.Len(ht, bobsPrivChannels.Channels, 1)
+4 -2
View File
@@ -402,14 +402,16 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
// testChannelFundingInputTypes tests that any type of supported input type can // testChannelFundingInputTypes tests that any type of supported input type can
// be used to fund channels. // be used to fund channels.
func testChannelFundingInputTypes(ht *lntest.HarnessTest) { func testChannelFundingInputTypes(ht *lntest.HarnessTest) {
alice := ht.Alice
// We'll start off by creating a node for Carol. // We'll start off by creating a node for Carol.
carol := ht.NewNode("Carol", nil) carol := ht.NewNode("Carol", nil)
// Now, we'll connect her to Alice so that they can open a // Now, we'll connect her to Alice so that they can open a
// channel together. // channel together.
ht.ConnectNodes(carol, ht.Alice) ht.ConnectNodes(carol, alice)
runChannelFundingInputTypes(ht, ht.Alice, carol) runChannelFundingInputTypes(ht, alice, carol)
} }
// runChannelFundingInputTypes tests that any type of supported input type can // runChannelFundingInputTypes tests that any type of supported input type can
+3 -1
View File
@@ -763,6 +763,8 @@ func testAbandonChannel(ht *lntest.HarnessTest) {
// testSendAllCoins tests that we're able to properly sweep all coins from the // testSendAllCoins tests that we're able to properly sweep all coins from the
// wallet into a single target address at the specified fee rate. // wallet into a single target address at the specified fee rate.
func testSendAllCoins(ht *lntest.HarnessTest) { func testSendAllCoins(ht *lntest.HarnessTest) {
alice := ht.Alice
// First, we'll make a new node, Ainz who'll we'll use to test wallet // First, we'll make a new node, Ainz who'll we'll use to test wallet
// sweeping. // sweeping.
// //
@@ -789,7 +791,7 @@ func testSendAllCoins(ht *lntest.HarnessTest) {
// Ensure that we can't send coins to another user's Pubkey. // Ensure that we can't send coins to another user's Pubkey.
err = ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{ err = ainz.RPC.SendCoinsAssertErr(&lnrpc.SendCoinsRequest{
Addr: ht.Alice.RPC.GetInfo().IdentityPubkey, Addr: alice.RPC.GetInfo().IdentityPubkey,
SendAll: true, SendAll: true,
Label: sendCoinsLabel, Label: sendCoinsLabel,
TargetConf: 6, TargetConf: 6,
+5 -3
View File
@@ -13,8 +13,10 @@ func testNeutrino(ht *lntest.HarnessTest) {
ht.Skipf("skipping test for non neutrino backends") ht.Skipf("skipping test for non neutrino backends")
} }
alice := ht.Alice
// Check if the neutrino sub server is running. // Check if the neutrino sub server is running.
statusRes := ht.Alice.RPC.Status(nil) statusRes := alice.RPC.Status(nil)
require.True(ht, statusRes.Active) require.True(ht, statusRes.Active)
require.Len(ht, statusRes.Peers, 1, "unable to find a peer") require.Len(ht, statusRes.Peers, 1, "unable to find a peer")
@@ -22,11 +24,11 @@ func testNeutrino(ht *lntest.HarnessTest) {
cFilterReq := &neutrinorpc.GetCFilterRequest{ cFilterReq := &neutrinorpc.GetCFilterRequest{
Hash: statusRes.GetBlockHash(), Hash: statusRes.GetBlockHash(),
} }
ht.Alice.RPC.GetCFilter(cFilterReq) alice.RPC.GetCFilter(cFilterReq)
// Try to reconnect to a connected peer. // Try to reconnect to a connected peer.
addPeerReq := &neutrinorpc.AddPeerRequest{ addPeerReq := &neutrinorpc.AddPeerRequest{
PeerAddrs: statusRes.Peers[0], PeerAddrs: statusRes.Peers[0],
} }
ht.Alice.RPC.AddPeer(addPeerReq) alice.RPC.AddPeer(addPeerReq)
} }
+13 -7
View File
@@ -33,8 +33,10 @@ func testChainKit(ht *lntest.HarnessTest) {
// testChainKitGetBlock ensures that given a block hash, the RPC endpoint // testChainKitGetBlock ensures that given a block hash, the RPC endpoint
// returns the correct target block. // returns the correct target block.
func testChainKitGetBlock(ht *lntest.HarnessTest) { func testChainKitGetBlock(ht *lntest.HarnessTest) {
alice := ht.Alice
// Get best block hash. // Get best block hash.
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
var bestBlockHash chainhash.Hash var bestBlockHash chainhash.Hash
err := bestBlockHash.SetBytes(bestBlockRes.BlockHash) err := bestBlockHash.SetBytes(bestBlockRes.BlockHash)
@@ -44,7 +46,7 @@ func testChainKitGetBlock(ht *lntest.HarnessTest) {
getBlockReq := &chainrpc.GetBlockRequest{ getBlockReq := &chainrpc.GetBlockRequest{
BlockHash: bestBlockHash[:], BlockHash: bestBlockHash[:],
} }
getBlockRes := ht.Alice.RPC.GetBlock(getBlockReq) getBlockRes := alice.RPC.GetBlock(getBlockReq)
// Deserialize the block which was retrieved by hash. // Deserialize the block which was retrieved by hash.
msgBlock := &wire.MsgBlock{} msgBlock := &wire.MsgBlock{}
@@ -61,8 +63,10 @@ func testChainKitGetBlock(ht *lntest.HarnessTest) {
// testChainKitGetBlockHeader ensures that given a block hash, the RPC endpoint // testChainKitGetBlockHeader ensures that given a block hash, the RPC endpoint
// returns the correct target block header. // returns the correct target block header.
func testChainKitGetBlockHeader(ht *lntest.HarnessTest) { func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
alice := ht.Alice
// Get best block hash. // Get best block hash.
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
var ( var (
bestBlockHash chainhash.Hash bestBlockHash chainhash.Hash
@@ -76,7 +80,7 @@ func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
getBlockReq := &chainrpc.GetBlockRequest{ getBlockReq := &chainrpc.GetBlockRequest{
BlockHash: bestBlockHash[:], BlockHash: bestBlockHash[:],
} }
getBlockRes := ht.Alice.RPC.GetBlock(getBlockReq) getBlockRes := alice.RPC.GetBlock(getBlockReq)
// Deserialize the block which was retrieved by hash. // Deserialize the block which was retrieved by hash.
blockReader := bytes.NewReader(getBlockRes.RawBlock) blockReader := bytes.NewReader(getBlockRes.RawBlock)
@@ -87,7 +91,7 @@ func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
getBlockHeaderReq := &chainrpc.GetBlockHeaderRequest{ getBlockHeaderReq := &chainrpc.GetBlockHeaderRequest{
BlockHash: bestBlockHash[:], BlockHash: bestBlockHash[:],
} }
getBlockHeaderRes := ht.Alice.RPC.GetBlockHeader(getBlockHeaderReq) getBlockHeaderRes := alice.RPC.GetBlockHeader(getBlockHeaderReq)
// Deserialize the block header which was retrieved by hash. // Deserialize the block header which was retrieved by hash.
blockHeaderReader := bytes.NewReader(getBlockHeaderRes.RawBlockHeader) blockHeaderReader := bytes.NewReader(getBlockHeaderRes.RawBlockHeader)
@@ -104,14 +108,16 @@ func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
// testChainKitGetBlockHash ensures that given a block height, the RPC endpoint // testChainKitGetBlockHash ensures that given a block height, the RPC endpoint
// returns the correct target block hash. // returns the correct target block hash.
func testChainKitGetBlockHash(ht *lntest.HarnessTest) { func testChainKitGetBlockHash(ht *lntest.HarnessTest) {
alice := ht.Alice
// Get best block hash. // Get best block hash.
bestBlockRes := ht.Alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
// Retrieve the block hash at best block height. // Retrieve the block hash at best block height.
req := &chainrpc.GetBlockHashRequest{ req := &chainrpc.GetBlockHashRequest{
BlockHeight: int64(bestBlockRes.BlockHeight), BlockHeight: int64(bestBlockRes.BlockHeight),
} }
getBlockHashRes := ht.Alice.RPC.GetBlockHash(req) getBlockHashRes := alice.RPC.GetBlockHash(req)
// Ensure best block hash is the same as retrieved block hash. // Ensure best block hash is the same as retrieved block hash.
expected := bestBlockRes.BlockHash expected := bestBlockRes.BlockHash
+3 -1
View File
@@ -315,7 +315,9 @@ func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
// closing, and ensures that if a node is subscribed to channel updates they // closing, and ensures that if a node is subscribed to channel updates they
// will be received correctly for both cooperative and force closed channels. // will be received correctly for both cooperative and force closed channels.
func testBasicChannelCreationAndUpdates(ht *lntest.HarnessTest) { func testBasicChannelCreationAndUpdates(ht *lntest.HarnessTest) {
runBasicChannelCreationAndUpdates(ht, ht.Alice, ht.Bob) alice, bob := ht.Alice, ht.Bob
runBasicChannelCreationAndUpdates(ht, alice, bob)
} }
// runBasicChannelCreationAndUpdates tests multiple channel opening and closing, // runBasicChannelCreationAndUpdates tests multiple channel opening and closing,
+22 -19
View File
@@ -1088,6 +1088,8 @@ func runFundAndSignPsbt(ht *lntest.HarnessTest, alice *node.HarnessNode) {
// a PSBT that already specifies an input but where the user still wants the // a PSBT that already specifies an input but where the user still wants the
// wallet to perform coin selection. // wallet to perform coin selection.
func testFundPsbt(ht *lntest.HarnessTest) { func testFundPsbt(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// We test a pay-join between Alice and Bob. Bob wants to send Alice // We test a pay-join between Alice and Bob. Bob wants to send Alice
// 5 million Satoshis in a non-obvious way. So Bob selects a UTXO that's // 5 million Satoshis in a non-obvious way. So Bob selects a UTXO that's
// bigger than 5 million Satoshis and expects the change minus the send // bigger than 5 million Satoshis and expects the change minus the send
@@ -1095,20 +1097,20 @@ func testFundPsbt(ht *lntest.HarnessTest) {
// combines her change with the 5 million Satoshis from Bob. With this // combines her change with the 5 million Satoshis from Bob. With this
// Alice ends up paying the fees for a transfer to her. // Alice ends up paying the fees for a transfer to her.
const sendAmount = 5_000_000 const sendAmount = 5_000_000
aliceAddr := ht.Alice.RPC.NewAddress(&lnrpc.NewAddressRequest{ aliceAddr := alice.RPC.NewAddress(&lnrpc.NewAddressRequest{
Type: lnrpc.AddressType_TAPROOT_PUBKEY, Type: lnrpc.AddressType_TAPROOT_PUBKEY,
}) })
bobAddr := ht.Bob.RPC.NewAddress(&lnrpc.NewAddressRequest{ bobAddr := bob.RPC.NewAddress(&lnrpc.NewAddressRequest{
Type: lnrpc.AddressType_TAPROOT_PUBKEY, Type: lnrpc.AddressType_TAPROOT_PUBKEY,
}) })
ht.Alice.UpdateState() alice.UpdateState()
ht.Bob.UpdateState() bob.UpdateState()
aliceStartBalance := ht.Alice.State.Wallet.TotalBalance aliceStartBalance := alice.State.Wallet.TotalBalance
bobStartBalance := ht.Bob.State.Wallet.TotalBalance bobStartBalance := bob.State.Wallet.TotalBalance
var bobUtxo *lnrpc.Utxo var bobUtxo *lnrpc.Utxo
bobUnspent := ht.Bob.RPC.ListUnspent(&walletrpc.ListUnspentRequest{}) bobUnspent := bob.RPC.ListUnspent(&walletrpc.ListUnspentRequest{})
for _, utxo := range bobUnspent.Utxos { for _, utxo := range bobUnspent.Utxos {
if utxo.AmountSat > sendAmount { if utxo.AmountSat > sendAmount {
bobUtxo = utxo bobUtxo = utxo
@@ -1145,7 +1147,7 @@ func testFundPsbt(ht *lntest.HarnessTest) {
require.NoError(ht, err) require.NoError(ht, err)
derivation, trDerivation := getAddressBip32Derivation( derivation, trDerivation := getAddressBip32Derivation(
ht, bobUtxo.Address, ht.Bob, ht, bobUtxo.Address, bob,
) )
bobUtxoPkScript, _ := hex.DecodeString(bobUtxo.PkScript) bobUtxoPkScript, _ := hex.DecodeString(bobUtxo.PkScript)
@@ -1165,31 +1167,31 @@ func testFundPsbt(ht *lntest.HarnessTest) {
// We have the template now. Bob basically funds the 5 million Sats to // We have the template now. Bob basically funds the 5 million Sats to
// send to Alice and Alice now only needs to coin select to pay for the // send to Alice and Alice now only needs to coin select to pay for the
// fees. // fees.
fundedPacket := fundPsbtCoinSelect(ht, ht.Alice, packet, 1) fundedPacket := fundPsbtCoinSelect(ht, alice, packet, 1)
txFee, err := fundedPacket.GetTxFee() txFee, err := fundedPacket.GetTxFee()
require.NoError(ht, err) require.NoError(ht, err)
// We now let Bob sign the transaction. // We now let Bob sign the transaction.
signedPacket := signPacket(ht, ht.Bob, fundedPacket) signedPacket := signPacket(ht, bob, fundedPacket)
// And then Alice, which should give us a fully signed TX. // And then Alice, which should give us a fully signed TX.
signedPacket = signPacket(ht, ht.Alice, signedPacket) signedPacket = signPacket(ht, alice, signedPacket)
// We should be able to finalize the PSBT and extract the final TX now. // We should be able to finalize the PSBT and extract the final TX now.
extractPublishAndMine(ht, ht.Alice, signedPacket) extractPublishAndMine(ht, alice, signedPacket)
// Make sure the new wallet balances are reflected correctly. // Make sure the new wallet balances are reflected correctly.
ht.AssertActiveNodesSynced() ht.AssertActiveNodesSynced()
ht.Alice.UpdateState() alice.UpdateState()
ht.Bob.UpdateState() bob.UpdateState()
require.Equal( require.Equal(
ht, aliceStartBalance+sendAmount-int64(txFee), ht, aliceStartBalance+sendAmount-int64(txFee),
ht.Alice.State.Wallet.TotalBalance, alice.State.Wallet.TotalBalance,
) )
require.Equal( require.Equal(
ht, bobStartBalance-sendAmount, ht, bobStartBalance-sendAmount,
ht.Bob.State.Wallet.TotalBalance, bob.State.Wallet.TotalBalance,
) )
} }
@@ -1596,6 +1598,9 @@ func sendAllCoinsToAddrType(ht *lntest.HarnessTest,
// the channel opening. The psbt funding flow is used to simulate this behavior // the channel opening. The psbt funding flow is used to simulate this behavior
// because we can easily let the remote peer run into the timeout. // because we can easily let the remote peer run into the timeout.
func testPsbtChanFundingFailFlow(ht *lntest.HarnessTest) { func testPsbtChanFundingFailFlow(ht *lntest.HarnessTest) {
alice := ht.Alice
bob := ht.Bob
const chanSize = funding.MaxBtcFundingAmount const chanSize = funding.MaxBtcFundingAmount
// Decrease the timeout window for the remote peer to accelerate the // Decrease the timeout window for the remote peer to accelerate the
@@ -1604,12 +1609,10 @@ func testPsbtChanFundingFailFlow(ht *lntest.HarnessTest) {
"--dev.reservationtimeout=1s", "--dev.reservationtimeout=1s",
"--dev.zombiesweeperinterval=1s", "--dev.zombiesweeperinterval=1s",
} }
ht.RestartNodeWithExtraArgs(ht.Bob, args) ht.RestartNodeWithExtraArgs(bob, args)
// Before we start the test, we'll ensure both sides are connected so // Before we start the test, we'll ensure both sides are connected so
// the funding flow can be properly executed. // the funding flow can be properly executed.
alice := ht.Alice
bob := ht.Bob
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
// At this point, we can begin our PSBT channel funding workflow. We'll // At this point, we can begin our PSBT channel funding workflow. We'll
+2 -2
View File
@@ -30,7 +30,7 @@ func testQuiescence(ht *lntest.HarnessTest) {
require.True(ht, res.Initiator) require.True(ht, res.Initiator)
req := &routerrpc.SendPaymentRequest{ req := &routerrpc.SendPaymentRequest{
Dest: ht.Alice.PubKey[:], Dest: alice.PubKey[:],
Amt: 100, Amt: 100,
PaymentHash: ht.Random32Bytes(), PaymentHash: ht.Random32Bytes(),
FinalCltvDelta: finalCltvDelta, FinalCltvDelta: finalCltvDelta,
@@ -39,7 +39,7 @@ func testQuiescence(ht *lntest.HarnessTest) {
} }
ht.SendPaymentAssertFail( ht.SendPaymentAssertFail(
ht.Bob, req, bob, req,
// This fails with insufficient balance because the bandwidth // This fails with insufficient balance because the bandwidth
// manager reports 0 bandwidth if a link is not eligible for // manager reports 0 bandwidth if a link is not eligible for
// forwarding, which is the case during quiescence. // forwarding, which is the case during quiescence.
+3 -1
View File
@@ -237,6 +237,8 @@ func testRestAPI(ht *lntest.HarnessTest) {
} }
func wsTestCaseSubscription(ht *lntest.HarnessTest) { func wsTestCaseSubscription(ht *lntest.HarnessTest) {
alice := ht.Alice
// Find out the current best block so we can subscribe to the next one. // Find out the current best block so we can subscribe to the next one.
hash, height := ht.GetBestBlock() hash, height := ht.GetBestBlock()
@@ -246,7 +248,7 @@ func wsTestCaseSubscription(ht *lntest.HarnessTest) {
Height: uint32(height), Height: uint32(height),
} }
url := "/v2/chainnotifier/register/blocks" url := "/v2/chainnotifier/register/blocks"
c, err := openWebSocket(ht.Alice, url, "POST", req, nil) c, err := openWebSocket(alice, url, "POST", req, nil)
require.NoError(ht, err, "websocket") require.NoError(ht, err, "websocket")
defer func() { defer func() {
err := c.WriteMessage(websocket.CloseMessage, closeMsg) err := c.WriteMessage(websocket.CloseMessage, closeMsg)
+39 -27
View File
@@ -556,22 +556,24 @@ func (b *blindedForwardTest) drainCarolLiquidity(incoming bool) {
func setupFourHopNetwork(ht *lntest.HarnessTest, func setupFourHopNetwork(ht *lntest.HarnessTest,
carol, dave *node.HarnessNode) []*lnrpc.ChannelPoint { carol, dave *node.HarnessNode) []*lnrpc.ChannelPoint {
alice, bob := ht.Alice, ht.Bob
const chanAmt = btcutil.Amount(100000) const chanAmt = btcutil.Amount(100000)
var networkChans []*lnrpc.ChannelPoint var networkChans []*lnrpc.ChannelPoint
// Open a channel with 100k satoshis between Alice and Bob with Alice // Open a channel with 100k satoshis between Alice and Bob with Alice
// being the sole funder of the channel. // being the sole funder of the channel.
chanPointAlice := ht.OpenChannel( chanPointAlice := ht.OpenChannel(
ht.Alice, ht.Bob, lntest.OpenChannelParams{ alice, bob, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
}, },
) )
networkChans = append(networkChans, chanPointAlice) networkChans = append(networkChans, chanPointAlice)
// Create a channel between bob and carol. // Create a channel between bob and carol.
ht.EnsureConnected(ht.Bob, carol) ht.EnsureConnected(bob, carol)
chanPointBob := ht.OpenChannel( chanPointBob := ht.OpenChannel(
ht.Bob, carol, lntest.OpenChannelParams{ bob, carol, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
}, },
) )
@@ -590,7 +592,7 @@ func setupFourHopNetwork(ht *lntest.HarnessTest,
networkChans = append(networkChans, chanPointCarol) networkChans = append(networkChans, chanPointCarol)
// Wait for all nodes to have seen all channels. // Wait for all nodes to have seen all channels.
nodes := []*node.HarnessNode{ht.Alice, ht.Bob, carol, dave} nodes := []*node.HarnessNode{alice, bob, carol, dave}
for _, chanPoint := range networkChans { for _, chanPoint := range networkChans {
for _, node := range nodes { for _, node := range nodes {
ht.AssertChannelInGraph(node, chanPoint) ht.AssertChannelInGraph(node, chanPoint)
@@ -609,6 +611,8 @@ func setupFourHopNetwork(ht *lntest.HarnessTest,
// path and forward payments in a blinded route and finally, receiving the // path and forward payments in a blinded route and finally, receiving the
// payment. // payment.
func testBlindedRouteInvoices(ht *lntest.HarnessTest) { func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
alice := ht.Alice
ctx, testCase := newBlindedForwardTest(ht) ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup() defer testCase.cleanup()
@@ -634,7 +638,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
}) })
// Now let Alice pay the invoice. // Now let Alice pay the invoice.
ht.CompletePaymentRequests(ht.Alice, []string{invoice.PaymentRequest}) ht.CompletePaymentRequests(alice, []string{invoice.PaymentRequest})
// Let Dave add a blinded invoice. // Let Dave add a blinded invoice.
// Once again let Dave create a blinded invoice. // Once again let Dave create a blinded invoice.
@@ -661,7 +665,7 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
require.EqualValues(ht, path.IntroductionNode, testCase.dave.PubKey[:]) require.EqualValues(ht, path.IntroductionNode, testCase.dave.PubKey[:])
// Now let Alice pay the invoice. // Now let Alice pay the invoice.
ht.CompletePaymentRequests(ht.Alice, []string{invoice.PaymentRequest}) ht.CompletePaymentRequests(alice, []string{invoice.PaymentRequest})
} }
// testReceiverBlindedError tests handling of errors from the receiving node in // testReceiverBlindedError tests handling of errors from the receiving node in
@@ -733,6 +737,8 @@ func testRelayingBlindedError(ht *lntest.HarnessTest) {
// over Alice -- Bob -- Carol -- Dave, where Bob is the introduction node and // over Alice -- Bob -- Carol -- Dave, where Bob is the introduction node and
// has insufficient outgoing liquidity to forward on to carol. // has insufficient outgoing liquidity to forward on to carol.
func testIntroductionNodeError(ht *lntest.HarnessTest) { func testIntroductionNodeError(ht *lntest.HarnessTest) {
bob := ht.Bob
ctx, testCase := newBlindedForwardTest(ht) ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup() defer testCase.cleanup()
testCase.setupNetwork(ctx, false) testCase.setupNetwork(ctx, false)
@@ -746,7 +752,7 @@ func testIntroductionNodeError(ht *lntest.HarnessTest) {
// Subscribe to Bob's HTLC events so that we can observe the payment // Subscribe to Bob's HTLC events so that we can observe the payment
// coming in. // coming in.
bobEvents := ht.Bob.RPC.SubscribeHtlcEvents() bobEvents := bob.RPC.SubscribeHtlcEvents()
// Once subscribed, the first event will be UNKNOWN. // Once subscribed, the first event will be UNKNOWN.
ht.AssertHtlcEventType(bobEvents, routerrpc.HtlcEvent_UNKNOWN) ht.AssertHtlcEventType(bobEvents, routerrpc.HtlcEvent_UNKNOWN)
@@ -764,6 +770,8 @@ func testIntroductionNodeError(ht *lntest.HarnessTest) {
// testDisableIntroductionNode tests disabling of blinded forwards for the // testDisableIntroductionNode tests disabling of blinded forwards for the
// introduction node. // introduction node.
func testDisableIntroductionNode(ht *lntest.HarnessTest) { func testDisableIntroductionNode(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// First construct a blinded route while Bob is still advertising the // First construct a blinded route while Bob is still advertising the
// route blinding feature bit to ensure that Bob is included in the // route blinding feature bit to ensure that Bob is included in the
// blinded path that Dave selects. // blinded path that Dave selects.
@@ -774,10 +782,10 @@ func testDisableIntroductionNode(ht *lntest.HarnessTest) {
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath) route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
// Now, disable route blinding for Bob, then re-connect to Alice. // Now, disable route blinding for Bob, then re-connect to Alice.
ht.RestartNodeWithExtraArgs(ht.Bob, []string{ ht.RestartNodeWithExtraArgs(bob, []string{
"--protocol.no-route-blinding", "--protocol.no-route-blinding",
}) })
ht.EnsureConnected(ht.Alice, ht.Bob) ht.EnsureConnected(alice, bob)
// Assert that this fails. // Assert that this fails.
testCase.sendToRoute(route, false) testCase.sendToRoute(route, false)
@@ -788,6 +796,8 @@ func testDisableIntroductionNode(ht *lntest.HarnessTest) {
// to resolve blinded HTLCs on chain between restarts, as we've got all the // to resolve blinded HTLCs on chain between restarts, as we've got all the
// infrastructure in place already for error testing. // infrastructure in place already for error testing.
func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) { func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// Setup a test case, note that we don't use its built in clean up // Setup a test case, note that we don't use its built in clean up
// because we're going to close a channel, so we'll close out the // because we're going to close a channel, so we'll close out the
// rest manually. // rest manually.
@@ -807,8 +817,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Wait for the HTLC to be active on Alice and Bob's channels. // Wait for the HTLC to be active on Alice and Bob's channels.
hash := sha256.Sum256(testCase.preimage[:]) hash := sha256.Sum256(testCase.preimage[:])
ht.AssertOutgoingHTLCActive(ht.Alice, testCase.channels[0], hash[:]) ht.AssertOutgoingHTLCActive(alice, testCase.channels[0], hash[:])
ht.AssertOutgoingHTLCActive(ht.Bob, testCase.channels[1], hash[:]) ht.AssertOutgoingHTLCActive(bob, testCase.channels[1], hash[:])
// Intercept the forward on Carol's link, but do not take any action // Intercept the forward on Carol's link, but do not take any action
// so that we have the chance to force close with this HTLC in flight. // so that we have the chance to force close with this HTLC in flight.
@@ -817,11 +827,11 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Force close Bob <-> Carol. // Force close Bob <-> Carol.
closeStream, _ := ht.CloseChannelAssertPending( closeStream, _ := ht.CloseChannelAssertPending(
ht.Bob, testCase.channels[1], true, bob, testCase.channels[1], true,
) )
ht.AssertStreamChannelForceClosed( ht.AssertStreamChannelForceClosed(
ht.Bob, testCase.channels[1], false, closeStream, bob, testCase.channels[1], false, closeStream,
) )
// SuspendCarol so that she can't interfere with the resolution of the // SuspendCarol so that she can't interfere with the resolution of the
@@ -831,32 +841,32 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Mine blocks so that Bob will claim his CSV delayed local commitment, // Mine blocks so that Bob will claim his CSV delayed local commitment,
// we've already mined 1 block so we need one less than our CSV. // we've already mined 1 block so we need one less than our CSV.
ht.MineBlocks(node.DefaultCSV - 1) ht.MineBlocks(node.DefaultCSV - 1)
ht.AssertNumPendingSweeps(ht.Bob, 1) ht.AssertNumPendingSweeps(bob, 1)
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
// Restart bob so that we can test that he's able to recover everything // Restart bob so that we can test that he's able to recover everything
// he needs to claim a blinded HTLC. // he needs to claim a blinded HTLC.
ht.RestartNode(ht.Bob) ht.RestartNode(bob)
// Mine enough blocks for Bob to trigger timeout of his outgoing HTLC. // Mine enough blocks for Bob to trigger timeout of his outgoing HTLC.
// Carol's incoming expiry height is Bob's outgoing so we can use this // Carol's incoming expiry height is Bob's outgoing so we can use this
// value. // value.
info := ht.Bob.RPC.GetInfo() info := bob.RPC.GetInfo()
target := carolHTLC.IncomingExpiry - info.BlockHeight target := carolHTLC.IncomingExpiry - info.BlockHeight
ht.MineBlocks(int(target)) ht.MineBlocks(int(target))
// Wait for Bob's timeout transaction in the mempool, since we've // Wait for Bob's timeout transaction in the mempool, since we've
// suspended Carol we don't need to account for her commitment output // suspended Carol we don't need to account for her commitment output
// claim. // claim.
ht.AssertNumPendingSweeps(ht.Bob, 0) ht.AssertNumPendingSweeps(bob, 0)
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
// Assert that the HTLC has cleared. // Assert that the HTLC has cleared.
ht.AssertHTLCNotActive(ht.Bob, testCase.channels[0], hash[:]) ht.AssertHTLCNotActive(bob, testCase.channels[0], hash[:])
ht.AssertHTLCNotActive(ht.Alice, testCase.channels[0], hash[:]) ht.AssertHTLCNotActive(alice, testCase.channels[0], hash[:])
// Wait for the HTLC to reflect as failed for Alice. // Wait for the HTLC to reflect as failed for Alice.
paymentStream := ht.Alice.RPC.TrackPaymentV2(hash[:]) paymentStream := alice.RPC.TrackPaymentV2(hash[:])
htlcs := ht.ReceiveTrackPayment(paymentStream).Htlcs htlcs := ht.ReceiveTrackPayment(paymentStream).Htlcs
require.Len(ht, htlcs, 1) require.Len(ht, htlcs, 1)
require.NotNil(ht, htlcs[0].Failure) require.NotNil(ht, htlcs[0].Failure)
@@ -868,7 +878,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Clean up the rest of our force close: mine blocks so that Bob's CSV // Clean up the rest of our force close: mine blocks so that Bob's CSV
// expires to trigger his sweep and then mine it. // expires to trigger his sweep and then mine it.
ht.MineBlocks(node.DefaultCSV) ht.MineBlocks(node.DefaultCSV)
ht.AssertNumPendingSweeps(ht.Bob, 1) ht.AssertNumPendingSweeps(bob, 1)
ht.MineBlocksAndAssertNumTxes(1, 1) ht.MineBlocksAndAssertNumTxes(1, 1)
// Bring carol back up so that we can close out the rest of our // Bring carol back up so that we can close out the rest of our
@@ -885,7 +895,7 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
// Manually close out the rest of our channels and cancel (don't use // Manually close out the rest of our channels and cancel (don't use
// built in cleanup which will try close the already-force-closed // built in cleanup which will try close the already-force-closed
// channel). // channel).
ht.CloseChannel(ht.Alice, testCase.channels[0]) ht.CloseChannel(alice, testCase.channels[0])
ht.CloseChannel(testCase.carol, testCase.channels[2]) ht.CloseChannel(testCase.carol, testCase.channels[2])
testCase.cancel() testCase.cancel()
} }
@@ -1191,7 +1201,7 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
// Now let Alice pay the invoice. // Now let Alice pay the invoice.
ht.CompletePaymentRequests( ht.CompletePaymentRequests(
ht.Alice, []string{invoiceResp.PaymentRequest}, alice, []string{invoiceResp.PaymentRequest},
) )
// Make sure Dave show the invoice as settled. // Make sure Dave show the invoice as settled.
@@ -1233,7 +1243,7 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
// Now let Alice pay the invoice. // Now let Alice pay the invoice.
ht.CompletePaymentRequests( ht.CompletePaymentRequests(
ht.Alice, []string{invoiceResp.PaymentRequest}, alice, []string{invoiceResp.PaymentRequest},
) )
// Make sure Dave show the invoice as settled. // Make sure Dave show the invoice as settled.
@@ -1430,6 +1440,8 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
// UpdateAddHTLC which we need to ensure gets included in the message on // UpdateAddHTLC which we need to ensure gets included in the message on
// restart. // restart.
func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) { func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// Setup a test case. // Setup a test case.
ctx, testCase := newBlindedForwardTest(ht) ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup() defer testCase.cleanup()
@@ -1464,8 +1476,8 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
}() }()
// Wait for the HTLC to be active on Alice and Bob's channels. // Wait for the HTLC to be active on Alice and Bob's channels.
ht.AssertOutgoingHTLCActive(ht.Alice, testCase.channels[0], hash[:]) ht.AssertOutgoingHTLCActive(alice, testCase.channels[0], hash[:])
ht.AssertOutgoingHTLCActive(ht.Bob, testCase.channels[1], hash[:]) ht.AssertOutgoingHTLCActive(bob, testCase.channels[1], hash[:])
// Intercept the forward on Carol's link. At this point, we know she // Intercept the forward on Carol's link. At this point, we know she
// has received the HTLC and so will persist this packet. // has received the HTLC and so will persist this packet.
@@ -1493,7 +1505,7 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
// Nodes need to be connected otherwise the forwarding of the // Nodes need to be connected otherwise the forwarding of the
// intercepted htlc will fail. // intercepted htlc will fail.
ht.EnsureConnected(ht.Bob, testCase.carol) ht.EnsureConnected(bob, testCase.carol)
ht.EnsureConnected(testCase.carol, testCase.dave) ht.EnsureConnected(testCase.carol, testCase.dave)
// Now that carol and dave are connected signal the forwarding of the // Now that carol and dave are connected signal the forwarding of the
+7 -5
View File
@@ -750,6 +750,8 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
// testScidAliasRoutingHints tests that dynamically created aliases via the RPC // testScidAliasRoutingHints tests that dynamically created aliases via the RPC
// are properly used when routing. // are properly used when routing.
func testScidAliasRoutingHints(ht *lntest.HarnessTest) { func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
bob := ht.Bob
const chanAmt = btcutil.Amount(800000) const chanAmt = btcutil.Amount(800000)
// Option-scid-alias is opt-in, as is anchors. // Option-scid-alias is opt-in, as is anchors.
@@ -866,8 +868,8 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
}) })
// Connect the existing Bob node with Carol via a public channel. // Connect the existing Bob node with Carol via a public channel.
ht.ConnectNodes(ht.Bob, carol) ht.ConnectNodes(bob, carol)
chanPointBC := ht.OpenChannel(ht.Bob, carol, lntest.OpenChannelParams{ chanPointBC := ht.OpenChannel(bob, carol, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
PushAmt: chanAmt / 2, PushAmt: chanAmt / 2,
}) })
@@ -902,7 +904,7 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
// Now Alice will try to pay to that payment request. // Now Alice will try to pay to that payment request.
timeout := time.Second * 15 timeout := time.Second * 15
stream := ht.Bob.RPC.SendPayment(&routerrpc.SendPaymentRequest{ stream := bob.RPC.SendPayment(&routerrpc.SendPaymentRequest{
PaymentRequest: payReq, PaymentRequest: payReq,
TimeoutSeconds: int32(timeout.Seconds()), TimeoutSeconds: int32(timeout.Seconds()),
FeeLimitSat: math.MaxInt64, FeeLimitSat: math.MaxInt64,
@@ -924,7 +926,7 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
AliasMaps: ephemeralAliasMap, AliasMaps: ephemeralAliasMap,
}) })
payReq2 := dave.RPC.AddInvoice(invoice).PaymentRequest payReq2 := dave.RPC.AddInvoice(invoice).PaymentRequest
stream2 := ht.Bob.RPC.SendPayment(&routerrpc.SendPaymentRequest{ stream2 := bob.RPC.SendPayment(&routerrpc.SendPaymentRequest{
PaymentRequest: payReq2, PaymentRequest: payReq2,
TimeoutSeconds: int32(timeout.Seconds()), TimeoutSeconds: int32(timeout.Seconds()),
FeeLimitSat: math.MaxInt64, FeeLimitSat: math.MaxInt64,
@@ -932,7 +934,7 @@ func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
ht.AssertPaymentStatusFromStream(stream2, lnrpc.Payment_FAILED) ht.AssertPaymentStatusFromStream(stream2, lnrpc.Payment_FAILED)
ht.CloseChannel(carol, chanPointCD) ht.CloseChannel(carol, chanPointCD)
ht.CloseChannel(ht.Bob, chanPointBC) ht.CloseChannel(bob, chanPointBC)
} }
// testMultiHopOverPrivateChannels tests that private channels can be used as // testMultiHopOverPrivateChannels tests that private channels can be used as
+9 -3
View File
@@ -25,7 +25,9 @@ import (
// the node's pubkey and a customized public key to check the validity of the // the node's pubkey and a customized public key to check the validity of the
// result. // result.
func testDeriveSharedKey(ht *lntest.HarnessTest) { func testDeriveSharedKey(ht *lntest.HarnessTest) {
runDeriveSharedKey(ht, ht.Alice) alice := ht.Alice
runDeriveSharedKey(ht, alice)
} }
// runDeriveSharedKey checks the ECDH performed by the endpoint // runDeriveSharedKey checks the ECDH performed by the endpoint
@@ -197,7 +199,9 @@ func runDeriveSharedKey(ht *lntest.HarnessTest, alice *node.HarnessNode) {
// testSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all // testSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
// custom ways of specifying the signing key in the key descriptor/locator. // custom ways of specifying the signing key in the key descriptor/locator.
func testSignOutputRaw(ht *lntest.HarnessTest) { func testSignOutputRaw(ht *lntest.HarnessTest) {
runSignOutputRaw(ht, ht.Alice) alice := ht.Alice
runSignOutputRaw(ht, alice)
} }
// runSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all // runSignOutputRaw makes sure that the SignOutputRaw RPC can be used with all
@@ -377,7 +381,9 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and // all custom flags by verifying with VerifyMessage. Tests both ECDSA and
// Schnorr signatures. // Schnorr signatures.
func testSignVerifyMessage(ht *lntest.HarnessTest) { func testSignVerifyMessage(ht *lntest.HarnessTest) {
runSignVerifyMessage(ht, ht.Alice) alice := ht.Alice
runSignVerifyMessage(ht, alice)
} }
// runSignVerifyMessage makes sure that the SignMessage RPC can be used with // runSignVerifyMessage makes sure that the SignMessage RPC can be used with
+3 -1
View File
@@ -1558,7 +1558,9 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// CPFP, then RBF. Along the way, we check the `BumpFee` can properly update // CPFP, then RBF. Along the way, we check the `BumpFee` can properly update
// the fee function used by supplying new params. // the fee function used by supplying new params.
func testBumpFee(ht *lntest.HarnessTest) { func testBumpFee(ht *lntest.HarnessTest) {
runBumpFee(ht, ht.Alice) alice := ht.Alice
runBumpFee(ht, alice)
} }
// runBumpFee checks the `BumpFee` RPC can properly bump the fee of a given // runBumpFee checks the `BumpFee` RPC can properly bump the fee of a given
+18 -16
View File
@@ -49,34 +49,36 @@ var (
// testTaproot ensures that the daemon can send to and spend from taproot (p2tr) // testTaproot ensures that the daemon can send to and spend from taproot (p2tr)
// outputs. // outputs.
func testTaproot(ht *lntest.HarnessTest) { func testTaproot(ht *lntest.HarnessTest) {
testTaprootSendCoinsKeySpendBip86(ht, ht.Alice) alice := ht.Alice
testTaprootComputeInputScriptKeySpendBip86(ht, ht.Alice)
testTaprootSignOutputRawScriptSpend(ht, ht.Alice) testTaprootSendCoinsKeySpendBip86(ht, alice)
testTaprootComputeInputScriptKeySpendBip86(ht, alice)
testTaprootSignOutputRawScriptSpend(ht, alice)
testTaprootSignOutputRawScriptSpend( testTaprootSignOutputRawScriptSpend(
ht, ht.Alice, txscript.SigHashSingle, ht, alice, txscript.SigHashSingle,
) )
testTaprootSignOutputRawKeySpendBip86(ht, ht.Alice) testTaprootSignOutputRawKeySpendBip86(ht, alice)
testTaprootSignOutputRawKeySpendBip86( testTaprootSignOutputRawKeySpendBip86(
ht, ht.Alice, txscript.SigHashSingle, ht, alice, txscript.SigHashSingle,
) )
testTaprootSignOutputRawKeySpendRootHash(ht, ht.Alice) testTaprootSignOutputRawKeySpendRootHash(ht, alice)
muSig2Versions := []signrpc.MuSig2Version{ muSig2Versions := []signrpc.MuSig2Version{
signrpc.MuSig2Version_MUSIG2_VERSION_V040, signrpc.MuSig2Version_MUSIG2_VERSION_V040,
signrpc.MuSig2Version_MUSIG2_VERSION_V100RC2, signrpc.MuSig2Version_MUSIG2_VERSION_V100RC2,
} }
for _, version := range muSig2Versions { for _, version := range muSig2Versions {
testTaprootMuSig2KeySpendBip86(ht, ht.Alice, version) testTaprootMuSig2KeySpendBip86(ht, alice, version)
testTaprootMuSig2KeySpendRootHash(ht, ht.Alice, version) testTaprootMuSig2KeySpendRootHash(ht, alice, version)
testTaprootMuSig2ScriptSpend(ht, ht.Alice, version) testTaprootMuSig2ScriptSpend(ht, alice, version)
testTaprootMuSig2CombinedLeafKeySpend(ht, ht.Alice, version) testTaprootMuSig2CombinedLeafKeySpend(ht, alice, version)
testMuSig2CombineKey(ht, ht.Alice, version) testMuSig2CombineKey(ht, alice, version)
} }
testTaprootImportTapscriptFullTree(ht, ht.Alice) testTaprootImportTapscriptFullTree(ht, alice)
testTaprootImportTapscriptPartialReveal(ht, ht.Alice) testTaprootImportTapscriptPartialReveal(ht, alice)
testTaprootImportTapscriptRootHashOnly(ht, ht.Alice) testTaprootImportTapscriptRootHashOnly(ht, alice)
testTaprootImportTapscriptFullKey(ht, ht.Alice) testTaprootImportTapscriptFullKey(ht, alice)
} }
// testTaprootSendCoinsKeySpendBip86 tests sending to and spending from // testTaprootSendCoinsKeySpendBip86 tests sending to and spending from
+13 -9
View File
@@ -39,6 +39,8 @@ var watchtowerTestCases = []*lntest.TestCase{
// testTowerClientTowerAndSessionManagement tests the various control commands // testTowerClientTowerAndSessionManagement tests the various control commands
// that a user has over the client's set of active towers and sessions. // that a user has over the client's set of active towers and sessions.
func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) { func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
alice := ht.Alice
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
externalIP = "1.2.3.4" externalIP = "1.2.3.4"
@@ -104,13 +106,13 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave) ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
// Connect Dave and Alice. // Connect Dave and Alice.
ht.ConnectNodes(dave, ht.Alice) ht.ConnectNodes(dave, alice)
// Open a channel between Dave and Alice. // Open a channel between Dave and Alice.
params := lntest.OpenChannelParams{ params := lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
} }
chanPoint := ht.OpenChannel(dave, ht.Alice, params) chanPoint := ht.OpenChannel(dave, alice, params)
// Show that the Wallis tower is currently seen as an active session // Show that the Wallis tower is currently seen as an active session
// candidate. // candidate.
@@ -122,7 +124,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
// Make some back-ups and assert that they are added to a session with // Make some back-ups and assert that they are added to a session with
// the tower. // the tower.
generateBackups(ht, dave, ht.Alice, 4) generateBackups(ht, dave, alice, 4)
// Assert that one of the sessions now has 4 backups. // Assert that one of the sessions now has 4 backups.
assertNumBackups(ht, dave.RPC, wallisPk, 4, false) assertNumBackups(ht, dave.RPC, wallisPk, 4, false)
@@ -139,7 +141,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
require.False(ht, info.SessionInfo[0].ActiveSessionCandidate) require.False(ht, info.SessionInfo[0].ActiveSessionCandidate)
// Back up a few more states. // Back up a few more states.
generateBackups(ht, dave, ht.Alice, 4) generateBackups(ht, dave, alice, 4)
// These should _not_ be on the tower. Therefore, the number of // These should _not_ be on the tower. Therefore, the number of
// back-ups on the tower should be the same as before. // back-ups on the tower should be the same as before.
@@ -163,7 +165,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
}) })
// Generate some more back-ups. // Generate some more back-ups.
generateBackups(ht, dave, ht.Alice, 4) generateBackups(ht, dave, alice, 4)
// Assert that they get added to the first tower (Wallis) and that the // Assert that they get added to the first tower (Wallis) and that the
// number of sessions with Wallis has not changed - in other words, the // number of sessions with Wallis has not changed - in other words, the
@@ -205,7 +207,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
assertNumSessions(wallisPk, 4, false) assertNumSessions(wallisPk, 4, false)
// Any new back-ups should now be backed up on a different session. // Any new back-ups should now be backed up on a different session.
generateBackups(ht, dave, ht.Alice, 2) generateBackups(ht, dave, alice, 2)
assertNumBackups(ht, dave.RPC, wallisPk, 10, false) assertNumBackups(ht, dave.RPC, wallisPk, 10, false)
findSession(wallisPk, 2) findSession(wallisPk, 2)
@@ -238,6 +240,8 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
// testTowerClientSessionDeletion tests that sessions are correctly deleted // testTowerClientSessionDeletion tests that sessions are correctly deleted
// when they are deemed closable. // when they are deemed closable.
func testTowerClientSessionDeletion(ht *lntest.HarnessTest) { func testTowerClientSessionDeletion(ht *lntest.HarnessTest) {
alice := ht.Alice
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
numInvoices = 5 numInvoices = 5
@@ -290,18 +294,18 @@ func testTowerClientSessionDeletion(ht *lntest.HarnessTest) {
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave) ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
// Connect Dave and Alice. // Connect Dave and Alice.
ht.ConnectNodes(dave, ht.Alice) ht.ConnectNodes(dave, alice)
// Open a channel between Dave and Alice. // Open a channel between Dave and Alice.
params := lntest.OpenChannelParams{ params := lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
} }
chanPoint := ht.OpenChannel(dave, ht.Alice, params) chanPoint := ht.OpenChannel(dave, alice, params)
// Since there are 2 updates made for every payment and the maximum // Since there are 2 updates made for every payment and the maximum
// number of updates per session has been set to 10, make 5 payments // number of updates per session has been set to 10, make 5 payments
// between the pair so that the session is exhausted. // between the pair so that the session is exhausted.
generateBackups(ht, dave, ht.Alice, maxUpdates) generateBackups(ht, dave, alice, maxUpdates)
// Assert that one of the sessions now has 10 backups. // Assert that one of the sessions now has 10 backups.
assertNumBackups(ht, dave.RPC, wallisPk, 10, false) assertNumBackups(ht, dave.RPC, wallisPk, 10, false)