itest: remove the use of standby nodes

This commit removes the usage of the standby nodes and uses
`CreateSimpleNetwork` when applicable. Also introduces a helper method
`NewNodeWithCoins` to quickly start a node with funds.
This commit is contained in:
yyforyongyu committed 2024-12-20 19:38:05 +08:00
1 parent 3eda87fff9
commit de8f14bed2
44 files changed
+321 -250

No files matched your search

+2 -2
View File
@@ -844,7 +844,7 @@ func runChanRestoreScenarioForceClose(ht *lntest.HarnessTest, zeroConf bool) {
// and the on-disk channel.backup are updated each time a channel is // and the on-disk channel.backup are updated each time a channel is
// opened/closed. // opened/closed.
func testChannelBackupUpdates(ht *lntest.HarnessTest) { func testChannelBackupUpdates(ht *lntest.HarnessTest) {
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
// First, we'll make a temp directory that we'll use to store our // First, we'll make a temp directory that we'll use to store our
// backup file, so we can check in on it during the test easily. // backup file, so we can check in on it during the test easily.
@@ -1052,7 +1052,7 @@ func testExportChannelBackup(ht *lntest.HarnessTest) {
// With Carol up, we'll now connect her to Alice, and open a channel // With Carol up, we'll now connect her to Alice, and open a channel
// between them. // between them.
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(carol, alice) ht.ConnectNodes(carol, alice)
// Next, we'll open two channels between Alice and Carol back to back. // Next, we'll open two channels between Alice and Carol back to back.
+3 -2
View File
@@ -48,7 +48,8 @@ func testChannelBalance(ht *lntest.HarnessTest) {
} }
// Before beginning, make sure alice and bob are connected. // Before beginning, make sure alice and bob are connected.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
chanPoint := ht.OpenChannel( chanPoint := ht.OpenChannel(
@@ -118,7 +119,7 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := ht.NewNode("Carol", []string{"--hodl.exit-settle"})
// Connect Alice to Carol. // Connect Alice to Carol.
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol) ht.ConnectNodes(alice, carol)
// Open a channel between Alice and Carol. // Open a channel between Alice and Carol.
+1 -1
View File
@@ -771,7 +771,7 @@ func testFailingChannel(ht *lntest.HarnessTest) {
// totally unrelated preimage. // totally unrelated preimage.
carol := ht.NewNode("Carol", []string{"--hodl.bogus-settle"}) carol := ht.NewNode("Carol", []string{"--hodl.bogus-settle"})
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol) ht.ConnectNodes(alice, carol)
// Let Alice connect and open a channel to Carol, // Let Alice connect and open a channel to Carol,
+11 -10
View File
@@ -218,7 +218,9 @@ func testUpdateChanStatus(ht *lntest.HarnessTest) {
// describeGraph RPC request unless explicitly asked for. // describeGraph RPC request unless explicitly asked for.
func testUnannouncedChannels(ht *lntest.HarnessTest) { func testUnannouncedChannels(ht *lntest.HarnessTest) {
amount := funding.MaxBtcFundingAmount amount := funding.MaxBtcFundingAmount
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
// Open a channel between Alice and Bob, ensuring the // Open a channel between Alice and Bob, ensuring the
// channel has been opened properly. // channel has been opened properly.
@@ -267,14 +269,10 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
// Spin up Bob first, since we will need to grab his pubkey when // Spin up Bob first, since we will need to grab his pubkey when
// starting Alice to test pinned syncing. // starting Alice to test pinned syncing.
bob := ht.Bob bob := ht.NewNodeWithCoins("Bob", nil)
bobInfo := bob.RPC.GetInfo() bobInfo := bob.RPC.GetInfo()
bobPubkey := bobInfo.IdentityPubkey bobPubkey := bobInfo.IdentityPubkey
// Restart Bob as he may have leftover announcements from previous
// tests, causing the graph to be unsynced.
ht.RestartNodeWithExtraArgs(bob, nil)
// For unpinned syncing, start Alice as usual. Otherwise grab Bob's // For unpinned syncing, start Alice as usual. Otherwise grab Bob's
// pubkey to include in his pinned syncer set. // pubkey to include in his pinned syncer set.
var aliceArgs []string var aliceArgs []string
@@ -285,8 +283,7 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
} }
} }
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", aliceArgs)
ht.RestartNodeWithExtraArgs(alice, aliceArgs)
// Connect Alice and Bob. // Connect Alice and Bob.
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
@@ -379,7 +376,9 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
// external IP addresses specified on the command line, that those addresses // external IP addresses specified on the command line, that those addresses
// announced to the network and reported in the network graph. // announced to the network and reported in the network graph.
func testNodeAnnouncement(ht *lntest.HarnessTest) { func testNodeAnnouncement(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNode("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
advertisedAddrs := []string{ advertisedAddrs := []string{
"192.168.1.1:8333", "192.168.1.1:8333",
@@ -434,7 +433,9 @@ func testNodeAnnouncement(ht *lntest.HarnessTest) {
// the requests correctly and that the new node announcement is broadcast // the requests correctly and that the new node announcement is broadcast
// with the right information after updating our node. // with the right information after updating our node.
func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) { func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNode("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
var lndArgs []string var lndArgs []string
+13 -15
View File
@@ -30,19 +30,16 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
chanAmt := funding.MaxBtcFundingAmount chanAmt := funding.MaxBtcFundingAmount
pushAmt := chanAmt / 2 pushAmt := chanAmt / 2
alice, bob := ht.Alice, ht.Bob
// Create a channel Alice->Bob. // Create a channel Alice->Bob.
chanPoint := ht.OpenChannel( chanPoints, nodes := ht.CreateSimpleNetwork(
alice, bob, lntest.OpenChannelParams{ [][]string{nil, nil}, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
PushAmt: pushAmt, PushAmt: pushAmt,
}, },
) )
// We add all the nodes' update channels to a slice, such that we can alice, bob := nodes[0], nodes[1]
// make sure they all receive the expected updates. chanPoint := chanPoints[0]
nodes := []*node.HarnessNode{alice, bob}
// Alice and Bob should see each other's ChannelUpdates, advertising the // Alice and Bob should see each other's ChannelUpdates, advertising the
// default routing policies. We do not currently set any inbound fees. // default routing policies. We do not currently set any inbound fees.
@@ -441,7 +438,8 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
func testSendUpdateDisableChannel(ht *lntest.HarnessTest) { func testSendUpdateDisableChannel(ht *lntest.HarnessTest) {
const chanAmt = 100000 const chanAmt = 100000
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
// Create a new node Eve, which will be restarted later with a config // Create a new node Eve, which will be restarted later with a config
// that has an inactive channel timeout of just 6 seconds (down from // that has an inactive channel timeout of just 6 seconds (down from
@@ -678,7 +676,9 @@ func testUpdateChannelPolicyForPrivateChannel(ht *lntest.HarnessTest) {
// We'll create the following topology first, // We'll create the following topology first,
// Alice <--public:100k--> Bob <--private:100k--> Carol // Alice <--public:100k--> Bob <--private:100k--> Carol
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// Open a channel with 100k satoshis between Alice and Bob. // Open a channel with 100k satoshis between Alice and Bob.
chanPointAliceBob := ht.OpenChannel( chanPointAliceBob := ht.OpenChannel(
@@ -787,16 +787,14 @@ func testUpdateChannelPolicyFeeRateAccuracy(ht *lntest.HarnessTest) {
pushAmt := chanAmt / 2 pushAmt := chanAmt / 2
// Create a channel Alice -> Bob. // Create a channel Alice -> Bob.
alice, bob := ht.Alice, ht.Bob chanPoints, nodes := ht.CreateSimpleNetwork(
chanPoint := ht.OpenChannel( [][]string{nil, nil}, lntest.OpenChannelParams{
alice, bob, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
PushAmt: pushAmt, PushAmt: pushAmt,
}, },
) )
alice := nodes[0]
// Nodes that we need to make sure receive the channel updates. chanPoint := chanPoints[0]
nodes := []*node.HarnessNode{alice, bob}
baseFee := int64(1500) baseFee := int64(1500)
timeLockDelta := uint32(66) timeLockDelta := uint32(66)
@@ -58,7 +58,8 @@ func testCoopCloseWithExternalDelivery(ht *lntest.HarnessTest) {
func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest, func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
upfrontShutdown bool, deliveryAddressType lnrpc.AddressType) { upfrontShutdown bool, deliveryAddressType lnrpc.AddressType) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
ht.ConnectNodes(alice, bob) ht.ConnectNodes(alice, bob)
// Here we generate a final delivery address in bob's wallet but set by // Here we generate a final delivery address in bob's wallet but set by
+4 -2
View File
@@ -37,7 +37,8 @@ func testCoopCloseWithHtlcs(ht *lntest.HarnessTest) {
// channel party initiates a channel shutdown while an HTLC is still pending on // channel party initiates a channel shutdown while an HTLC is still pending on
// the channel. // the channel.
func coopCloseWithHTLCs(ht *lntest.HarnessTest) { func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
ht.ConnectNodes(alice, bob) ht.ConnectNodes(alice, bob)
// Here we set up a channel between Alice and Bob, beginning with a // Here we set up a channel between Alice and Bob, beginning with a
@@ -128,7 +129,8 @@ func coopCloseWithHTLCs(ht *lntest.HarnessTest) {
// process continues as expected even if a channel re-establish happens after // process continues as expected even if a channel re-establish happens after
// one party has already initiated the shutdown. // one party has already initiated the shutdown.
func coopCloseWithHTLCsWithRestart(ht *lntest.HarnessTest) { func coopCloseWithHTLCsWithRestart(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
ht.ConnectNodes(alice, bob) ht.ConnectNodes(alice, bob)
// Open a channel between Alice and Bob with the balance split equally. // Open a channel between Alice and Bob with the balance split equally.
+5 -8
View File
@@ -13,8 +13,6 @@ 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.
@@ -29,14 +27,13 @@ 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(alice, extraArgs) cfgs := [][]string{extraArgs, nil}
// Connect nodes and open a channel so that Alice will be included chanPoints, nodes := ht.CreateSimpleNetwork(
// in Bob's graph. cfgs, lntest.OpenChannelParams{Amt: 1000000},
ht.ConnectNodes(alice, bob)
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: 1000000},
) )
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// 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.
+2 -3
View File
@@ -14,8 +14,6 @@ import (
// types (within the message type range usually reserved for protocol messages) // types (within the message type range usually reserved for protocol messages)
// via the send and subscribe custom message APIs. // via the send and subscribe custom message APIs.
func testCustomMessage(ht *lntest.HarnessTest) { func testCustomMessage(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
var ( var (
overrideType1 uint32 = 554 overrideType1 uint32 = 554
overrideType2 uint32 = 555 overrideType2 uint32 = 555
@@ -27,7 +25,8 @@ func testCustomMessage(ht *lntest.HarnessTest) {
extraArgs := []string{ extraArgs := []string{
fmt.Sprintf(msgOverrideArg, overrideType1), fmt.Sprintf(msgOverrideArg, overrideType1),
} }
ht.RestartNodeWithExtraArgs(alice, extraArgs) alice := ht.NewNode("Alice", extraArgs)
bob := ht.NewNode("Bob", nil)
// Subscribe Alice to custom messages before we send any, so that we // Subscribe Alice to custom messages before we send any, so that we
// don't miss any. // don't miss any.
+2 -1
View File
@@ -24,7 +24,8 @@ func testExperimentalEndorsement(ht *lntest.HarnessTest) {
// testEndorsement sets up a 5 hop network and tests propagation of // testEndorsement sets up a 5 hop network and tests propagation of
// experimental endorsement signals. // experimental endorsement signals.
func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) { func testEndorsement(ht *lntest.HarnessTest, aliceEndorse bool) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
carol := ht.NewNode( carol := ht.NewNode(
"carol", []string{"--protocol.no-experimental-endorsement"}, "carol", []string{"--protocol.no-experimental-endorsement"},
) )
+3 -1
View File
@@ -765,7 +765,9 @@ type interceptorTestScenario struct {
func newInterceptorTestScenario( func newInterceptorTestScenario(
ht *lntest.HarnessTest) *interceptorTestScenario { ht *lntest.HarnessTest) *interceptorTestScenario {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
carol := ht.NewNode("carol", nil) carol := ht.NewNode("carol", nil)
dave := ht.NewNode("dave", nil) dave := ht.NewNode("dave", nil)
+5 -6
View File
@@ -282,8 +282,7 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
// 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)
alice := ht.NewNode("Alice", nil)
alice := ht.Alice
// We'll send her some unconfirmed funds. // We'll send her some unconfirmed funds.
ht.FundCoinsUnconfirmed(2*chanAmt, carol) ht.FundCoinsUnconfirmed(2*chanAmt, carol)
@@ -402,7 +401,7 @@ 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 alice := ht.NewNode("Alice", nil)
// 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)
@@ -841,7 +840,7 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
} }
carol := ht.NewNode("Carol", carolArgs) carol := ht.NewNode("Carol", carolArgs)
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol) ht.ConnectNodes(alice, carol)
// Create a new channel that requires 5 confs before it's considered // Create a new channel that requires 5 confs before it's considered
@@ -957,8 +956,8 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
} }
eve := ht.NewNode("eve", scidAliasArgs) eve := ht.NewNode("eve", scidAliasArgs)
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", scidAliasArgs)
ht.RestartNodeWithExtraArgs(alice, scidAliasArgs) bob := ht.NewNodeWithCoins("Bob", nil)
// Before we start the test, we'll ensure Alice is connected to Carol // Before we start the test, we'll ensure Alice is connected to Carol
// and Dave, so she can open channels to both of them (and Bob). // and Dave, so she can open channels to both of them (and Bob).
+4 -3
View File
@@ -17,10 +17,11 @@ import (
// would otherwise trigger force closes when they expire. // would otherwise trigger force closes when they expire.
func testHoldInvoiceForceClose(ht *lntest.HarnessTest) { func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// Open a channel between alice and bob. // Open a channel between alice and bob.
alice, bob := ht.Alice, ht.Bob chanPoints, nodes := ht.CreateSimpleNetwork(
chanPoint := ht.OpenChannel( [][]string{nil, nil}, lntest.OpenChannelParams{Amt: 300000},
alice, bob, lntest.OpenChannelParams{Amt: 300000},
) )
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Create a non-dust hold invoice for bob. // Create a non-dust hold invoice for bob.
var ( var (
+3 -1
View File
@@ -28,7 +28,9 @@ func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", nil) carol := ht.NewNode("Carol", nil)
// Connect Alice to Carol. // Connect Alice to Carol.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
ht.ConnectNodes(alice, carol) ht.ConnectNodes(alice, carol)
// Open a channel between Alice and Carol which is private so that we // Open a channel between Alice and Carol which is private so that we
+1 -1
View File
@@ -14,7 +14,7 @@ import (
func testLookupHtlcResolution(ht *lntest.HarnessTest) { func testLookupHtlcResolution(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(1000000) const chanAmt = btcutil.Amount(1000000)
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
carol := ht.NewNode("Carol", []string{ carol := ht.NewNode("Carol", []string{
"--store-final-htlc-resolutions", "--store-final-htlc-resolutions",
}) })
+2 -1
View File
@@ -251,7 +251,8 @@ type acceptorTestScenario struct {
// //
// Among them, Alice and Bob are standby nodes and Carol is a new node. // Among them, Alice and Bob are standby nodes and Carol is a new node.
func newAcceptorTestScenario(ht *lntest.HarnessTest) *acceptorTestScenario { func newAcceptorTestScenario(ht *lntest.HarnessTest) *acceptorTestScenario {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
carol := ht.NewNode("carol", nil) carol := ht.NewNode("carol", nil)
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
+3 -3
View File
@@ -29,7 +29,7 @@ func testMacaroonAuthentication(ht *lntest.HarnessTest) {
newAddrReq = &lnrpc.NewAddressRequest{ newAddrReq = &lnrpc.NewAddressRequest{
Type: AddrTypeWitnessPubkeyHash, Type: AddrTypeWitnessPubkeyHash,
} }
testNode = ht.Alice testNode = ht.NewNode("Alice", nil)
testClient = testNode.RPC.LN testClient = testNode.RPC.LN
) )
@@ -295,7 +295,7 @@ func testMacaroonAuthentication(ht *lntest.HarnessTest) {
// in the request must be set correctly, and the baked macaroon has the intended // in the request must be set correctly, and the baked macaroon has the intended
// permissions. // permissions.
func testBakeMacaroon(ht *lntest.HarnessTest) { func testBakeMacaroon(ht *lntest.HarnessTest) {
var testNode = ht.Alice var testNode = ht.NewNode("Alice", nil)
testCases := []struct { testCases := []struct {
name string name string
@@ -521,7 +521,7 @@ func testBakeMacaroon(ht *lntest.HarnessTest) {
func testDeleteMacaroonID(ht *lntest.HarnessTest) { func testDeleteMacaroonID(ht *lntest.HarnessTest) {
var ( var (
ctxb = ht.Context() ctxb = ht.Context()
testNode = ht.Alice testNode = ht.NewNode("Alice", nil)
) )
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
+8 -12
View File
@@ -19,25 +19,21 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
// Bob to add a maximum of 5 htlcs to her commitment. // Bob to add a maximum of 5 htlcs to her commitment.
maxHtlcs := 5 maxHtlcs := 5
alice, bob := ht.Alice, ht.Bob // Create nodes with the new flag so they understand the new payment
// Restart nodes with the new flag so they understand the new payment
// status. // status.
ht.RestartNodeWithExtraArgs(alice, []string{ cfg := []string{"--routerrpc.usestatusinitiated"}
"--routerrpc.usestatusinitiated", cfgs := [][]string{cfg, cfg}
})
ht.RestartNodeWithExtraArgs(bob, []string{
"--routerrpc.usestatusinitiated",
})
ht.EnsureConnected(alice, bob) // Create a channel Alice->Bob.
chanPoint := ht.OpenChannel( chanPoints, nodes := ht.CreateSimpleNetwork(
alice, bob, lntest.OpenChannelParams{ cfgs, lntest.OpenChannelParams{
Amt: 1000000, Amt: 1000000,
PushAmt: 800000, PushAmt: 800000,
RemoteMaxHtlcs: uint16(maxHtlcs), RemoteMaxHtlcs: uint16(maxHtlcs),
}, },
) )
chanPoint := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Alice and bob should have one channel open with each other now. // Alice and bob should have one channel open with each other now.
ht.AssertNodeNumChannels(alice, 1) ht.AssertNodeNumChannels(alice, 1)
+31 -28
View File
@@ -39,9 +39,8 @@ func testDisconnectingTargetPeer(ht *lntest.HarnessTest) {
"--maxbackoff=1m", "--maxbackoff=1m",
} }
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", args)
ht.RestartNodeWithExtraArgs(alice, args) bob := ht.NewNodeWithCoins("Bob", args)
ht.RestartNodeWithExtraArgs(bob, args)
// Start by connecting Alice and Bob with no channels. // Start by connecting Alice and Bob with no channels.
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
@@ -239,17 +238,11 @@ func testListChannels(ht *lntest.HarnessTest) {
const aliceRemoteMaxHtlcs = 50 const aliceRemoteMaxHtlcs = 50
const bobRemoteMaxHtlcs = 100 const bobRemoteMaxHtlcs = 100
// Get the standby nodes and open a channel between them.
alice, bob := ht.Alice, ht.Bob
args := []string{fmt.Sprintf( args := []string{fmt.Sprintf(
"--default-remote-max-htlcs=%v", "--default-remote-max-htlcs=%v",
bobRemoteMaxHtlcs, bobRemoteMaxHtlcs,
)} )}
ht.RestartNodeWithExtraArgs(bob, args) cfgs := [][]string{nil, args}
// Connect Alice to Bob.
ht.EnsureConnected(alice, bob)
// 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. The minial HTLC amount is set // being the sole funder of the channel. The minial HTLC amount is set
@@ -264,8 +257,10 @@ func testListChannels(ht *lntest.HarnessTest) {
MinHtlc: customizedMinHtlc, MinHtlc: customizedMinHtlc,
RemoteMaxHtlcs: aliceRemoteMaxHtlcs, RemoteMaxHtlcs: aliceRemoteMaxHtlcs,
} }
chanPoint := ht.OpenChannel(alice, bob, p)
defer ht.CloseChannel(alice, chanPoint) chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, p)
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Alice should have one channel opened with Bob. // Alice should have one channel opened with Bob.
ht.AssertNodeNumChannels(alice, 1) ht.AssertNodeNumChannels(alice, 1)
@@ -369,7 +364,7 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
} }
carol := ht.NewNode("Carol", args) carol := ht.NewNode("Carol", args)
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol) ht.ConnectNodes(alice, carol)
carolBalance := btcutil.Amount(maxPendingChannels) * amount carolBalance := btcutil.Amount(maxPendingChannels) * amount
@@ -439,7 +434,9 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) { func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) {
const chanAmt = 1000000 const chanAmt = 1000000
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// Open a channel between Alice and Bob which will later be // Open a channel between Alice and Bob which will later be
// cooperatively closed. // cooperatively closed.
@@ -553,7 +550,8 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
// Alice ------> Carol ------> Bob // Alice ------> Carol ------> Bob
// //
const chanAmt = btcutil.Amount(1000000) const chanAmt = btcutil.Amount(1000000)
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
// Create Carol with reject htlc flag. // Create Carol with reject htlc flag.
carol := ht.NewNode("Carol", []string{"--rejecthtlc"}) carol := ht.NewNode("Carol", []string{"--rejecthtlc"})
@@ -649,15 +647,16 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
func testNodeSignVerify(ht *lntest.HarnessTest) { func testNodeSignVerify(ht *lntest.HarnessTest) {
chanAmt := funding.MaxBtcFundingAmount chanAmt := funding.MaxBtcFundingAmount
pushAmt := btcutil.Amount(100000) pushAmt := btcutil.Amount(100000)
alice, bob := ht.Alice, ht.Bob p := lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
}
// Create a channel between alice and bob. // Create a channel between alice and bob.
aliceBobCh := ht.OpenChannel( cfgs := [][]string{nil, nil}
alice, bob, lntest.OpenChannelParams{ chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, p)
Amt: chanAmt, alice, bob := nodes[0], nodes[1]
PushAmt: pushAmt, aliceBobCh := chanPoints[0]
},
)
// alice signs "alice msg" and sends her signature to bob. // alice signs "alice msg" and sends her signature to bob.
aliceMsg := []byte("alice msg") aliceMsg := []byte("alice msg")
@@ -694,14 +693,17 @@ func testNodeSignVerify(ht *lntest.HarnessTest) {
// and not in one of the pending closure states. It also verifies that the // and not in one of the pending closure states. It also verifies that the
// abandoned channel is reported as closed with close type 'abandoned'. // abandoned channel is reported as closed with close type 'abandoned'.
func testAbandonChannel(ht *lntest.HarnessTest) { func testAbandonChannel(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// First establish a channel between Alice and Bob. // First establish a channel between Alice and Bob.
channelParam := lntest.OpenChannelParams{ channelParam := lntest.OpenChannelParams{
Amt: funding.MaxBtcFundingAmount, Amt: funding.MaxBtcFundingAmount,
PushAmt: btcutil.Amount(100000), PushAmt: btcutil.Amount(100000),
} }
chanPoint := ht.OpenChannel(alice, bob, channelParam)
// Create a channel between alice and bob.
cfgs := [][]string{nil, nil}
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, channelParam)
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Now that the channel is open, we'll obtain its channel ID real quick // Now that the channel is open, we'll obtain its channel ID real quick
// so we can use it to query the graph below. // so we can use it to query the graph below.
@@ -763,7 +765,7 @@ 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 alice := ht.NewNodeWithCoins("Alice", nil)
// 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.
@@ -1162,7 +1164,8 @@ func assertChannelConstraintsEqual(ht *lntest.HarnessTest,
// on a message with a provided address. // on a message with a provided address.
func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) { func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) {
// Using different nodes to sign the message and verify the signature. // Using different nodes to sign the message and verify the signature.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNode("Alice,", nil)
bob := ht.NewNode("Bob,", nil)
// Test an lnd wallet created P2WKH address. // Test an lnd wallet created P2WKH address.
respAddr := alice.RPC.NewAddress(&lnrpc.NewAddressRequest{ respAddr := alice.RPC.NewAddress(&lnrpc.NewAddressRequest{
@@ -1279,7 +1282,7 @@ func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) {
// up with native SQL enabled, as we don't currently support migration of KV // up with native SQL enabled, as we don't currently support migration of KV
// invoices to the new SQL schema. // invoices to the new SQL schema.
func testNativeSQLNoMigration(ht *lntest.HarnessTest) { func testNativeSQLNoMigration(ht *lntest.HarnessTest) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
// Make sure we run the test with SQLite or Postgres. // Make sure we run the test with SQLite or Postgres.
if alice.Cfg.DBBackend != node.BackendSqlite && if alice.Cfg.DBBackend != node.BackendSqlite &&
+2 -2
View File
@@ -180,8 +180,8 @@ type mppTestScenario struct {
// \ / // \ /
// \__ Dave ____/ // \__ Dave ____/
func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario { func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
ht.RestartNodeWithExtraArgs(bob, []string{ bob := ht.NewNodeWithCoins("Bob", []string{
"--maxpendingchannels=2", "--maxpendingchannels=2",
"--accept-amp", "--accept-amp",
}) })
@@ -15,7 +15,9 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
// multi-hop payment. // multi-hop payment.
const chanAmt = funding.MaxBtcFundingAmount const chanAmt = funding.MaxBtcFundingAmount
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// Since we'd like to test some multi-hop failure scenarios, we'll // Since we'd like to test some multi-hop failure scenarios, we'll
// introduce another node into our test network: Carol. // introduce another node into our test network: Carol.
+3 -1
View File
@@ -18,7 +18,8 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
// channel with Alice, and Carol with Dave. After this setup, the // channel with Alice, and Carol with Dave. After this setup, the
// network topology should now look like: // network topology should now look like:
// Carol -> Dave -> Alice -> Bob // Carol -> Dave -> Alice -> Bob
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
daveArgs := []string{"--protocol.legacy.onion"} daveArgs := []string{"--protocol.legacy.onion"}
dave := ht.NewNode("Dave", daveArgs) dave := ht.NewNode("Dave", daveArgs)
@@ -37,6 +38,7 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
ht.AssertHtlcEventType(daveEvents, routerrpc.HtlcEvent_UNKNOWN) ht.AssertHtlcEventType(daveEvents, routerrpc.HtlcEvent_UNKNOWN)
// Connect the nodes. // Connect the nodes.
ht.ConnectNodes(alice, bob)
ht.ConnectNodes(dave, alice) ht.ConnectNodes(dave, alice)
ht.ConnectNodes(carol, dave) ht.ConnectNodes(carol, dave)
+2 -2
View File
@@ -126,7 +126,7 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
} }
// Connect Alice to Dave and Charlie. // Connect Alice to Dave and Charlie.
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, dave) ht.ConnectNodes(alice, dave)
ht.ConnectNodes(alice, charlie) ht.ConnectNodes(alice, charlie)
@@ -218,7 +218,7 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
// testAddPeerConfig tests that the "--addpeer" config flag successfully adds // testAddPeerConfig tests that the "--addpeer" config flag successfully adds
// a new peer. // a new peer.
func testAddPeerConfig(ht *lntest.HarnessTest) { func testAddPeerConfig(ht *lntest.HarnessTest) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
info := alice.RPC.GetInfo() info := alice.RPC.GetInfo()
alicePeerAddress := info.Uris[0] alicePeerAddress := info.Uris[0]
+1 -1
View File
@@ -13,7 +13,7 @@ func testNeutrino(ht *lntest.HarnessTest) {
ht.Skipf("skipping test for non neutrino backends") ht.Skipf("skipping test for non neutrino backends")
} }
alice := ht.Alice alice := ht.NewNode("Alice", nil)
// Check if the neutrino sub server is running. // Check if the neutrino sub server is running.
statusRes := alice.RPC.Status(nil) statusRes := alice.RPC.Status(nil)
+5 -10
View File
@@ -33,7 +33,7 @@ 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 alice := ht.NewNode("Alice", nil)
// Get best block hash. // Get best block hash.
bestBlockRes := alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
@@ -63,7 +63,7 @@ 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 alice := ht.NewNode("Alice", nil)
// Get best block hash. // Get best block hash.
bestBlockRes := alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
@@ -108,7 +108,7 @@ 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 alice := ht.NewNode("Alice", nil)
// Get best block hash. // Get best block hash.
bestBlockRes := alice.RPC.GetBestBlock(nil) bestBlockRes := alice.RPC.GetBestBlock(nil)
@@ -134,8 +134,7 @@ func testChainKitSendOutputsAnchorReserve(ht *lntest.HarnessTest) {
// NOTE: we cannot reuse the standby node here as the test requires the // NOTE: we cannot reuse the standby node here as the test requires the
// node to start with no UTXOs. // node to start with no UTXOs.
charlie := ht.NewNode("Charlie", args) charlie := ht.NewNode("Charlie", args)
bob := ht.Bob bob := ht.NewNode("Bob", args)
ht.RestartNodeWithExtraArgs(bob, args)
// We'll start the test by sending Charlie some coins. // We'll start the test by sending Charlie some coins.
fundingAmount := btcutil.Amount(100_000) fundingAmount := btcutil.Amount(100_000)
@@ -222,12 +221,8 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
// Start two nodes supporting anchor channels. // Start two nodes supporting anchor channels.
args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS) args := lntest.NodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
// NOTE: we cannot reuse the standby node here as the test requires the
// node to start with no UTXOs.
alice := ht.NewNode("Alice", args) alice := ht.NewNode("Alice", args)
bob := ht.Bob bob := ht.NewNode("Bob", args)
ht.RestartNodeWithExtraArgs(bob, args)
ht.ConnectNodes(alice, bob) ht.ConnectNodes(alice, bob)
// Send just enough coins for Alice to open a channel without a change // Send just enough coins for Alice to open a channel without a change
+18 -10
View File
@@ -34,7 +34,9 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
tempMiner := ht.SpawnTempMiner() tempMiner := ht.SpawnTempMiner()
miner := ht.Miner() miner := ht.Miner()
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
// Create a new channel that requires 1 confs before it's considered // Create a new channel that requires 1 confs before it's considered
// open, then broadcast the funding transaction // open, then broadcast the funding transaction
@@ -242,9 +244,10 @@ func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
// In this basic test, we'll need a third node, Carol, so we can forward // In this basic test, we'll need a third node, Carol, so we can forward
// a payment through the channel we'll open with the different fee // a payment through the channel we'll open with the different fee
// policies. // policies.
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
carol := ht.NewNode("Carol", nil) carol := ht.NewNode("Carol", nil)
alice, bob := ht.Alice, ht.Bob
nodes := []*node.HarnessNode{alice, bob, carol} nodes := []*node.HarnessNode{alice, bob, carol}
runTestCase := func(ht *lntest.HarnessTest, runTestCase := func(ht *lntest.HarnessTest,
@@ -301,7 +304,7 @@ func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
// Send Carol enough coins to be able to open a channel // Send Carol enough coins to be able to open a channel
// to Alice. // to Alice.
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol) st.FundCoins(btcutil.SatoshiPerBitcoin, carol)
runTestCase( runTestCase(
st, feeScenario, st, feeScenario,
@@ -315,7 +318,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) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
runBasicChannelCreationAndUpdates(ht, alice, bob) runBasicChannelCreationAndUpdates(ht, alice, bob)
} }
@@ -519,8 +524,8 @@ func testUpdateOnPendingOpenChannels(ht *lntest.HarnessTest) {
// processing the fundee's `channel_ready`, the HTLC will be cached and // processing the fundee's `channel_ready`, the HTLC will be cached and
// eventually settled. // eventually settled.
func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) { func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
// Grab the channel participants. alice := ht.NewNodeWithCoins("Alice", nil)
alice, bob := ht.Alice, ht.Bob bob := ht.NewNode("Bob", nil)
// Restart Alice with the config so she won't process Bob's // Restart Alice with the config so she won't process Bob's
// channel_ready msg immediately. // channel_ready msg immediately.
@@ -603,8 +608,8 @@ func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
// processing the funder's `channel_ready`, the HTLC will be cached and // processing the funder's `channel_ready`, the HTLC will be cached and
// eventually settled. // eventually settled.
func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) { func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) {
// Grab the channel participants. alice := ht.NewNodeWithCoins("Alice", nil)
alice, bob := ht.Alice, ht.Bob bob := ht.NewNode("Bob", nil)
// Restart Bob with the config so he won't process Alice's // Restart Bob with the config so he won't process Alice's
// channel_ready msg immediately. // channel_ready msg immediately.
@@ -746,7 +751,10 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
// before the funding transaction is confirmed, that the FundingExpiryBlocks // before the funding transaction is confirmed, that the FundingExpiryBlocks
// field of a PendingChannels decreases. // field of a PendingChannels decreases.
func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) { func testFundingExpiryBlocksOnPending(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
param := lntest.OpenChannelParams{Amt: 100000} param := lntest.OpenChannelParams{Amt: 100000}
update := ht.OpenChannelAssertPending(alice, bob, param) update := ht.OpenChannelAssertPending(alice, bob, param)
@@ -844,7 +852,6 @@ func testSimpleTaprootChannelActivation(ht *lntest.HarnessTest) {
// up as locked balance in the WalletBalance response. // up as locked balance in the WalletBalance response.
func testOpenChannelLockedBalance(ht *lntest.HarnessTest) { func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
var ( var (
bob = ht.Bob
req *lnrpc.ChannelAcceptRequest req *lnrpc.ChannelAcceptRequest
err error err error
) )
@@ -852,6 +859,7 @@ func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
// Create a new node so we can assert exactly how much fund has been // Create a new node so we can assert exactly how much fund has been
// locked later. // locked later.
alice := ht.NewNode("alice", nil) alice := ht.NewNode("alice", nil)
bob := ht.NewNode("bob", nil)
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice) ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
// Connect the nodes. // Connect the nodes.
+12 -4
View File
@@ -346,7 +346,8 @@ func runTestPaymentHTLCTimeout(ht *lntest.HarnessTest, restartAlice bool) {
// to return floor fee rate(1 sat/vb). // to return floor fee rate(1 sat/vb).
func testSendDirectPayment(ht *lntest.HarnessTest) { func testSendDirectPayment(ht *lntest.HarnessTest) {
// Grab Alice and Bob's nodes for convenience. // Grab Alice and Bob's nodes for convenience.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
// Create a list of commitment types we want to test. // Create a list of commitment types we want to test.
commitmentTypes := []lnrpc.CommitmentType{ commitmentTypes := []lnrpc.CommitmentType{
@@ -466,7 +467,9 @@ func testSendDirectPayment(ht *lntest.HarnessTest) {
} }
func testListPayments(ht *lntest.HarnessTest) { func testListPayments(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
// Check that there are no payments before test. // Check that there are no payments before test.
ht.AssertNumPayments(alice, 0) ht.AssertNumPayments(alice, 0)
@@ -658,7 +661,10 @@ func testPaymentFollowingChannelOpen(ht *lntest.HarnessTest) {
channelCapacity := paymentAmt * 1000 channelCapacity := paymentAmt * 1000
// We first establish a channel between Alice and Bob. // We first establish a channel between Alice and Bob.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
p := lntest.OpenChannelParams{ p := lntest.OpenChannelParams{
Amt: channelCapacity, Amt: channelCapacity,
} }
@@ -934,7 +940,9 @@ func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
func testInvoiceSubscriptions(ht *lntest.HarnessTest) { func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(500000) const chanAmt = btcutil.Amount(500000)
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
// Create a new invoice subscription client for Bob, the notification // Create a new invoice subscription client for Bob, the notification
// should be dispatched shortly below. // should be dispatched shortly below.
+9 -8
View File
@@ -146,7 +146,7 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
// 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 alice := ht.NewNodeWithCoins("Alice", nil)
ht.EnsureConnected(carol, dave) ht.EnsureConnected(carol, dave)
ht.EnsureConnected(carol, alice) ht.EnsureConnected(carol, alice)
@@ -344,7 +344,7 @@ func runPsbtChanFundingExternal(ht *lntest.HarnessTest, carol,
// 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 alice := ht.NewNodeWithCoins("Alice", nil)
ht.EnsureConnected(carol, dave) ht.EnsureConnected(carol, dave)
ht.EnsureConnected(carol, alice) ht.EnsureConnected(carol, alice)
@@ -517,8 +517,7 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
const chanSize = funding.MaxBtcFundingAmount const chanSize = funding.MaxBtcFundingAmount
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
// Get new address for anchor reserve. // Get new address for anchor reserve.
req := &lnrpc.NewAddressRequest{ req := &lnrpc.NewAddressRequest{
@@ -697,7 +696,8 @@ func testSignPsbt(ht *lntest.HarnessTest) {
for _, tc := range psbtTestRunners { for _, tc := range psbtTestRunners {
succeed := ht.Run(tc.name, func(t *testing.T) { succeed := ht.Run(tc.name, func(t *testing.T) {
st := ht.Subtest(t) st := ht.Subtest(t)
tc.runner(st, st.Alice) alice := st.NewNodeWithCoins("Alice", nil)
tc.runner(st, alice)
}) })
// Abort the test if failed. // Abort the test if failed.
@@ -1088,7 +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 alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
// 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
@@ -1598,8 +1599,8 @@ 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 alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.Bob bob := ht.NewNodeWithCoins("Bob", nil)
const chanSize = funding.MaxBtcFundingAmount const chanSize = funding.MaxBtcFundingAmount
+2 -1
View File
@@ -16,7 +16,8 @@ import (
// NOTE FOR REVIEW: this could be improved by blasting the channel with HTLC // NOTE FOR REVIEW: this could be improved by blasting the channel with HTLC
// traffic on both sides to increase the surface area of the change under test. // traffic on both sides to increase the surface area of the change under test.
func testQuiescence(ht *lntest.HarnessTest) { func testQuiescence(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
chanPoint := ht.OpenChannel(bob, alice, lntest.OpenChannelParams{ chanPoint := ht.OpenChannel(bob, alice, lntest.OpenChannelParams{
Amt: btcutil.Amount(1000000), Amt: btcutil.Amount(1000000),
+2 -1
View File
@@ -17,7 +17,8 @@ func testResHandoff(ht *lntest.HarnessTest) {
paymentAmt = 50000 paymentAmt = 50000
) )
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
// First we'll create a channel between Alice and Bob. // First we'll create a channel between Alice and Bob.
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
+10 -10
View File
@@ -212,13 +212,13 @@ func testRestAPI(ht *lntest.HarnessTest) {
// Make sure Alice allows all CORS origins. Bob will keep the default. // Make sure Alice allows all CORS origins. Bob will keep the default.
// We also make sure the ping/pong messages are sent very often, so we // We also make sure the ping/pong messages are sent very often, so we
// can test them without waiting half a minute. // can test them without waiting half a minute.
alice, bob := ht.Alice, ht.Bob bob := ht.NewNode("Bob", nil)
alice.Cfg.ExtraArgs = append( args := []string{
alice.Cfg.ExtraArgs, "--restcors=\"*\"", "--restcors=\"*\"",
fmt.Sprintf("--ws-ping-interval=%s", pingInterval), fmt.Sprintf("--ws-ping-interval=%s", pingInterval),
fmt.Sprintf("--ws-pong-wait=%s", pongWait), fmt.Sprintf("--ws-pong-wait=%s", pongWait),
) }
ht.RestartNode(alice) alice := ht.NewNodeWithCoins("Alice", args)
for _, tc := range testCases { for _, tc := range testCases {
tc := tc tc := tc
@@ -237,7 +237,7 @@ func testRestAPI(ht *lntest.HarnessTest) {
} }
func wsTestCaseSubscription(ht *lntest.HarnessTest) { func wsTestCaseSubscription(ht *lntest.HarnessTest) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
// 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()
@@ -328,7 +328,7 @@ func wsTestCaseSubscriptionMacaroon(ht *lntest.HarnessTest) {
// This time we send the macaroon in the special header // This time we send the macaroon in the special header
// Sec-Websocket-Protocol which is the only header field available to // Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket. // browsers when opening a WebSocket.
alice := ht.Alice alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon( mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout, alice.Cfg.AdminMacPath, defaultTimeout,
) )
@@ -413,7 +413,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
// This time we send the macaroon in the special header // This time we send the macaroon in the special header
// Sec-Websocket-Protocol which is the only header field available to // Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket. // browsers when opening a WebSocket.
alice := ht.Alice alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon( mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout, alice.Cfg.AdminMacPath, defaultTimeout,
) )
@@ -522,7 +522,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
// Before we start opening channels, make sure the two nodes are // Before we start opening channels, make sure the two nodes are
// connected. // connected.
bob := ht.Bob bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
// Open 3 channels to make sure multiple requests and responses can be // Open 3 channels to make sure multiple requests and responses can be
@@ -554,7 +554,7 @@ func wsTestPingPongTimeout(ht *lntest.HarnessTest) {
// This time we send the macaroon in the special header // This time we send the macaroon in the special header
// Sec-Websocket-Protocol which is the only header field available to // Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket. // browsers when opening a WebSocket.
alice := ht.Alice alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon( mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout, alice.Cfg.AdminMacPath, defaultTimeout,
) )
+49 -36
View File
@@ -26,11 +26,9 @@ import (
// expected. It also includes the edge case of a single-hop blinded route, // expected. It also includes the edge case of a single-hop blinded route,
// which indicates that the introduction node is the recipient. // which indicates that the introduction node is the recipient.
func testQueryBlindedRoutes(ht *lntest.HarnessTest) { func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
var ( alice := ht.NewNodeWithCoins("Alice", nil)
// Convenience aliases. bob := ht.NewNodeWithCoins("Bob", nil)
alice = ht.Alice ht.EnsureConnected(alice, bob)
bob = ht.Bob
)
// Setup a two hop channel network: Alice -- Bob -- Carol. // Setup a two hop channel network: Alice -- Bob -- Carol.
// We set our proportional fee for these channels to zero, so that // We set our proportional fee for these channels to zero, so that
@@ -318,6 +316,8 @@ func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
type blindedForwardTest struct { type blindedForwardTest struct {
ht *lntest.HarnessTest ht *lntest.HarnessTest
alice *node.HarnessNode
bob *node.HarnessNode
carol *node.HarnessNode carol *node.HarnessNode
dave *node.HarnessNode dave *node.HarnessNode
channels []*lnrpc.ChannelPoint channels []*lnrpc.ChannelPoint
@@ -349,11 +349,24 @@ func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context,
func (b *blindedForwardTest) setupNetwork(ctx context.Context, func (b *blindedForwardTest) setupNetwork(ctx context.Context,
withInterceptor bool) { withInterceptor bool) {
const chanAmt = btcutil.Amount(100_000)
carolArgs := []string{"--bitcoin.timelockdelta=18"} carolArgs := []string{"--bitcoin.timelockdelta=18"}
if withInterceptor { if withInterceptor {
carolArgs = append(carolArgs, "--requireinterceptor") carolArgs = append(carolArgs, "--requireinterceptor")
} }
b.carol = b.ht.NewNode("Carol", carolArgs)
daveArgs := []string{"--bitcoin.timelockdelta=18"}
cfgs := [][]string{nil, nil, carolArgs, daveArgs}
param := lntest.OpenChannelParams{
Amt: chanAmt,
}
// Creates a network with the following topology and liquidity:
// Alice (100k)----- Bob (100k) ----- Carol (100k) ----- Dave
chanPoints, nodes := b.ht.CreateSimpleNetwork(cfgs, param)
b.channels = chanPoints
b.alice, b.bob, b.carol, b.dave = nodes[0], nodes[1], nodes[2], nodes[3]
if withInterceptor { if withInterceptor {
var err error var err error
@@ -362,10 +375,6 @@ func (b *blindedForwardTest) setupNetwork(ctx context.Context,
) )
require.NoError(b.ht, err, "interceptor") require.NoError(b.ht, err, "interceptor")
} }
b.dave = b.ht.NewNode("Dave", []string{"--bitcoin.timelockdelta=18"})
b.channels = setupFourHopNetwork(b.ht, b.carol, b.dave)
} }
// buildBlindedPath returns a blinded route from Bob -> Carol -> Dave, with Bob // buildBlindedPath returns a blinded route from Bob -> Carol -> Dave, with Bob
@@ -395,7 +404,7 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
require.Len(b.ht, payReq.BlindedPaths, 1) require.Len(b.ht, payReq.BlindedPaths, 1)
path := payReq.BlindedPaths[0].BlindedPath path := payReq.BlindedPaths[0].BlindedPath
require.Len(b.ht, path.BlindedHops, 3) require.Len(b.ht, path.BlindedHops, 3)
require.EqualValues(b.ht, path.IntroductionNode, b.ht.Bob.PubKey[:]) require.EqualValues(b.ht, path.IntroductionNode, b.bob.PubKey[:])
return payReq.BlindedPaths[0] return payReq.BlindedPaths[0]
} }
@@ -403,8 +412,8 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
// cleanup tears down all channels created by the test and cancels the top // cleanup tears down all channels created by the test and cancels the top
// level context used in the test. // level context used in the test.
func (b *blindedForwardTest) cleanup() { func (b *blindedForwardTest) cleanup() {
b.ht.CloseChannel(b.ht.Alice, b.channels[0]) b.ht.CloseChannel(b.alice, b.channels[0])
b.ht.CloseChannel(b.ht.Bob, b.channels[1]) b.ht.CloseChannel(b.bob, b.channels[1])
b.ht.CloseChannel(b.carol, b.channels[2]) b.ht.CloseChannel(b.carol, b.channels[2])
b.cancel() b.cancel()
@@ -431,7 +440,7 @@ func (b *blindedForwardTest) createRouteToBlinded(paymentAmt int64,
}, },
} }
resp := b.ht.Alice.RPC.QueryRoutes(req) resp := b.alice.RPC.QueryRoutes(req)
require.Greater(b.ht, len(resp.Routes), 0, "no routes") require.Greater(b.ht, len(resp.Routes), 0, "no routes")
require.Len(b.ht, resp.Routes[0].Hops, 3, "unexpected route length") require.Len(b.ht, resp.Routes[0].Hops, 3, "unexpected route length")
@@ -452,7 +461,7 @@ func (b *blindedForwardTest) sendBlindedPayment(ctx context.Context,
ctx, cancel := context.WithTimeout(ctx, time.Hour) ctx, cancel := context.WithTimeout(ctx, time.Hour)
go func() { go func() {
_, err := b.ht.Alice.RPC.Router.SendToRouteV2(ctx, sendReq) _, err := b.alice.RPC.Router.SendToRouteV2(ctx, sendReq)
// We may get a context canceled error when the test is // We may get a context canceled error when the test is
// finished. // finished.
@@ -481,7 +490,7 @@ func (b *blindedForwardTest) sendToRoute(route *lnrpc.Route,
// Let Alice send to the blinded payment path and assert that it // Let Alice send to the blinded payment path and assert that it
// succeeds/fails. // succeeds/fails.
htlcAttempt := b.ht.Alice.RPC.SendToRouteV2(sendReq) htlcAttempt := b.alice.RPC.SendToRouteV2(sendReq)
if assertSuccess { if assertSuccess {
require.Nil(b.ht, htlcAttempt.Failure) require.Nil(b.ht, htlcAttempt.Failure)
require.Equal(b.ht, htlcAttempt.Status, require.Equal(b.ht, htlcAttempt.Status,
@@ -498,7 +507,7 @@ func (b *blindedForwardTest) sendToRoute(route *lnrpc.Route,
require.NoError(b.ht, err) require.NoError(b.ht, err)
pmt := b.ht.AssertPaymentStatus( pmt := b.ht.AssertPaymentStatus(
b.ht.Alice, preimage, lnrpc.Payment_FAILED, b.alice, preimage, lnrpc.Payment_FAILED,
) )
require.Len(b.ht, pmt.Htlcs, 1) require.Len(b.ht, pmt.Htlcs, 1)
@@ -520,7 +529,7 @@ func (b *blindedForwardTest) drainCarolLiquidity(incoming bool) {
receivingNode := b.dave receivingNode := b.dave
if incoming { if incoming {
sendingNode = b.ht.Bob sendingNode = b.bob
receivingNode = b.carol receivingNode = b.carol
} }
@@ -556,7 +565,8 @@ 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 alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
const chanAmt = btcutil.Amount(100000) const chanAmt = btcutil.Amount(100000)
var networkChans []*lnrpc.ChannelPoint var networkChans []*lnrpc.ChannelPoint
@@ -611,8 +621,6 @@ 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()
@@ -620,6 +628,8 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
// blinded path that uses Bob as an introduction node. // blinded path that uses Bob as an introduction node.
testCase.setupNetwork(ctx, false) testCase.setupNetwork(ctx, false)
alice := testCase.alice
// Let Dave add a blinded invoice. // Let Dave add a blinded invoice.
// Add restrictions so that he only ever creates a single blinded path // Add restrictions so that he only ever creates a single blinded path
// from Bob to himself. // from Bob to himself.
@@ -737,14 +747,14 @@ 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)
blindedPaymentPath := testCase.buildBlindedPath() blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath) route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
bob := testCase.bob
// Before we send our payment, drain all of Carol's incoming liquidity // Before we send our payment, drain all of Carol's incoming liquidity
// so that she can't receive the forward from Bob, causing a failure // so that she can't receive the forward from Bob, causing a failure
// at the introduction node. // at the introduction node.
@@ -770,8 +780,6 @@ 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.
@@ -781,6 +789,8 @@ func testDisableIntroductionNode(ht *lntest.HarnessTest) {
blindedPaymentPath := testCase.buildBlindedPath() blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath) route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
alice, bob := testCase.alice, testCase.bob
// Now, disable route blinding for Bob, then re-connect to Alice. // Now, disable route blinding for Bob, then re-connect to Alice.
ht.RestartNodeWithExtraArgs(bob, []string{ ht.RestartNodeWithExtraArgs(bob, []string{
"--protocol.no-route-blinding", "--protocol.no-route-blinding",
@@ -796,8 +806,6 @@ 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.
@@ -811,6 +819,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
50_000_000, blindedPaymentPath, 50_000_000, blindedPaymentPath,
) )
alice, bob := testCase.alice, testCase.bob
// Once our interceptor is set up, we can send the blinded payment. // Once our interceptor is set up, we can send the blinded payment.
cancelPmt := testCase.sendBlindedPayment(ctx, blindedRoute) cancelPmt := testCase.sendBlindedPayment(ctx, blindedRoute)
defer cancelPmt() defer cancelPmt()
@@ -917,8 +927,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) { func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
// Create a five-node context consisting of Alice, Bob and three new // Create a five-node context consisting of Alice, Bob and three new
// nodes. // nodes.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNode("Alice", nil)
bob := ht.NewNode("Bob", nil)
dave := ht.NewNode("dave", nil) dave := ht.NewNode("dave", nil)
carol := ht.NewNode("carol", nil) carol := ht.NewNode("carol", nil)
eve := ht.NewNode("eve", nil) eve := ht.NewNode("eve", nil)
@@ -932,10 +942,12 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
// Send coins to the nodes and mine 1 blocks to confirm them. // Send coins to the nodes and mine 1 blocks to confirm them.
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, alice)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, bob)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, carol)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, dave)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve) ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve)
ht.MineBlocksAndAssertNumTxes(1, 3) ht.MineBlocksAndAssertNumTxes(1, 5)
} }
const paymentAmt = btcutil.Amount(300000) const paymentAmt = btcutil.Amount(300000)
@@ -1107,11 +1119,11 @@ func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
// between him and the introduction node. So we expect that Carol is chosen as // between him and the introduction node. So we expect that Carol is chosen as
// the intro node and that one dummy hops is appended. // the intro node and that one dummy hops is appended.
func testBlindedRouteDummyHops(ht *lntest.HarnessTest) { func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
// Disable route blinding for Bob so that he is never chosen as the // Disable route blinding for Bob so that he is never chosen as the
// introduction node. // introduction node.
ht.RestartNodeWithExtraArgs(bob, []string{ bob := ht.NewNodeWithCoins("Bob", []string{
"--protocol.no-route-blinding", "--protocol.no-route-blinding",
}) })
@@ -1278,7 +1290,8 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
// \ / // \ /
// --- Carol --- // --- Carol ---
func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) { func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
// Create a four-node context consisting of Alice, Bob and three new // Create a four-node context consisting of Alice, Bob and three new
// nodes. // nodes.
@@ -1440,8 +1453,6 @@ 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()
@@ -1449,6 +1460,8 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
// Set up network with carol interceptor. // Set up network with carol interceptor.
testCase.setupNetwork(ctx, true) testCase.setupNetwork(ctx, true)
alice, bob := testCase.alice, testCase.bob
// Let dave create invoice. // Let dave create invoice.
blindedPaymentPath := testCase.buildBlindedPath() blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath) route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
@@ -1465,7 +1478,7 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
go func() { go func() {
defer close(done) defer close(done)
htlcAttempt, err := testCase.ht.Alice.RPC.Router.SendToRouteV2( htlcAttempt, err := testCase.alice.RPC.Router.SendToRouteV2(
ctx, sendReq, ctx, sendReq,
) )
require.NoError(testCase.ht, err) require.NoError(testCase.ht, err)
+27 -12
View File
@@ -317,9 +317,8 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
opts = append(opts, "--db.no-graph-cache") opts = append(opts, "--db.no-graph-cache")
} }
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", opts)
ht.RestartNodeWithExtraArgs(alice, opts) bob := ht.NewNodeWithCoins("Bob", opts)
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
const chanAmt = btcutil.Amount(100000) const chanAmt = btcutil.Amount(100000)
@@ -417,7 +416,10 @@ func testSendToRouteErrorPropagation(ht *lntest.HarnessTest) {
// 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.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointAlice := ht.OpenChannel( chanPointAlice := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt}, alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
) )
@@ -496,7 +498,10 @@ func testPrivateChannels(ht *lntest.HarnessTest) {
// where the 100k channel between Carol and Alice is private. // where the 100k channel between Carol and Alice is private.
// Open a channel with 200k satoshis between Alice and Bob. // Open a channel with 200k satoshis between Alice and Bob.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointAlice := ht.OpenChannel( chanPointAlice := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt * 2}, alice, bob, lntest.OpenChannelParams{Amt: chanAmt * 2},
) )
@@ -618,7 +623,10 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
// throughout this test. We'll include a push amount since we currently // throughout this test. We'll include a push amount since we currently
// require channels to have enough remote balance to cover the // require channels to have enough remote balance to cover the
// invoice's payment. // invoice's payment.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointBob := ht.OpenChannel( chanPointBob := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{ alice, bob, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
@@ -750,7 +758,7 @@ 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 bob := ht.NewNodeWithCoins("Bob", nil)
const chanAmt = btcutil.Amount(800000) const chanAmt = btcutil.Amount(800000)
@@ -948,7 +956,10 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// First, we'll open a private channel between Alice and Bob with Alice // First, we'll open a private channel between Alice and Bob with Alice
// being the funder. // being the funder.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointAlice := ht.OpenChannel( chanPointAlice := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{ alice, bob, lntest.OpenChannelParams{
Amt: chanAmt, Amt: chanAmt,
@@ -958,7 +969,7 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// Next, we'll create Carol's node and open a public channel between // Next, we'll create Carol's node and open a public channel between
// her and Bob with Bob being the funder. // her and Bob with Bob being the funder.
carol := ht.NewNode("Carol", nil) carol := ht.NewNodeWithCoins("Carol", nil)
ht.ConnectNodes(bob, carol) ht.ConnectNodes(bob, carol)
chanPointBob := ht.OpenChannel( chanPointBob := ht.OpenChannel(
bob, carol, lntest.OpenChannelParams{ bob, carol, lntest.OpenChannelParams{
@@ -973,7 +984,6 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// him and Carol with Carol being the funder. // him and Carol with Carol being the funder.
dave := ht.NewNode("Dave", nil) dave := ht.NewNode("Dave", nil)
ht.ConnectNodes(carol, dave) ht.ConnectNodes(carol, dave)
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := ht.OpenChannel( chanPointCarol := ht.OpenChannel(
carol, dave, lntest.OpenChannelParams{ carol, dave, lntest.OpenChannelParams{
@@ -1050,7 +1060,9 @@ func testQueryRoutes(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(100000) const chanAmt = btcutil.Amount(100000)
// Grab Alice and Bob from the standby nodes. // Grab Alice and Bob from the standby nodes.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// Create Carol and connect her to Bob. We also send her some coins for // Create Carol and connect her to Bob. We also send her some coins for
// channel opening. // channel opening.
@@ -1353,7 +1365,10 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(100000) const chanAmt = btcutil.Amount(100000)
// Open a channel between Alice and Bob. // Open a channel between Alice and Bob.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
chanPointAliceBob := ht.OpenChannel( chanPointAliceBob := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt}, alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
) )
+3 -3
View File
@@ -25,7 +25,7 @@ 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) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
runDeriveSharedKey(ht, alice) runDeriveSharedKey(ht, alice)
} }
@@ -199,7 +199,7 @@ 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) {
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
runSignOutputRaw(ht, alice) runSignOutputRaw(ht, alice)
} }
@@ -381,7 +381,7 @@ 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) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
runSignVerifyMessage(ht, alice) runSignVerifyMessage(ht, alice)
} }
+4 -3
View File
@@ -18,10 +18,11 @@ func testSingleHopInvoice(ht *lntest.HarnessTest) {
// 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.
chanAmt := btcutil.Amount(100000) chanAmt := btcutil.Amount(100000)
alice, bob := ht.Alice, ht.Bob chanPoints, nodes := ht.CreateSimpleNetwork(
cp := ht.OpenChannel( [][]string{nil, nil}, lntest.OpenChannelParams{Amt: chanAmt},
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
) )
cp := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// assertAmountPaid is a helper closure that asserts the amount paid by // assertAmountPaid is a helper closure that asserts the amount paid by
// Alice and received by Bob are expected. // Alice and received by Bob are expected.
+1 -1
View File
@@ -1558,7 +1558,7 @@ 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) {
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
runBumpFee(ht, alice) runBumpFee(ht, alice)
} }
+3 -1
View File
@@ -383,7 +383,9 @@ func setupScenarioFourNodes(ht *lntest.HarnessTest) *scenarioFourNodes {
} }
// Grab the standby nodes. // Grab the standby nodes.
alice, bob := ht.Alice, ht.Bob alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("bob", nil)
ht.ConnectNodes(alice, bob)
// As preliminary setup, we'll create two new nodes: Carol and Dave, // As preliminary setup, we'll create two new nodes: Carol and Dave,
// such that we now have a 4 node, 3 channel topology. Dave will make // such that we now have a 4 node, 3 channel topology. Dave will make
+1 -1
View File
@@ -49,7 +49,7 @@ 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) {
alice := ht.Alice alice := ht.NewNode("Alice", nil)
testTaprootSendCoinsKeySpendBip86(ht, alice) testTaprootSendCoinsKeySpendBip86(ht, alice)
testTaprootComputeInputScriptKeySpendBip86(ht, alice) testTaprootComputeInputScriptKeySpendBip86(ht, alice)
+12 -13
View File
@@ -14,21 +14,19 @@ import (
// testTrackPayments tests whether a client that calls the TrackPayments api // testTrackPayments tests whether a client that calls the TrackPayments api
// receives payment updates. // receives payment updates.
func testTrackPayments(ht *lntest.HarnessTest) { func testTrackPayments(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob // Create Alice with the new flag so she understands the new payment
// Restart Alice with the new flag so she understands the new payment
// status. // status.
ht.RestartNodeWithExtraArgs(alice, []string{ cfgAlice := []string{"--routerrpc.usestatusinitiated"}
"--routerrpc.usestatusinitiated", cfgs := [][]string{cfgAlice, nil}
})
// Open a channel between alice and bob. // Create a channel Alice->Bob.
ht.EnsureConnected(alice, bob) chanPoints, nodes := ht.CreateSimpleNetwork(
channel := ht.OpenChannel( cfgs, lntest.OpenChannelParams{
alice, bob, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000), Amt: btcutil.Amount(300000),
}, },
) )
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates. // Call the TrackPayments api to listen for payment updates.
req := &routerrpc.TrackPaymentsRequest{ req := &routerrpc.TrackPaymentsRequest{
@@ -104,12 +102,13 @@ func testTrackPayments(ht *lntest.HarnessTest) {
// is not set, the new Payment_INITIATED is replaced with Payment_IN_FLIGHT. // is not set, the new Payment_INITIATED is replaced with Payment_IN_FLIGHT.
func testTrackPaymentsCompatible(ht *lntest.HarnessTest) { func testTrackPaymentsCompatible(ht *lntest.HarnessTest) {
// Open a channel between alice and bob. // Open a channel between alice and bob.
alice, bob := ht.Alice, ht.Bob chanPoints, nodes := ht.CreateSimpleNetwork(
channel := ht.OpenChannel( [][]string{nil, nil}, lntest.OpenChannelParams{
alice, bob, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000), Amt: btcutil.Amount(300000),
}, },
) )
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates. // Call the TrackPayments api to listen for payment updates.
req := &routerrpc.TrackPaymentsRequest{ req := &routerrpc.TrackPaymentsRequest{
+2 -2
View File
@@ -582,7 +582,7 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,
// Send coins to Carol's address and confirm them, making sure the // Send coins to Carol's address and confirm them, making sure the
// balance updates accordingly. // balance updates accordingly.
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
req := &lnrpc.SendCoinsRequest{ req := &lnrpc.SendCoinsRequest{
Addr: externalAddr, Addr: externalAddr,
Amount: utxoAmt, Amount: utxoAmt,
@@ -694,7 +694,7 @@ func testWalletImportPubKeyScenario(ht *lntest.HarnessTest,
addrType walletrpc.AddressType) { addrType walletrpc.AddressType) {
const utxoAmt int64 = btcutil.SatoshiPerBitcoin const utxoAmt int64 = btcutil.SatoshiPerBitcoin
alice := ht.Alice alice := ht.NewNodeWithCoins("Alice", nil)
// We'll start our test by having two nodes, Carol and Dave. // We'll start our test by having two nodes, Carol and Dave.
// //
+3 -7
View File
@@ -39,7 +39,7 @@ 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 alice := ht.NewNode("Alice", nil)
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
@@ -240,7 +240,7 @@ 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 alice := ht.NewNode("Alice", nil)
const ( const (
chanAmt = funding.MaxBtcFundingAmount chanAmt = funding.MaxBtcFundingAmount
@@ -395,7 +395,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// protection logic automatically. // protection logic automatically.
daveArgs := lntest.NodeArgsForCommitType(commitType) daveArgs := lntest.NodeArgsForCommitType(commitType)
daveArgs = append(daveArgs, "--nolisten", "--wtclient.active") daveArgs = append(daveArgs, "--nolisten", "--wtclient.active")
dave := ht.NewNode("Dave", daveArgs) dave := ht.NewNodeWithCoins("Dave", daveArgs)
addTowerReq := &wtclientrpc.AddTowerRequest{ addTowerReq := &wtclientrpc.AddTowerRequest{
Pubkey: willyInfoPk, Pubkey: willyInfoPk,
@@ -407,10 +407,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// announcement, so we open a channel with Carol, // announcement, so we open a channel with Carol,
ht.ConnectNodes(dave, carol) ht.ConnectNodes(dave, carol)
// Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner.
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
// Send one more UTXOs if this is a neutrino backend. // Send one more UTXOs if this is a neutrino backend.
if ht.IsNeutrinoBackend() { if ht.IsNeutrinoBackend() {
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave) ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)
+5 -18
View File
@@ -27,25 +27,12 @@ func testWipeForwardingPackages(ht *lntest.HarnessTest) {
numInvoices = 3 numInvoices = 3
) )
// Grab Alice and Bob from HarnessTest. chanPoints, nodes := ht.CreateSimpleNetwork(
alice, bob := ht.Alice, ht.Bob [][]string{nil, nil, nil},
lntest.OpenChannelParams{Amt: chanAmt},
// Create a new node Carol, which will create invoices that require
// Alice to pay.
carol := ht.NewNode("Carol", nil)
// Connect Bob to Carol.
ht.ConnectNodes(bob, carol)
// Open a channel between Alice and Bob.
chanPointAB := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)
// Open a channel between Bob and Carol.
chanPointBC := ht.OpenChannel(
bob, carol, lntest.OpenChannelParams{Amt: chanAmt},
) )
chanPointAB, chanPointBC := chanPoints[0], chanPoints[1]
alice, bob, carol := nodes[0], nodes[1], nodes[2]
// Before we continue, make sure Alice has seen the channel between Bob // Before we continue, make sure Alice has seen the channel between Bob
// and Carol. // and Carol.
+1 -1
View File
@@ -753,7 +753,7 @@ func testPrivateUpdateAlias(ht *lntest.HarnessTest,
// testOptionScidUpgrade tests that toggling the option-scid-alias feature bit // testOptionScidUpgrade tests that toggling the option-scid-alias feature bit
// correctly upgrades existing channels. // correctly upgrades existing channels.
func testOptionScidUpgrade(ht *lntest.HarnessTest) { func testOptionScidUpgrade(ht *lntest.HarnessTest) {
bob := ht.Bob bob := ht.NewNodeWithCoins("Bob", nil)
// Start carol with anchors only. // Start carol with anchors only.
carolArgs := []string{ carolArgs := []string{
+36
View File
@@ -603,6 +603,42 @@ func (h *HarnessTest) NewNode(name string,
return node return node
} }
// NewNodeWithCoins creates a new node and asserts its creation. The node is
// guaranteed to have finished its initialization and all its subservers are
// started. In addition, 5 UTXO of 1 BTC each are sent to the node.
func (h *HarnessTest) NewNodeWithCoins(name string,
extraArgs []string) *node.HarnessNode {
node, err := h.manager.newNode(h.T, name, extraArgs, nil, false)
require.NoErrorf(h, err, "unable to create new node for %s", name)
// Start the node.
err = node.Start(h.runCtx)
require.NoError(h, err, "failed to start node %s", node.Name())
// Load up the wallets of the node with 5 outputs of 1 BTC each.
const (
numOutputs = 5
fundAmount = 1 * btcutil.SatoshiPerBitcoin
totalAmount = fundAmount * numOutputs
)
for i := 0; i < numOutputs; i++ {
h.createAndSendOutput(
node, fundAmount,
lnrpc.AddressType_WITNESS_PUBKEY_HASH,
)
}
// Mine a block to confirm the transactions.
h.MineBlocksAndAssertNumTxes(1, numOutputs)
// Now block until the wallet have fully synced up.
h.WaitForBalanceConfirmed(node, totalAmount)
return node
}
// Shutdown shuts down the given node and asserts that no errors occur. // Shutdown shuts down the given node and asserts that no errors occur.
func (h *HarnessTest) Shutdown(node *node.HarnessNode) { func (h *HarnessTest) Shutdown(node *node.HarnessNode) {
// The process may not be in a state to always shutdown immediately, so // The process may not be in a state to always shutdown immediately, so