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 2024-11-20 14:46:59 +08:00
parent 3eda87fff9
commit de8f14bed2
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
44 changed files with 321 additions and 250 deletions

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
// opened/closed.
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
// 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
// between them.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(carol, alice)
// Next, we'll open two channels between Alice and Carol back to back.

View File

@ -48,7 +48,8 @@ func testChannelBalance(ht *lntest.HarnessTest) {
}
// 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)
chanPoint := ht.OpenChannel(
@ -118,7 +119,7 @@ func testChannelUnsettledBalance(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", []string{"--hodl.exit-settle"})
// Connect Alice to Carol.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)
// Open a channel between Alice and Carol.

View File

@ -771,7 +771,7 @@ func testFailingChannel(ht *lntest.HarnessTest) {
// totally unrelated preimage.
carol := ht.NewNode("Carol", []string{"--hodl.bogus-settle"})
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)
// Let Alice connect and open a channel to Carol,

View File

@ -218,7 +218,9 @@ func testUpdateChanStatus(ht *lntest.HarnessTest) {
// describeGraph RPC request unless explicitly asked for.
func testUnannouncedChannels(ht *lntest.HarnessTest) {
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
// 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
// starting Alice to test pinned syncing.
bob := ht.Bob
bob := ht.NewNodeWithCoins("Bob", nil)
bobInfo := bob.RPC.GetInfo()
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
// pubkey to include in his pinned syncer set.
var aliceArgs []string
@ -285,8 +283,7 @@ func testGraphTopologyNtfns(ht *lntest.HarnessTest, pinned bool) {
}
}
alice := ht.Alice
ht.RestartNodeWithExtraArgs(alice, aliceArgs)
alice := ht.NewNodeWithCoins("Alice", aliceArgs)
// Connect Alice and 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
// announced to the network and reported in the network graph.
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{
"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
// with the right information after updating our node.
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

View File

@ -30,19 +30,16 @@ func testUpdateChannelPolicy(ht *lntest.HarnessTest) {
chanAmt := funding.MaxBtcFundingAmount
pushAmt := chanAmt / 2
alice, bob := ht.Alice, ht.Bob
// Create a channel Alice->Bob.
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
},
)
// We add all the nodes' update channels to a slice, such that we can
// make sure they all receive the expected updates.
nodes := []*node.HarnessNode{alice, bob}
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Alice and Bob should see each other's ChannelUpdates, advertising the
// 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) {
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
// 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,
// 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.
chanPointAliceBob := ht.OpenChannel(
@ -787,16 +787,14 @@ func testUpdateChannelPolicyFeeRateAccuracy(ht *lntest.HarnessTest) {
pushAmt := chanAmt / 2
// Create a channel Alice -> Bob.
alice, bob := ht.Alice, ht.Bob
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
},
)
// Nodes that we need to make sure receive the channel updates.
nodes := []*node.HarnessNode{alice, bob}
alice := nodes[0]
chanPoint := chanPoints[0]
baseFee := int64(1500)
timeLockDelta := uint32(66)

View File

@ -58,7 +58,8 @@ func testCoopCloseWithExternalDelivery(ht *lntest.HarnessTest) {
func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
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)
// Here we generate a final delivery address in bob's wallet but set by

View File

@ -37,7 +37,8 @@ func testCoopCloseWithHtlcs(ht *lntest.HarnessTest) {
// channel party initiates a channel shutdown while an HTLC is still pending on
// the channel.
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)
// 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
// one party has already initiated the shutdown.
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)
// Open a channel between Alice and Bob with the balance split equally.

View File

@ -13,8 +13,6 @@ import (
// sets. For completeness, it also asserts that features aren't set in places
// where they aren't intended to be.
func testCustomFeatures(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
var (
// Odd custom features so that we don't need to worry about
// issues connecting to peers.
@ -29,14 +27,13 @@ func testCustomFeatures(ht *lntest.HarnessTest) {
fmt.Sprintf("--protocol.custom-nodeann=%v", customNodeAnn),
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
// in Bob's graph.
ht.ConnectNodes(alice, bob)
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: 1000000},
chanPoints, nodes := ht.CreateSimpleNetwork(
cfgs, 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
// message.

View File

@ -14,8 +14,6 @@ import (
// types (within the message type range usually reserved for protocol messages)
// via the send and subscribe custom message APIs.
func testCustomMessage(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
var (
overrideType1 uint32 = 554
overrideType2 uint32 = 555
@ -27,7 +25,8 @@ func testCustomMessage(ht *lntest.HarnessTest) {
extraArgs := []string{
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
// don't miss any.

View File

@ -24,7 +24,8 @@ func testExperimentalEndorsement(ht *lntest.HarnessTest) {
// testEndorsement sets up a 5 hop network and tests propagation of
// experimental endorsement signals.
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", []string{"--protocol.no-experimental-endorsement"},
)

View File

@ -765,7 +765,9 @@ type interceptorTestScenario struct {
func newInterceptorTestScenario(
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)
dave := ht.NewNode("dave", nil)

View File

@ -282,8 +282,7 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
// We'll start off by creating a node for Carol.
carol := ht.NewNode("Carol", nil)
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// We'll send her some unconfirmed funds.
ht.FundCoinsUnconfirmed(2*chanAmt, carol)
@ -402,7 +401,7 @@ func testUnconfirmedChannelFunding(ht *lntest.HarnessTest) {
// testChannelFundingInputTypes tests that any type of supported input type can
// be used to fund channels.
func testChannelFundingInputTypes(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// We'll start off by creating a node for Carol.
carol := ht.NewNode("Carol", nil)
@ -841,7 +840,7 @@ func testChannelFundingPersistence(ht *lntest.HarnessTest) {
}
carol := ht.NewNode("Carol", carolArgs)
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)
// 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)
alice, bob := ht.Alice, ht.Bob
ht.RestartNodeWithExtraArgs(alice, scidAliasArgs)
alice := ht.NewNodeWithCoins("Alice", scidAliasArgs)
bob := ht.NewNodeWithCoins("Bob", nil)
// 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).

View File

@ -17,10 +17,11 @@ import (
// would otherwise trigger force closes when they expire.
func testHoldInvoiceForceClose(ht *lntest.HarnessTest) {
// Open a channel between alice and bob.
alice, bob := ht.Alice, ht.Bob
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: 300000},
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{Amt: 300000},
)
alice, bob := nodes[0], nodes[1]
chanPoint := chanPoints[0]
// Create a non-dust hold invoice for bob.
var (

View File

@ -28,7 +28,9 @@ func testHoldInvoicePersistence(ht *lntest.HarnessTest) {
carol := ht.NewNode("Carol", nil)
// 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)
// Open a channel between Alice and Carol which is private so that we

View File

@ -14,7 +14,7 @@ import (
func testLookupHtlcResolution(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(1000000)
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
carol := ht.NewNode("Carol", []string{
"--store-final-htlc-resolutions",
})

View File

@ -251,7 +251,8 @@ type acceptorTestScenario struct {
//
// Among them, Alice and Bob are standby nodes and Carol is a new node.
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)
ht.EnsureConnected(alice, bob)

View File

@ -29,7 +29,7 @@ func testMacaroonAuthentication(ht *lntest.HarnessTest) {
newAddrReq = &lnrpc.NewAddressRequest{
Type: AddrTypeWitnessPubkeyHash,
}
testNode = ht.Alice
testNode = ht.NewNode("Alice", nil)
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
// permissions.
func testBakeMacaroon(ht *lntest.HarnessTest) {
var testNode = ht.Alice
var testNode = ht.NewNode("Alice", nil)
testCases := []struct {
name string
@ -521,7 +521,7 @@ func testBakeMacaroon(ht *lntest.HarnessTest) {
func testDeleteMacaroonID(ht *lntest.HarnessTest) {
var (
ctxb = ht.Context()
testNode = ht.Alice
testNode = ht.NewNode("Alice", nil)
)
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()

View File

@ -19,25 +19,21 @@ func testMaxHtlcPathfind(ht *lntest.HarnessTest) {
// Bob to add a maximum of 5 htlcs to her commitment.
maxHtlcs := 5
alice, bob := ht.Alice, ht.Bob
// Restart nodes with the new flag so they understand the new payment
// Create nodes with the new flag so they understand the new payment
// status.
ht.RestartNodeWithExtraArgs(alice, []string{
"--routerrpc.usestatusinitiated",
})
ht.RestartNodeWithExtraArgs(bob, []string{
"--routerrpc.usestatusinitiated",
})
cfg := []string{"--routerrpc.usestatusinitiated"}
cfgs := [][]string{cfg, cfg}
ht.EnsureConnected(alice, bob)
chanPoint := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
// Create a channel Alice->Bob.
chanPoints, nodes := ht.CreateSimpleNetwork(
cfgs, lntest.OpenChannelParams{
Amt: 1000000,
PushAmt: 800000,
RemoteMaxHtlcs: uint16(maxHtlcs),
},
)
chanPoint := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Alice and bob should have one channel open with each other now.
ht.AssertNodeNumChannels(alice, 1)

View File

@ -39,9 +39,8 @@ func testDisconnectingTargetPeer(ht *lntest.HarnessTest) {
"--maxbackoff=1m",
}
alice, bob := ht.Alice, ht.Bob
ht.RestartNodeWithExtraArgs(alice, args)
ht.RestartNodeWithExtraArgs(bob, args)
alice := ht.NewNodeWithCoins("Alice", args)
bob := ht.NewNodeWithCoins("Bob", args)
// Start by connecting Alice and Bob with no channels.
ht.EnsureConnected(alice, bob)
@ -239,17 +238,11 @@ func testListChannels(ht *lntest.HarnessTest) {
const aliceRemoteMaxHtlcs = 50
const bobRemoteMaxHtlcs = 100
// Get the standby nodes and open a channel between them.
alice, bob := ht.Alice, ht.Bob
args := []string{fmt.Sprintf(
"--default-remote-max-htlcs=%v",
bobRemoteMaxHtlcs,
)}
ht.RestartNodeWithExtraArgs(bob, args)
// Connect Alice to Bob.
ht.EnsureConnected(alice, bob)
cfgs := [][]string{nil, args}
// 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
@ -264,8 +257,10 @@ func testListChannels(ht *lntest.HarnessTest) {
MinHtlc: customizedMinHtlc,
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.
ht.AssertNodeNumChannels(alice, 1)
@ -369,7 +364,7 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
}
carol := ht.NewNode("Carol", args)
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, carol)
carolBalance := btcutil.Amount(maxPendingChannels) * amount
@ -439,7 +434,9 @@ func testMaxPendingChannels(ht *lntest.HarnessTest) {
func testGarbageCollectLinkNodes(ht *lntest.HarnessTest) {
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
// cooperatively closed.
@ -553,7 +550,8 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
// Alice ------> Carol ------> Bob
//
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.
carol := ht.NewNode("Carol", []string{"--rejecthtlc"})
@ -649,15 +647,16 @@ func testRejectHTLC(ht *lntest.HarnessTest) {
func testNodeSignVerify(ht *lntest.HarnessTest) {
chanAmt := funding.MaxBtcFundingAmount
pushAmt := btcutil.Amount(100000)
alice, bob := ht.Alice, ht.Bob
p := lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
}
// Create a channel between alice and bob.
aliceBobCh := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
Amt: chanAmt,
PushAmt: pushAmt,
},
)
cfgs := [][]string{nil, nil}
chanPoints, nodes := ht.CreateSimpleNetwork(cfgs, p)
alice, bob := nodes[0], nodes[1]
aliceBobCh := chanPoints[0]
// alice signs "alice msg" and sends her signature to bob.
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
// abandoned channel is reported as closed with close type 'abandoned'.
func testAbandonChannel(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// First establish a channel between Alice and Bob.
channelParam := lntest.OpenChannelParams{
Amt: funding.MaxBtcFundingAmount,
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
// 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
// wallet into a single target address at the specified fee rate.
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
// sweeping.
@ -1162,7 +1164,8 @@ func assertChannelConstraintsEqual(ht *lntest.HarnessTest,
// on a message with a provided address.
func testSignVerifyMessageWithAddr(ht *lntest.HarnessTest) {
// 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.
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
// invoices to the new SQL schema.
func testNativeSQLNoMigration(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// Make sure we run the test with SQLite or Postgres.
if alice.Cfg.DBBackend != node.BackendSqlite &&

View File

@ -180,8 +180,8 @@ type mppTestScenario struct {
// \ /
// \__ Dave ____/
func newMppTestScenario(ht *lntest.HarnessTest) *mppTestScenario {
alice, bob := ht.Alice, ht.Bob
ht.RestartNodeWithExtraArgs(bob, []string{
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", []string{
"--maxpendingchannels=2",
"--accept-amp",
})

View File

@ -15,7 +15,9 @@ func testHtlcErrorPropagation(ht *lntest.HarnessTest) {
// multi-hop payment.
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
// introduce another node into our test network: Carol.

View File

@ -18,7 +18,8 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
// channel with Alice, and Carol with Dave. After this setup, the
// network topology should now look like:
// 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"}
dave := ht.NewNode("Dave", daveArgs)
@ -37,6 +38,7 @@ func testMultiHopPayments(ht *lntest.HarnessTest) {
ht.AssertHtlcEventType(daveEvents, routerrpc.HtlcEvent_UNKNOWN)
// Connect the nodes.
ht.ConnectNodes(alice, bob)
ht.ConnectNodes(dave, alice)
ht.ConnectNodes(carol, dave)

View File

@ -126,7 +126,7 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
}
// Connect Alice to Dave and Charlie.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.ConnectNodes(alice, dave)
ht.ConnectNodes(alice, charlie)
@ -218,7 +218,7 @@ func testReconnectAfterIPChange(ht *lntest.HarnessTest) {
// testAddPeerConfig tests that the "--addpeer" config flag successfully adds
// a new peer.
func testAddPeerConfig(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
info := alice.RPC.GetInfo()
alicePeerAddress := info.Uris[0]

View File

@ -13,7 +13,7 @@ func testNeutrino(ht *lntest.HarnessTest) {
ht.Skipf("skipping test for non neutrino backends")
}
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// Check if the neutrino sub server is running.
statusRes := alice.RPC.Status(nil)

View File

@ -33,7 +33,7 @@ func testChainKit(ht *lntest.HarnessTest) {
// testChainKitGetBlock ensures that given a block hash, the RPC endpoint
// returns the correct target block.
func testChainKitGetBlock(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// Get best block hash.
bestBlockRes := alice.RPC.GetBestBlock(nil)
@ -63,7 +63,7 @@ func testChainKitGetBlock(ht *lntest.HarnessTest) {
// testChainKitGetBlockHeader ensures that given a block hash, the RPC endpoint
// returns the correct target block header.
func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// Get best block hash.
bestBlockRes := alice.RPC.GetBestBlock(nil)
@ -108,7 +108,7 @@ func testChainKitGetBlockHeader(ht *lntest.HarnessTest) {
// testChainKitGetBlockHash ensures that given a block height, the RPC endpoint
// returns the correct target block hash.
func testChainKitGetBlockHash(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
// Get best block hash.
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
// node to start with no UTXOs.
charlie := ht.NewNode("Charlie", args)
bob := ht.Bob
ht.RestartNodeWithExtraArgs(bob, args)
bob := ht.NewNode("Bob", args)
// We'll start the test by sending Charlie some coins.
fundingAmount := btcutil.Amount(100_000)
@ -222,12 +221,8 @@ func testAnchorReservedValue(ht *lntest.HarnessTest) {
// Start two nodes supporting anchor channels.
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)
bob := ht.Bob
ht.RestartNodeWithExtraArgs(bob, args)
bob := ht.NewNode("Bob", args)
ht.ConnectNodes(alice, bob)
// Send just enough coins for Alice to open a channel without a change

View File

@ -34,7 +34,9 @@ func testOpenChannelAfterReorg(ht *lntest.HarnessTest) {
tempMiner := ht.SpawnTempMiner()
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
// 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
// a payment through the channel we'll open with the different fee
// policies.
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
carol := ht.NewNode("Carol", nil)
alice, bob := ht.Alice, ht.Bob
nodes := []*node.HarnessNode{alice, bob, carol}
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
// to Alice.
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
st.FundCoins(btcutil.SatoshiPerBitcoin, carol)
runTestCase(
st, feeScenario,
@ -315,7 +318,9 @@ func testOpenChannelUpdateFeePolicy(ht *lntest.HarnessTest) {
// closing, and ensures that if a node is subscribed to channel updates they
// will be received correctly for both cooperative and force closed channels.
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)
}
@ -519,8 +524,8 @@ func testUpdateOnPendingOpenChannels(ht *lntest.HarnessTest) {
// processing the fundee's `channel_ready`, the HTLC will be cached and
// eventually settled.
func testUpdateOnFunderPendingOpenChannels(ht *lntest.HarnessTest) {
// Grab the channel participants.
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
// Restart Alice with the config so she won't process Bob's
// 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
// eventually settled.
func testUpdateOnFundeePendingOpenChannels(ht *lntest.HarnessTest) {
// Grab the channel participants.
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNode("Bob", nil)
// Restart Bob with the config so he won't process Alice's
// channel_ready msg immediately.
@ -746,7 +751,10 @@ func verifyCloseUpdate(chanUpdate *lnrpc.ChannelEventUpdate,
// before the funding transaction is confirmed, that the FundingExpiryBlocks
// field of a PendingChannels decreases.
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}
update := ht.OpenChannelAssertPending(alice, bob, param)
@ -844,7 +852,6 @@ func testSimpleTaprootChannelActivation(ht *lntest.HarnessTest) {
// up as locked balance in the WalletBalance response.
func testOpenChannelLockedBalance(ht *lntest.HarnessTest) {
var (
bob = ht.Bob
req *lnrpc.ChannelAcceptRequest
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
// locked later.
alice := ht.NewNode("alice", nil)
bob := ht.NewNode("bob", nil)
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
// Connect the nodes.

View File

@ -346,7 +346,8 @@ func runTestPaymentHTLCTimeout(ht *lntest.HarnessTest, restartAlice bool) {
// to return floor fee rate(1 sat/vb).
func testSendDirectPayment(ht *lntest.HarnessTest) {
// 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.
commitmentTypes := []lnrpc.CommitmentType{
@ -466,7 +467,9 @@ func testSendDirectPayment(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.
ht.AssertNumPayments(alice, 0)
@ -658,7 +661,10 @@ func testPaymentFollowingChannelOpen(ht *lntest.HarnessTest) {
channelCapacity := paymentAmt * 1000
// 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{
Amt: channelCapacity,
}
@ -934,7 +940,9 @@ func testBidirectionalAsyncPayments(ht *lntest.HarnessTest) {
func testInvoiceSubscriptions(ht *lntest.HarnessTest) {
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
// should be dispatched shortly below.

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
// the funding flow can be properly executed.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.EnsureConnected(carol, dave)
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
// the funding flow can be properly executed.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
ht.EnsureConnected(carol, dave)
ht.EnsureConnected(carol, alice)
@ -517,8 +517,7 @@ func runPsbtChanFundingSingleStep(ht *lntest.HarnessTest, carol,
const chanSize = funding.MaxBtcFundingAmount
alice := ht.Alice
ht.FundCoins(btcutil.SatoshiPerBitcoin, alice)
alice := ht.NewNodeWithCoins("Alice", nil)
// Get new address for anchor reserve.
req := &lnrpc.NewAddressRequest{
@ -697,7 +696,8 @@ func testSignPsbt(ht *lntest.HarnessTest) {
for _, tc := range psbtTestRunners {
succeed := ht.Run(tc.name, func(t *testing.T) {
st := ht.Subtest(t)
tc.runner(st, st.Alice)
alice := st.NewNodeWithCoins("Alice", nil)
tc.runner(st, alice)
})
// 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
// wallet to perform coin selection.
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
// 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
// because we can easily let the remote peer run into the timeout.
func testPsbtChanFundingFailFlow(ht *lntest.HarnessTest) {
alice := ht.Alice
bob := ht.Bob
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
const chanSize = funding.MaxBtcFundingAmount

View File

@ -16,7 +16,8 @@ import (
// 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.
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{
Amt: btcutil.Amount(1000000),

View File

@ -17,7 +17,8 @@ func testResHandoff(ht *lntest.HarnessTest) {
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.
ht.EnsureConnected(alice, bob)

View File

@ -212,13 +212,13 @@ func testRestAPI(ht *lntest.HarnessTest) {
// 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
// can test them without waiting half a minute.
alice, bob := ht.Alice, ht.Bob
alice.Cfg.ExtraArgs = append(
alice.Cfg.ExtraArgs, "--restcors=\"*\"",
bob := ht.NewNode("Bob", nil)
args := []string{
"--restcors=\"*\"",
fmt.Sprintf("--ws-ping-interval=%s", pingInterval),
fmt.Sprintf("--ws-pong-wait=%s", pongWait),
)
ht.RestartNode(alice)
}
alice := ht.NewNodeWithCoins("Alice", args)
for _, tc := range testCases {
tc := tc
@ -237,7 +237,7 @@ func testRestAPI(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.
hash, height := ht.GetBestBlock()
@ -328,7 +328,7 @@ func wsTestCaseSubscriptionMacaroon(ht *lntest.HarnessTest) {
// This time we send the macaroon in the special header
// Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket.
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout,
)
@ -413,7 +413,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
// This time we send the macaroon in the special header
// Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket.
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout,
)
@ -522,7 +522,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
// Before we start opening channels, make sure the two nodes are
// connected.
bob := ht.Bob
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// 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
// Sec-Websocket-Protocol which is the only header field available to
// browsers when opening a WebSocket.
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
mac, err := alice.ReadMacaroon(
alice.Cfg.AdminMacPath, defaultTimeout,
)

View File

@ -26,11 +26,9 @@ import (
// expected. It also includes the edge case of a single-hop blinded route,
// which indicates that the introduction node is the recipient.
func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
var (
// Convenience aliases.
alice = ht.Alice
bob = ht.Bob
)
alice := ht.NewNodeWithCoins("Alice", nil)
bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob)
// Setup a two hop channel network: Alice -- Bob -- Carol.
// We set our proportional fee for these channels to zero, so that
@ -318,6 +316,8 @@ func testQueryBlindedRoutes(ht *lntest.HarnessTest) {
type blindedForwardTest struct {
ht *lntest.HarnessTest
alice *node.HarnessNode
bob *node.HarnessNode
carol *node.HarnessNode
dave *node.HarnessNode
channels []*lnrpc.ChannelPoint
@ -349,11 +349,24 @@ func newBlindedForwardTest(ht *lntest.HarnessTest) (context.Context,
func (b *blindedForwardTest) setupNetwork(ctx context.Context,
withInterceptor bool) {
const chanAmt = btcutil.Amount(100_000)
carolArgs := []string{"--bitcoin.timelockdelta=18"}
if withInterceptor {
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 {
var err error
@ -362,10 +375,6 @@ func (b *blindedForwardTest) setupNetwork(ctx context.Context,
)
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
@ -395,7 +404,7 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
require.Len(b.ht, payReq.BlindedPaths, 1)
path := payReq.BlindedPaths[0].BlindedPath
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]
}
@ -403,8 +412,8 @@ func (b *blindedForwardTest) buildBlindedPath() *lnrpc.BlindedPaymentPath {
// cleanup tears down all channels created by the test and cancels the top
// level context used in the test.
func (b *blindedForwardTest) cleanup() {
b.ht.CloseChannel(b.ht.Alice, b.channels[0])
b.ht.CloseChannel(b.ht.Bob, b.channels[1])
b.ht.CloseChannel(b.alice, b.channels[0])
b.ht.CloseChannel(b.bob, b.channels[1])
b.ht.CloseChannel(b.carol, b.channels[2])
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.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)
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
// finished.
@ -481,7 +490,7 @@ func (b *blindedForwardTest) sendToRoute(route *lnrpc.Route,
// Let Alice send to the blinded payment path and assert that it
// succeeds/fails.
htlcAttempt := b.ht.Alice.RPC.SendToRouteV2(sendReq)
htlcAttempt := b.alice.RPC.SendToRouteV2(sendReq)
if assertSuccess {
require.Nil(b.ht, htlcAttempt.Failure)
require.Equal(b.ht, htlcAttempt.Status,
@ -498,7 +507,7 @@ func (b *blindedForwardTest) sendToRoute(route *lnrpc.Route,
require.NoError(b.ht, err)
pmt := b.ht.AssertPaymentStatus(
b.ht.Alice, preimage, lnrpc.Payment_FAILED,
b.alice, preimage, lnrpc.Payment_FAILED,
)
require.Len(b.ht, pmt.Htlcs, 1)
@ -520,7 +529,7 @@ func (b *blindedForwardTest) drainCarolLiquidity(incoming bool) {
receivingNode := b.dave
if incoming {
sendingNode = b.ht.Bob
sendingNode = b.bob
receivingNode = b.carol
}
@ -556,7 +565,8 @@ func (b *blindedForwardTest) drainCarolLiquidity(incoming bool) {
func setupFourHopNetwork(ht *lntest.HarnessTest,
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)
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
// payment.
func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
alice := ht.Alice
ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup()
@ -620,6 +628,8 @@ func testBlindedRouteInvoices(ht *lntest.HarnessTest) {
// blinded path that uses Bob as an introduction node.
testCase.setupNetwork(ctx, false)
alice := testCase.alice
// Let Dave add a blinded invoice.
// Add restrictions so that he only ever creates a single blinded path
// 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
// has insufficient outgoing liquidity to forward on to carol.
func testIntroductionNodeError(ht *lntest.HarnessTest) {
bob := ht.Bob
ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup()
testCase.setupNetwork(ctx, false)
blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
bob := testCase.bob
// 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
// at the introduction node.
@ -770,8 +780,6 @@ func testIntroductionNodeError(ht *lntest.HarnessTest) {
// testDisableIntroductionNode tests disabling of blinded forwards for the
// introduction node.
func testDisableIntroductionNode(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// First construct a blinded route while Bob is still advertising the
// route blinding feature bit to ensure that Bob is included in the
// blinded path that Dave selects.
@ -781,6 +789,8 @@ func testDisableIntroductionNode(ht *lntest.HarnessTest) {
blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
alice, bob := testCase.alice, testCase.bob
// Now, disable route blinding for Bob, then re-connect to Alice.
ht.RestartNodeWithExtraArgs(bob, []string{
"--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
// infrastructure in place already for error testing.
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
// because we're going to close a channel, so we'll close out the
// rest manually.
@ -811,6 +819,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
50_000_000, blindedPaymentPath,
)
alice, bob := testCase.alice, testCase.bob
// Once our interceptor is set up, we can send the blinded payment.
cancelPmt := testCase.sendBlindedPayment(ctx, blindedRoute)
defer cancelPmt()
@ -917,8 +927,8 @@ func testErrorHandlingOnChainFailure(ht *lntest.HarnessTest) {
func testMPPToSingleBlindedPath(ht *lntest.HarnessTest) {
// Create a five-node context consisting of Alice, Bob and three new
// nodes.
alice, bob := ht.Alice, ht.Bob
alice := ht.NewNode("Alice", nil)
bob := ht.NewNode("Bob", nil)
dave := ht.NewNode("dave", nil)
carol := ht.NewNode("carol", 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.
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, dave)
ht.FundCoinsUnconfirmed(btcutil.SatoshiPerBitcoin, eve)
ht.MineBlocksAndAssertNumTxes(1, 3)
ht.MineBlocksAndAssertNumTxes(1, 5)
}
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
// the intro node and that one dummy hops is appended.
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
// introduction node.
ht.RestartNodeWithExtraArgs(bob, []string{
bob := ht.NewNodeWithCoins("Bob", []string{
"--protocol.no-route-blinding",
})
@ -1278,7 +1290,8 @@ func testBlindedRouteDummyHops(ht *lntest.HarnessTest) {
// \ /
// --- Carol ---
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
// nodes.
@ -1440,8 +1453,6 @@ func testMPPToMultipleBlindedPaths(ht *lntest.HarnessTest) {
// UpdateAddHTLC which we need to ensure gets included in the message on
// restart.
func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// Setup a test case.
ctx, testCase := newBlindedForwardTest(ht)
defer testCase.cleanup()
@ -1449,6 +1460,8 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
// Set up network with carol interceptor.
testCase.setupNetwork(ctx, true)
alice, bob := testCase.alice, testCase.bob
// Let dave create invoice.
blindedPaymentPath := testCase.buildBlindedPath()
route := testCase.createRouteToBlinded(10_000_000, blindedPaymentPath)
@ -1465,7 +1478,7 @@ func testBlindedPaymentHTLCReForward(ht *lntest.HarnessTest) {
go func() {
defer close(done)
htlcAttempt, err := testCase.ht.Alice.RPC.Router.SendToRouteV2(
htlcAttempt, err := testCase.alice.RPC.Router.SendToRouteV2(
ctx, sendReq,
)
require.NoError(testCase.ht, err)

View File

@ -317,9 +317,8 @@ func runMultiHopSendToRoute(ht *lntest.HarnessTest, useGraphCache bool) {
opts = append(opts, "--db.no-graph-cache")
}
alice, bob := ht.Alice, ht.Bob
ht.RestartNodeWithExtraArgs(alice, opts)
alice := ht.NewNodeWithCoins("Alice", opts)
bob := ht.NewNodeWithCoins("Bob", opts)
ht.EnsureConnected(alice, bob)
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
// 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(
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.
// 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(
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
// require channels to have enough remote balance to cover the
// 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(
alice, bob, lntest.OpenChannelParams{
Amt: chanAmt,
@ -750,7 +758,7 @@ func testInvoiceRoutingHints(ht *lntest.HarnessTest) {
// testScidAliasRoutingHints tests that dynamically created aliases via the RPC
// are properly used when routing.
func testScidAliasRoutingHints(ht *lntest.HarnessTest) {
bob := ht.Bob
bob := ht.NewNodeWithCoins("Bob", nil)
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
// 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(
alice, bob, lntest.OpenChannelParams{
Amt: chanAmt,
@ -958,7 +969,7 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// Next, we'll create Carol's node and open a public channel between
// her and Bob with Bob being the funder.
carol := ht.NewNode("Carol", nil)
carol := ht.NewNodeWithCoins("Carol", nil)
ht.ConnectNodes(bob, carol)
chanPointBob := ht.OpenChannel(
bob, carol, lntest.OpenChannelParams{
@ -973,7 +984,6 @@ func testMultiHopOverPrivateChannels(ht *lntest.HarnessTest) {
// him and Carol with Carol being the funder.
dave := ht.NewNode("Dave", nil)
ht.ConnectNodes(carol, dave)
ht.FundCoins(btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := ht.OpenChannel(
carol, dave, lntest.OpenChannelParams{
@ -1050,7 +1060,9 @@ func testQueryRoutes(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(100000)
// 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
// channel opening.
@ -1353,7 +1365,10 @@ func testRouteFeeCutoff(ht *lntest.HarnessTest) {
const chanAmt = btcutil.Amount(100000)
// 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(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
)

View File

@ -25,7 +25,7 @@ import (
// the node's pubkey and a customized public key to check the validity of the
// result.
func testDeriveSharedKey(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
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
// custom ways of specifying the signing key in the key descriptor/locator.
func testSignOutputRaw(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
runSignOutputRaw(ht, alice)
}
@ -381,7 +381,7 @@ func assertSignOutputRaw(ht *lntest.HarnessTest,
// all custom flags by verifying with VerifyMessage. Tests both ECDSA and
// Schnorr signatures.
func testSignVerifyMessage(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
runSignVerifyMessage(ht, alice)
}

View File

@ -18,10 +18,11 @@ func testSingleHopInvoice(ht *lntest.HarnessTest) {
// Open a channel with 100k satoshis between Alice and Bob with Alice
// being the sole funder of the channel.
chanAmt := btcutil.Amount(100000)
alice, bob := ht.Alice, ht.Bob
cp := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{Amt: chanAmt},
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{Amt: chanAmt},
)
cp := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// assertAmountPaid is a helper closure that asserts the amount paid by
// Alice and received by Bob are expected.

View File

@ -1558,7 +1558,7 @@ func testSweepCommitOutputAndAnchor(ht *lntest.HarnessTest) {
// CPFP, then RBF. Along the way, we check the `BumpFee` can properly update
// the fee function used by supplying new params.
func testBumpFee(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
runBumpFee(ht, alice)
}

View File

@ -383,7 +383,9 @@ func setupScenarioFourNodes(ht *lntest.HarnessTest) *scenarioFourNodes {
}
// 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,
// such that we now have a 4 node, 3 channel topology. Dave will make

View File

@ -49,7 +49,7 @@ var (
// testTaproot ensures that the daemon can send to and spend from taproot (p2tr)
// outputs.
func testTaproot(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
testTaprootSendCoinsKeySpendBip86(ht, alice)
testTaprootComputeInputScriptKeySpendBip86(ht, alice)

View File

@ -14,21 +14,19 @@ import (
// testTrackPayments tests whether a client that calls the TrackPayments api
// receives payment updates.
func testTrackPayments(ht *lntest.HarnessTest) {
alice, bob := ht.Alice, ht.Bob
// Restart Alice with the new flag so she understands the new payment
// Create Alice with the new flag so she understands the new payment
// status.
ht.RestartNodeWithExtraArgs(alice, []string{
"--routerrpc.usestatusinitiated",
})
cfgAlice := []string{"--routerrpc.usestatusinitiated"}
cfgs := [][]string{cfgAlice, nil}
// Open a channel between alice and bob.
ht.EnsureConnected(alice, bob)
channel := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
// Create a channel Alice->Bob.
chanPoints, nodes := ht.CreateSimpleNetwork(
cfgs, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000),
},
)
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates.
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.
func testTrackPaymentsCompatible(ht *lntest.HarnessTest) {
// Open a channel between alice and bob.
alice, bob := ht.Alice, ht.Bob
channel := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil}, lntest.OpenChannelParams{
Amt: btcutil.Amount(300000),
},
)
channel := chanPoints[0]
alice, bob := nodes[0], nodes[1]
// Call the TrackPayments api to listen for payment updates.
req := &routerrpc.TrackPaymentsRequest{

View File

@ -582,7 +582,7 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,
// Send coins to Carol's address and confirm them, making sure the
// balance updates accordingly.
alice := ht.Alice
alice := ht.NewNodeWithCoins("Alice", nil)
req := &lnrpc.SendCoinsRequest{
Addr: externalAddr,
Amount: utxoAmt,
@ -694,7 +694,7 @@ func testWalletImportPubKeyScenario(ht *lntest.HarnessTest,
addrType walletrpc.AddressType) {
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.
//

View File

@ -39,7 +39,7 @@ var watchtowerTestCases = []*lntest.TestCase{
// testTowerClientTowerAndSessionManagement tests the various control commands
// that a user has over the client's set of active towers and sessions.
func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
const (
chanAmt = funding.MaxBtcFundingAmount
@ -240,7 +240,7 @@ func testTowerClientTowerAndSessionManagement(ht *lntest.HarnessTest) {
// testTowerClientSessionDeletion tests that sessions are correctly deleted
// when they are deemed closable.
func testTowerClientSessionDeletion(ht *lntest.HarnessTest) {
alice := ht.Alice
alice := ht.NewNode("Alice", nil)
const (
chanAmt = funding.MaxBtcFundingAmount
@ -395,7 +395,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// protection logic automatically.
daveArgs := lntest.NodeArgsForCommitType(commitType)
daveArgs = append(daveArgs, "--nolisten", "--wtclient.active")
dave := ht.NewNode("Dave", daveArgs)
dave := ht.NewNodeWithCoins("Dave", daveArgs)
addTowerReq := &wtclientrpc.AddTowerRequest{
Pubkey: willyInfoPk,
@ -407,10 +407,6 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(ht *lntest.HarnessTest,
// announcement, so we open a channel with 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.
if ht.IsNeutrinoBackend() {
ht.FundCoins(btcutil.SatoshiPerBitcoin, dave)

View File

@ -27,25 +27,12 @@ func testWipeForwardingPackages(ht *lntest.HarnessTest) {
numInvoices = 3
)
// Grab Alice and Bob from HarnessTest.
alice, bob := ht.Alice, ht.Bob
// 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},
chanPoints, nodes := ht.CreateSimpleNetwork(
[][]string{nil, nil, nil},
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
// and Carol.

View File

@ -753,7 +753,7 @@ func testPrivateUpdateAlias(ht *lntest.HarnessTest,
// testOptionScidUpgrade tests that toggling the option-scid-alias feature bit
// correctly upgrades existing channels.
func testOptionScidUpgrade(ht *lntest.HarnessTest) {
bob := ht.Bob
bob := ht.NewNodeWithCoins("Bob", nil)
// Start carol with anchors only.
carolArgs := []string{

View File

@ -603,6 +603,42 @@ func (h *HarnessTest) NewNode(name string,
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.
func (h *HarnessTest) Shutdown(node *node.HarnessNode) {
// The process may not be in a state to always shutdown immediately, so