Merge pull request #5374 from yyforyongyu/itest-use-require-sendcoin

itest: use require inside net.SendCoins
This commit is contained in:
Olaoluwa Osuntokun 2021-06-18 14:12:39 -07:00 committed by GitHub
commit 2fd75ace9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 285 additions and 687 deletions

@ -12,6 +12,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"testing"
"time" "time"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
@ -26,6 +27,7 @@ import (
"github.com/lightningnetwork/lnd/lntest/wait" "github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
) )
@ -144,7 +146,9 @@ func (f *fakeLogger) Println(args ...interface{}) {}
// rpc clients capable of communicating with the initial seeder nodes are // rpc clients capable of communicating with the initial seeder nodes are
// created. Nodes are initialized with the given extra command line flags, which // created. Nodes are initialized with the given extra command line flags, which
// should be formatted properly - "--arg=value". // should be formatted properly - "--arg=value".
func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error { func (n *NetworkHarness) SetUp(t *testing.T,
testCase string, lndArgs []string) error {
// Swap out grpc's default logger with out fake logger which drops the // Swap out grpc's default logger with out fake logger which drops the
// statements on the floor. // statements on the floor.
grpclog.SetLogger(&fakeLogger{}) grpclog.SetLogger(&fakeLogger{})
@ -153,32 +157,16 @@ func (n *NetworkHarness) SetUp(testCase string, lndArgs []string) error {
// Start the initial seeder nodes within the test network, then connect // Start the initial seeder nodes within the test network, then connect
// their respective RPC clients. // their respective RPC clients.
var wg sync.WaitGroup var wg sync.WaitGroup
errChan := make(chan error, 2)
wg.Add(2) wg.Add(2)
go func() { go func() {
defer wg.Done() defer wg.Done()
node, err := n.NewNode("Alice", lndArgs) n.Alice = n.NewNode(t, "Alice", lndArgs)
if err != nil {
errChan <- err
return
}
n.Alice = node
}() }()
go func() { go func() {
defer wg.Done() defer wg.Done()
node, err := n.NewNode("Bob", lndArgs) n.Bob = n.NewNode(t, "Bob", lndArgs)
if err != nil {
errChan <- err
return
}
n.Bob = node
}() }()
wg.Wait() wg.Wait()
select {
case err := <-errChan:
return err
default:
}
// First, make a connection between the two nodes. This will wait until // First, make a connection between the two nodes. This will wait until
// both nodes are fully started since the Connect RPC is guarded behind // both nodes are fully started since the Connect RPC is guarded behind
@ -346,10 +334,15 @@ func (n *NetworkHarness) NewNodeEtcd(name string, etcdCfg *etcd.Config,
// NewNode fully initializes a returns a new HarnessNode bound to the // NewNode fully initializes a returns a new HarnessNode bound to the
// current instance of the network harness. The created node is running, but // current instance of the network harness. The created node is running, but
// not yet connected to other nodes within the network. // not yet connected to other nodes within the network.
func (n *NetworkHarness) NewNode(name string, extraArgs []string) (*HarnessNode, func (n *NetworkHarness) NewNode(t *testing.T,
error) { name string, extraArgs []string) *HarnessNode {
return n.newNode(name, extraArgs, false, nil, n.embeddedEtcd, true) node, err := n.newNode(
name, extraArgs, false, nil, n.embeddedEtcd, true,
)
require.NoErrorf(t, err, "unable to create new node for %s", name)
return node
} }
// NewNodeWithSeed fully initializes a new HarnessNode after creating a fresh // NewNodeWithSeed fully initializes a new HarnessNode after creating a fresh
@ -1358,36 +1351,45 @@ func (n *NetworkHarness) DumpLogs(node *HarnessNode) (string, error) {
// SendCoins attempts to send amt satoshis from the internal mining node to the // SendCoins attempts to send amt satoshis from the internal mining node to the
// targeted lightning node using a P2WKH address. 6 blocks are mined after in // targeted lightning node using a P2WKH address. 6 blocks are mined after in
// order to confirm the transaction. // order to confirm the transaction.
func (n *NetworkHarness) SendCoins(ctx context.Context, amt btcutil.Amount, func (n *NetworkHarness) SendCoins(ctx context.Context, t *testing.T,
target *HarnessNode) error { amt btcutil.Amount, target *HarnessNode) {
return n.sendCoins( err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH, ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH,
true, true,
) )
require.NoErrorf(t, err, "unable to send coins for %s", target.Cfg.Name)
} }
// SendCoinsUnconfirmed sends coins from the internal mining node to the target // SendCoinsUnconfirmed sends coins from the internal mining node to the target
// lightning node using a P2WPKH address. No blocks are mined after, so the // lightning node using a P2WPKH address. No blocks are mined after, so the
// transaction remains unconfirmed. // transaction remains unconfirmed.
func (n *NetworkHarness) SendCoinsUnconfirmed(ctx context.Context, func (n *NetworkHarness) SendCoinsUnconfirmed(ctx context.Context,
amt btcutil.Amount, target *HarnessNode) error { t *testing.T, amt btcutil.Amount, target *HarnessNode) {
return n.sendCoins( err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH, ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH,
false, false,
) )
require.NoErrorf(
t, err, "unable to send unconfirmed coins for %s",
target.Cfg.Name,
)
} }
// SendCoinsNP2WKH attempts to send amt satoshis from the internal mining node // SendCoinsNP2WKH attempts to send amt satoshis from the internal mining node
// to the targeted lightning node using a NP2WKH address. // to the targeted lightning node using a NP2WKH address.
func (n *NetworkHarness) SendCoinsNP2WKH(ctx context.Context, func (n *NetworkHarness) SendCoinsNP2WKH(ctx context.Context,
amt btcutil.Amount, target *HarnessNode) error { t *testing.T, amt btcutil.Amount, target *HarnessNode) {
return n.sendCoins( err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_NESTED_PUBKEY_HASH, ctx, amt, target, lnrpc.AddressType_NESTED_PUBKEY_HASH,
true, true,
) )
require.NoErrorf(
t, err, "unable to send NP2WKH coins for %s",
target.Cfg.Name,
)
} }
// sendCoins attempts to send amt satoshis from the internal mining node to the // sendCoins attempts to send amt satoshis from the internal mining node to the

@ -433,10 +433,7 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) {
backupDir, chanbackup.DefaultBackupFileName, backupDir, chanbackup.DefaultBackupFileName,
) )
carolArgs := fmt.Sprintf("--backupfilepath=%v", backupFilePath) carolArgs := fmt.Sprintf("--backupfilepath=%v", backupFilePath)
carol, err := net.NewNode("carol", []string{carolArgs}) carol := net.NewNode(t.t, "carol", []string{carolArgs})
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Next, we'll register for streaming notifications for changes to the // Next, we'll register for streaming notifications for changes to the
@ -605,10 +602,7 @@ func testExportChannelBackup(net *lntest.NetworkHarness, t *harnessTest) {
// First, we'll create our primary test node: Carol. We'll use Carol to // First, we'll create our primary test node: Carol. We'll use Carol to
// open channels and also export backups that we'll examine throughout // open channels and also export backups that we'll examine throughout
// the test. // the test.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// 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
@ -849,24 +843,16 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
defer func() { defer func() {
shutdownAndAssert(net, t, dave) shutdownAndAssert(net, t, dave)
}() }()
carol, err := net.NewNode("carol", nodeArgs) carol := net.NewNode(t.t, "carol", nodeArgs)
if err != nil {
t.Fatalf("unable to make new node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Now that our new nodes are created, we'll give them some coins for // Now that our new nodes are created, we'll give them some coins for
// channel opening and anchor sweeping. // channel opening and anchor sweeping.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
var from, to *lntest.HarnessNode var from, to *lntest.HarnessNode
if testCase.initiator { if testCase.initiator {

@ -44,16 +44,13 @@ type interceptorTestCase struct {
// valid payment (invoice is settled). // valid payment (invoice is settled).
func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) { func testForwardInterceptor(net *lntest.NetworkHarness, t *harnessTest) {
// Initialize the test context with 3 connected nodes. // Initialize the test context with 3 connected nodes.
alice, err := net.NewNode("alice", nil) alice := net.NewNode(t.t, "alice", nil)
require.NoError(t.t, err, "unable to create alice")
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
bob, err := net.NewNode("bob", nil) bob := net.NewNode(t.t, "bob", nil)
require.NoError(t.t, err, "unable to create bob")
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
require.NoError(t.t, err, "unable to create carol")
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
testContext := newInterceptorTestContext(t, net, alice, bob, carol) testContext := newInterceptorTestContext(t, net, alice, bob, carol)
@ -316,8 +313,7 @@ func (c *interceptorTestContext) openChannel(from, to *lntest.HarnessNode,
ctxb := context.Background() ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err := c.net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, from) c.net.SendCoins(ctxt, c.t.t, btcutil.SatoshiPerBitcoin, from)
require.NoError(c.t.t, err, "unable to send coins")
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPoint := openChannelAndAssert( chanPoint := openChannelAndAssert(

@ -37,25 +37,22 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
// preferentially signal the legacy commitment format. We do // preferentially signal the legacy commitment format. We do
// the same for Dave shortly below. // the same for Dave shortly below.
carolArgs := carolCommitType.Args() carolArgs := carolCommitType.Args()
carol, err := net.NewNode("Carol", carolArgs) carol := net.NewNode(t.t, "Carol", carolArgs)
require.NoError(t.t, err, "unable to create new node")
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Each time, we'll send Carol a new set of coins in order to // Each time, we'll send Carol a new set of coins in order to
// fund the channel. // fund the channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
require.NoError(t.t, err, "unable to send coins to carol")
daveArgs := daveCommitType.Args() daveArgs := daveCommitType.Args()
dave, err := net.NewNode("Dave", daveArgs) dave := net.NewNode(t.t, "Dave", daveArgs)
require.NoError(t.t, err, "unable to create new node")
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// Before we start the test, we'll ensure both sides are // Before we start the test, we'll ensure both sides are
// connected to the funding flow can properly be executed. // connected to the funding flow can properly be executed.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.EnsureConnected(ctxt, carol, dave) err := net.EnsureConnected(ctxt, carol, dave)
require.NoError(t.t, err, "unable to connect peers") require.NoError(t.t, err, "unable to connect peers")
carolChan, daveChan, closeChan, err := basicChannelFundingTest( carolChan, daveChan, closeChan, err := basicChannelFundingTest(
@ -260,14 +257,12 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
) )
// We'll start off by creating a node for Carol. // We'll start off by creating a node for Carol.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
require.NoError(t.t, err, "unable to create carol's node")
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// We'll send her some confirmed funds. // We'll send her some confirmed funds.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, 2*chanAmt, carol) net.SendCoins(ctxt, t.t, 2*chanAmt, carol)
require.NoError(t.t, err, "unable to send coins to carol")
// Now let Carol send some funds to herself, making a unconfirmed // Now let Carol send some funds to herself, making a unconfirmed
// change output. // change output.
@ -385,24 +380,21 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
// First, we'll create two new nodes that we'll use to open channel // First, we'll create two new nodes that we'll use to open channel
// between for this test. // between for this test.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
dave, err := net.NewNode("dave", nil) dave := net.NewNode(t.t, "dave", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// Carol will be funding the channel, so we'll send some coins over to // Carol will be funding the channel, so we'll send some coins over to
// her and ensure they have enough confirmations before we proceed. // her and ensure they have enough confirmations before we proceed.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
require.NoError(t.t, err)
// Before we start the test, we'll ensure both sides are connected to // Before we start the test, we'll ensure both sides are connected to
// the funding flow can properly be executed. // the funding flow can properly be executed.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.EnsureConnected(ctxt, carol, dave) err := net.EnsureConnected(ctxt, carol, dave)
require.NoError(t.t, err) require.NoError(t.t, err)
// At this point, we're ready to simulate our external channel funding // At this point, we're ready to simulate our external channel funding

@ -30,10 +30,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
) )
// Create carol, and clean up when the test finishes. // Create carol, and clean up when the test finishes.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Connect Alice to Carol. // Connect Alice to Carol.
@ -56,7 +53,7 @@ func testHoldInvoicePersistence(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Carol to receive the channel edge from the // Wait for Alice and Carol to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice) err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)

@ -18,33 +18,24 @@ import (
func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) { func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
// We'll make two new nodes, both wumbo but with the default // We'll make two new nodes, both wumbo but with the default
// limit on maximum channel size (10 BTC) // limit on maximum channel size (10 BTC)
wumboNode, err := net.NewNode( wumboNode := net.NewNode(
"wumbo", []string{"--protocol.wumbo-channels"}, t.t, "wumbo", []string{"--protocol.wumbo-channels"},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, wumboNode) defer shutdownAndAssert(net, t, wumboNode)
wumboNode2, err := net.NewNode( wumboNode2 := net.NewNode(
"wumbo2", []string{"--protocol.wumbo-channels"}, t.t, "wumbo2", []string{"--protocol.wumbo-channels"},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, wumboNode2) defer shutdownAndAssert(net, t, wumboNode2)
// We'll send 11 BTC to the wumbo node so it can test the wumbo soft limit. // We'll send 11 BTC to the wumbo node so it can test the wumbo soft limit.
ctxb := context.Background() ctxb := context.Background()
err = net.SendCoins(ctxb, 11*btcutil.SatoshiPerBitcoin, wumboNode) net.SendCoins(ctxb, t.t, 11*btcutil.SatoshiPerBitcoin, wumboNode)
if err != nil {
t.Fatalf("unable to send coins to wumbo node: %v", err)
}
// Next we'll connect both nodes, then attempt to make a wumbo channel // Next we'll connect both nodes, then attempt to make a wumbo channel
// funding request, which should fail as it exceeds the default wumbo // funding request, which should fail as it exceeds the default wumbo
// soft limit of 10 BTC. // soft limit of 10 BTC.
err = net.EnsureConnected(ctxb, wumboNode, wumboNode2) err := net.EnsureConnected(ctxb, wumboNode, wumboNode2)
if err != nil { if err != nil {
t.Fatalf("unable to connect peers: %v", err) t.Fatalf("unable to connect peers: %v", err)
} }
@ -67,10 +58,7 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
// Next we'll create a non-wumbo node to verify that it enforces the // Next we'll create a non-wumbo node to verify that it enforces the
// BOLT-02 channel size limit and rejects our funding request. // BOLT-02 channel size limit and rejects our funding request.
miniNode, err := net.NewNode("mini", nil) miniNode := net.NewNode(t.t, "mini", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, miniNode) defer shutdownAndAssert(net, t, miniNode)
err = net.EnsureConnected(ctxb, wumboNode, miniNode) err = net.EnsureConnected(ctxb, wumboNode, miniNode)
@ -95,13 +83,15 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
// We'll now make another wumbo node with appropriate maximum channel size // We'll now make another wumbo node with appropriate maximum channel size
// to accept our wumbo channel funding. // to accept our wumbo channel funding.
wumboNode3, err := net.NewNode( wumboNode3 := net.NewNode(
"wumbo3", []string{"--protocol.wumbo-channels", t.t, "wumbo3", []string{
fmt.Sprintf("--maxchansize=%v", int64(funding.MaxBtcFundingAmountWumbo+1))}, "--protocol.wumbo-channels",
fmt.Sprintf(
"--maxchansize=%v",
int64(funding.MaxBtcFundingAmountWumbo+1),
),
},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, wumboNode3) defer shutdownAndAssert(net, t, wumboNode3)
// Creating a wumbo channel between these two nodes should succeed. // Creating a wumbo channel between these two nodes should succeed.

@ -257,32 +257,14 @@ func newMppTestContext(t *harnessTest,
ctxb := context.Background() ctxb := context.Background()
alice, err := net.NewNode("alice", nil) alice := net.NewNode(t.t, "alice", nil)
if err != nil { bob := net.NewNode(t.t, "bob", []string{"--accept-amp"})
t.Fatalf("unable to create alice: %v", err)
}
bob, err := net.NewNode("bob", []string{"--accept-amp"})
if err != nil {
t.Fatalf("unable to create bob: %v", err)
}
// 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.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
if err != nil { dave := net.NewNode(t.t, "dave", nil)
t.Fatalf("unable to create carol: %v", err) eve := net.NewNode(t.t, "eve", nil)
}
dave, err := net.NewNode("dave", nil)
if err != nil {
t.Fatalf("unable to create dave: %v", err)
}
eve, err := net.NewNode("eve", nil)
if err != nil {
t.Fatalf("unable to create eve: %v", err)
}
// Connect nodes to ensure propagation of channels. // Connect nodes to ensure propagation of channels.
nodes := []*lntest.HarnessNode{alice, bob, carol, dave, eve} nodes := []*lntest.HarnessNode{alice, bob, carol, dave, eve}
@ -314,10 +296,7 @@ func (c *mppTestContext) openChannel(from, to *lntest.HarnessNode, chanSize btcu
ctxb := context.Background() ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err := c.net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, from) c.net.SendCoins(ctxt, c.t.t, btcutil.SatoshiPerBitcoin, from)
if err != nil {
c.t.Fatalf("unable to send coins : %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPoint := openChannelAndAssert( chanPoint := openChannelAndAssert(

@ -88,10 +88,7 @@ func testHtlcErrorPropagation(net *lntest.NetworkHarness, t *harnessTest) {
// 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.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
// Next, we'll create a connection from Bob to Carol, and open a // Next, we'll create a connection from Bob to Carol, and open a
// channel between them so we have the topology: Alice -> Bob -> Carol. // channel between them so we have the topology: Alice -> Bob -> Carol.

@ -47,10 +47,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
// First, we'll create Dave and establish a channel to Alice. Dave will // First, we'll create Dave and establish a channel to Alice. Dave will
// be running an older node that requires the legacy onion payload. // be running an older node that requires the legacy onion payload.
daveArgs := []string{"--protocol.legacy.onion"} daveArgs := []string{"--protocol.legacy.onion"}
dave, err := net.NewNode("Dave", daveArgs) dave := net.NewNode(t.t, "Dave", daveArgs)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -58,10 +55,8 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -81,10 +76,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. // Dave.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -92,10 +84,8 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,

@ -81,16 +81,10 @@ func testMultiHopHtlcClaims(net *lntest.NetworkHarness, t *harnessTest) {
ht := newHarnessTest(t, net) ht := newHarnessTest(t, net)
args := commitType.Args() args := commitType.Args()
alice, err := net.NewNode("Alice", args) alice := net.NewNode(t, "Alice", args)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, ht, alice) defer shutdownAndAssert(net, ht, alice)
bob, err := net.NewNode("Bob", args) bob := net.NewNode(t, "Bob", args)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, ht, bob) defer shutdownAndAssert(net, ht, bob)
ctxb := context.Background() ctxb := context.Background()
@ -225,16 +219,10 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
// Make sure there are enough utxos for anchoring. // Make sure there are enough utxos for anchoring.
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
if err != nil {
t.Fatalf("unable to send coins to Alice: %v", err)
}
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, bob) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, bob)
if err != nil {
t.Fatalf("unable to send coins to Bob: %v", err)
}
} }
// We'll start the test by creating a channel between Alice and Bob, // We'll start the test by creating a channel between Alice and Bob,
@ -267,10 +255,8 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
if carolHodl { if carolHodl {
carolFlags = append(carolFlags, "--hodl.exit-settle") carolFlags = append(carolFlags, "--hodl.exit-settle")
} }
carol, err := net.NewNode("Carol", carolFlags) carol := net.NewNode(t.t, "Carol", carolFlags)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
if err := net.ConnectNodes(ctxt, bob, carol); err != nil { if err := net.ConnectNodes(ctxt, bob, carol); err != nil {
t.Fatalf("unable to connect bob to carol: %v", err) t.Fatalf("unable to connect bob to carol: %v", err)
@ -282,10 +268,7 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
// positively-yielding transaction. // positively-yielding transaction.
for i := 0; i < 2; i++ { for i := 0; i < 2; i++ {
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to Carol: %v", err)
}
} }
// We'll then create a channel from Bob to Carol. After this channel is // We'll then create a channel from Bob to Carol. After this channel is

@ -30,10 +30,7 @@ func testNetworkConnectionTimeout(net *lntest.NetworkHarness, t *harnessTest) {
// First, test the global timeout settings. // First, test the global timeout settings.
// Create Carol with a connection timeout of 1 millisecond. // Create Carol with a connection timeout of 1 millisecond.
carol, err := net.NewNode("Carol", []string{"--connectiontimeout=1ms"}) carol := net.NewNode(t.t, "Carol", []string{"--connectiontimeout=1ms"})
if err != nil {
t.Fatalf("unable to create new node carol: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Try to connect Carol to a non-routable IP address, which should give // Try to connect Carol to a non-routable IP address, which should give
@ -48,10 +45,7 @@ func testNetworkConnectionTimeout(net *lntest.NetworkHarness, t *harnessTest) {
// Second, test timeout on the connect peer request. // Second, test timeout on the connect peer request.
// Create Dave with the default timeout setting. // Create Dave with the default timeout setting.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new node dave: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// Try to connect Dave to a non-routable IP address, using a timeout // Try to connect Dave to a non-routable IP address, using a timeout

@ -32,10 +32,7 @@ func testCPFP(net *lntest.NetworkHarness, t *harnessTest) {
// send to Bob. // send to Bob.
ctxb := context.Background() ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err := net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, net.Alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Alice)
if err != nil {
t.Fatalf("unable to send coins to alice: %v", err)
}
// Create an address for Bob to send the coins to. // Create an address for Bob to send the coins to.
addrReq := &lnrpc.NewAddressRequest{ addrReq := &lnrpc.NewAddressRequest{
@ -172,19 +169,15 @@ func testCPFP(net *lntest.NetworkHarness, t *harnessTest) {
func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) { func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
// Start two nodes supporting anchor channels. // Start two nodes supporting anchor channels.
args := commitTypeAnchors.Args() args := commitTypeAnchors.Args()
alice, err := net.NewNode("Alice", args) alice := net.NewNode(t.t, "Alice", args)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
bob, err := net.NewNode("Bob", args) bob := net.NewNode(t.t, "Bob", args)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, bob) defer shutdownAndAssert(net, t, bob)
ctxb := context.Background() ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.ConnectNodes(ctxt, alice, bob) err := net.ConnectNodes(ctxt, alice, bob)
require.NoError(t.t, err) require.NoError(t.t, err)
// Send just enough coins for Alice to open a channel without a change output. // Send just enough coins for Alice to open a channel without a change output.
@ -194,10 +187,8 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
) )
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout) ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
err = net.SendCoins(ctxt, chanAmt+feeEst, alice) net.SendCoins(ctxt, t.t, chanAmt+feeEst, alice)
require.NoError(t.t, err)
// Alice opens a channel that would consume all the funds in her
// wallet, without a change output. This should not be allowed. // wallet, without a change output. This should not be allowed.
resErr := lnwallet.ErrReservedValueInvalidated.Error() resErr := lnwallet.ErrReservedValueInvalidated.Error()

@ -25,23 +25,19 @@ func testPsbtChanFunding(net *lntest.NetworkHarness, t *harnessTest) {
// First, we'll create two new nodes that we'll use to open channels // First, we'll create two new nodes that we'll use to open channels
// between for this test. Dave gets some coins that will be used to // between for this test. Dave gets some coins that will be used to
// fund the PSBT, just to make sure that Carol has an empty wallet. // fund the PSBT, just to make sure that Carol has an empty wallet.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
dave, err := net.NewNode("dave", nil) dave := net.NewNode(t.t, "dave", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, dave)
if err != nil { net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, dave)
t.Fatalf("unable to send coins to dave: %v", err)
}
// 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.
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
err = net.EnsureConnected(ctxt, carol, dave) err := net.EnsureConnected(ctxt, carol, dave)
require.NoError(t.t, err) require.NoError(t.t, err)
err = net.EnsureConnected(ctxt, carol, net.Alice) err = net.EnsureConnected(ctxt, carol, net.Alice)
require.NoError(t.t, err) require.NoError(t.t, err)

@ -1004,23 +1004,15 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
// Send one BTC to the next P2WKH address. // Send one BTC to the next P2WKH address.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins( net.SendCoins(
ctxt, btcutil.SatoshiPerBitcoin, node, ctxt, t.t, btcutil.SatoshiPerBitcoin, node,
) )
if err != nil {
t.Fatalf("unable to send coins to node: %v",
err)
}
// And another to the next NP2WKH address. // And another to the next NP2WKH address.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoinsNP2WKH( net.SendCoinsNP2WKH(
ctxt, btcutil.SatoshiPerBitcoin, node, ctxt, t.t, btcutil.SatoshiPerBitcoin, node,
) )
if err != nil {
t.Fatalf("unable to send coins to node: %v",
err)
}
} }
} }
@ -1641,15 +1633,12 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
// Create Carol with options to rate limit channel updates up to 2 per // Create Carol with options to rate limit channel updates up to 2 per
// day, and create a new channel Bob->Carol. // day, and create a new channel Bob->Carol.
carol, err := net.NewNode( carol := net.NewNode(
"Carol", []string{ t.t, "Carol", []string{
"--gossip.max-channel-update-burst=2", "--gossip.max-channel-update-burst=2",
"--gossip.channel-update-interval=24h", "--gossip.channel-update-interval=24h",
}, },
) )
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
// Clean up carol's node when the test finishes. // Clean up carol's node when the test finishes.
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
@ -1662,10 +1651,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
// Send some coins to Carol that can be used for channel funding. // Send some coins to Carol that can be used for channel funding.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
if err := net.ConnectNodes(ctxb, carol, net.Bob); err != nil { if err := net.ConnectNodes(ctxb, carol, net.Bob); err != nil {
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
@ -2392,16 +2378,10 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
"--maxbackoff=1m", "--maxbackoff=1m",
} }
alice, err := net.NewNode("Alice", args) alice := net.NewNode(t.t, "Alice", args)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
bob, err := net.NewNode("Bob", args) bob := net.NewNode(t.t, "Bob", args)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, bob) defer shutdownAndAssert(net, t, bob)
// Start by connecting Alice and Bob with no channels. // Start by connecting Alice and Bob with no channels.
@ -2415,10 +2395,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
// Give Alice some coins so she can fund a channel. // Give Alice some coins so she can fund a channel.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
if err != nil {
t.Fatalf("unable to send coins to alice: %v", err)
}
chanAmt := funding.MaxBtcFundingAmount chanAmt := funding.MaxBtcFundingAmount
pushAmt := btcutil.Amount(0) pushAmt := btcutil.Amount(0)
@ -2563,10 +2540,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// we'll need to create a new node instance. // we'll need to create a new node instance.
const numConfs = 5 const numConfs = 5
carolArgs := []string{fmt.Sprintf("--bitcoin.defaultchanconfs=%v", numConfs)} carolArgs := []string{fmt.Sprintf("--bitcoin.defaultchanconfs=%v", numConfs)}
carol, err := net.NewNode("Carol", carolArgs) carol := net.NewNode(t.t, "Carol", carolArgs)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
// Clean up carol's node when the test finishes. // Clean up carol's node when the test finishes.
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
@ -2865,10 +2839,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Create carol in hodl mode. // Create carol in hodl mode.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Connect Alice to Carol. // Connect Alice to Carol.
@ -2889,7 +2860,7 @@ func testChannelUnsettledBalance(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Carol to receive the channel edge from the // Wait for Alice and Carol to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice) err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPointAlice)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->carol channel before "+ t.Fatalf("alice didn't see the alice->carol channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -3165,10 +3136,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
ht := newHarnessTest(t, net) ht := newHarnessTest(t, net)
args := channelType.Args() args := channelType.Args()
alice, err := net.NewNode("Alice", args) alice := net.NewNode(ht.t, "Alice", args)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, ht, alice) defer shutdownAndAssert(net, ht, alice)
// Since we'd like to test failure scenarios with // Since we'd like to test failure scenarios with
@ -3176,10 +3144,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
// our test network: Carol. // our test network: Carol.
carolArgs := []string{"--hodl.exit-settle"} carolArgs := []string{"--hodl.exit-settle"}
carolArgs = append(carolArgs, args...) carolArgs = append(carolArgs, args...)
carol, err := net.NewNode("Carol", carolArgs) carol := net.NewNode(ht.t, "Carol", carolArgs)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, ht, carol) defer shutdownAndAssert(net, ht, carol)
// Each time, we'll send Alice new set of coins in // Each time, we'll send Alice new set of coins in
@ -3187,23 +3152,11 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
ctxt, _ := context.WithTimeout( ctxt, _ := context.WithTimeout(
context.Background(), defaultTimeout, context.Background(), defaultTimeout,
) )
err = net.SendCoins( net.SendCoins(ctxt, t, btcutil.SatoshiPerBitcoin, alice)
ctxt, btcutil.SatoshiPerBitcoin, alice,
)
if err != nil {
t.Fatalf("unable to send coins to Alice: %v",
err)
}
// Also give Carol some coins to allow her to sweep her // Also give Carol some coins to allow her to sweep her
// anchor. // anchor.
err = net.SendCoins( net.SendCoins(ctxt, t, btcutil.SatoshiPerBitcoin, carol)
ctxt, btcutil.SatoshiPerBitcoin, carol,
)
if err != nil {
t.Fatalf("unable to send coins to Alice: %v",
err)
}
channelForceClosureTest( channelForceClosureTest(
net, ht, alice, carol, channelType, net, ht, alice, carol, channelType,
@ -4500,10 +4453,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
chanAmt := btcutil.Amount(100000) chanAmt := btcutil.Amount(100000)
// First, we'll create Dave, the receiver, and start him in hodl mode. // First, we'll create Dave, the receiver, and start him in hodl mode.
dave, err := net.NewNode("Dave", []string{"--hodl.exit-settle"}) dave := net.NewNode(t.t, "Dave", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
// We must remember to shutdown the nodes we created for the duration // We must remember to shutdown the nodes we created for the duration
// of the tests, only leaving the two seed nodes (Alice and Bob) within // of the tests, only leaving the two seed nodes (Alice and Bob) within
@ -4513,10 +4463,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. Carol is started in both unsafe-replay which will cause her to // Dave. Carol is started in both unsafe-replay which will cause her to
// replay any pending Adds held in memory upon reconnection. // replay any pending Adds held in memory upon reconnection.
carol, err := net.NewNode("Carol", []string{"--unsafe-replay"}) carol := net.NewNode(t.t, "Carol", []string{"--unsafe-replay"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
@ -4524,10 +4471,8 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPoint := openChannelAndAssert( chanPoint := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -4541,10 +4486,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// by paying from Carol directly to Dave, because the '--unsafe-replay' // by paying from Carol directly to Dave, because the '--unsafe-replay'
// setup doesn't apply to locally added htlcs. In that case, the // setup doesn't apply to locally added htlcs. In that case, the
// mailbox, that is responsible for generating the replay, is bypassed. // mailbox, that is responsible for generating the replay, is bypassed.
fred, err := net.NewNode("Fred", nil) fred := net.NewNode(t.t, "Fred", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, fred) defer shutdownAndAssert(net, t, fred)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -4552,10 +4494,8 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect fred to carol: %v", err) t.Fatalf("unable to connect fred to carol: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, fred) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, fred)
if err != nil {
t.Fatalf("unable to send coins to fred: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointFC := openChannelAndAssert( chanPointFC := openChannelAndAssert(
ctxt, t, net, fred, carol, ctxt, t, net, fred, carol,
@ -4738,18 +4678,17 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
const bobRemoteMaxHtlcs = 100 const bobRemoteMaxHtlcs = 100
// Create two fresh nodes and open a channel between them. // Create two fresh nodes and open a channel between them.
alice, err := net.NewNode("Alice", nil) alice := net.NewNode(t.t, "Alice", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
bob, err := net.NewNode("Bob", []string{ bob := net.NewNode(
fmt.Sprintf("--default-remote-max-htlcs=%v", bobRemoteMaxHtlcs), t.t, "Bob", []string{
}) fmt.Sprintf(
if err != nil { "--default-remote-max-htlcs=%v",
t.Fatalf("unable to create new node: %v", err) bobRemoteMaxHtlcs,
} ),
},
)
defer shutdownAndAssert(net, t, bob) defer shutdownAndAssert(net, t, bob)
// Connect Alice to Bob. // Connect Alice to Bob.
@ -4759,10 +4698,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Give Alice some coins so she can fund a channel. // Give Alice some coins so she can fund a channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
if err != nil {
t.Fatalf("unable to send coins to alice: %v", err)
}
// 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 to // being the sole funder of the channel. The minial HTLC amount is set to
@ -4783,7 +4719,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the // Wait for Alice and Bob to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint) err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->bob channel before "+ t.Fatalf("alice didn't see the alice->bob channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -4880,26 +4816,24 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background() ctxb := context.Background()
// Create two fresh nodes and open a channel between them. // Create two fresh nodes and open a channel between them.
alice, err := net.NewNode("Alice", []string{ alice := net.NewNode(
"--minbackoff=10s", t.t, "Alice", []string{
"--chan-enable-timeout=1.5s", "--minbackoff=10s",
"--chan-disable-timeout=3s", "--chan-enable-timeout=1.5s",
"--chan-status-sample-interval=.5s", "--chan-disable-timeout=3s",
}) "--chan-status-sample-interval=.5s",
if err != nil { },
t.Fatalf("unable to create new node: %v", err) )
}
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
bob, err := net.NewNode("Bob", []string{ bob := net.NewNode(
"--minbackoff=10s", t.t, "Bob", []string{
"--chan-enable-timeout=1.5s", "--minbackoff=10s",
"--chan-disable-timeout=3s", "--chan-enable-timeout=1.5s",
"--chan-status-sample-interval=.5s", "--chan-disable-timeout=3s",
}) "--chan-status-sample-interval=.5s",
if err != nil { },
t.Fatalf("unable to create new node: %v", err) )
}
defer shutdownAndAssert(net, t, bob) defer shutdownAndAssert(net, t, bob)
// Connect Alice to Bob. // Connect Alice to Bob.
@ -4909,10 +4843,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
// Give Alice some coins so she can fund a channel. // Give Alice some coins so she can fund a channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
if err != nil {
t.Fatalf("unable to send coins to alice: %v", err)
}
// 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.
@ -4928,7 +4859,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the // Wait for Alice and Bob to receive the channel edge from the
// funding manager. // funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint) err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("alice didn't see the alice->bob channel before "+ t.Fatalf("alice didn't see the alice->bob channel before "+
"timeout: %v", err) "timeout: %v", err)
@ -4944,10 +4875,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
// Launch a node for Carol which will connect to Alice and Bob in // Launch a node for Carol which will connect to Alice and Bob in
// order to receive graph updates. This will ensure that the // order to receive graph updates. This will ensure that the
// channel updates are propagated throughout the network. // channel updates are propagated throughout the network.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create Carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -5506,16 +5434,10 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
// is the sole funder of the channel with 100k satoshis. The network // is the sole funder of the channel with 100k satoshis. The network
// topology should look like: // topology should look like:
// Carol -> 100k -> Dave // Carol -> 100k -> Dave
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
@ -5523,10 +5445,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
// Open a channel with 100k satoshis between Carol and Dave with Carol // Open a channel with 100k satoshis between Carol and Dave with Carol
// being the sole funder of the channel. // being the sole funder of the channel.
@ -5887,10 +5806,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
// Create Carol and establish a channel from Bob. Bob is the sole funder // Create Carol and establish a channel from Bob. Bob is the sole funder
// of the channel with 100k satoshis. The network topology should look like: // of the channel with 100k satoshis. The network topology should look like:
// Alice -> Bob -> Carol // Alice -> Bob -> Carol
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -5898,10 +5814,8 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to alice: %v", err) t.Fatalf("unable to connect carol to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, net.Bob) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
if err != nil {
t.Fatalf("unable to send coins to bob: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointBob := openChannelAndAssert( chanPointBob := openChannelAndAssert(
ctxt, t, net, net.Bob, carol, ctxt, t, net, net.Bob, carol,
@ -6069,29 +5983,17 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
// Bob graph. // Bob graph.
// //
// The network topology should now look like: Alice -> Bob; Carol -> Charlie. // The network topology should now look like: Alice -> Bob; Carol -> Charlie.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
charlie, err := net.NewNode("Charlie", nil) charlie := net.NewNode(t.t, "Charlie", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, charlie) defer shutdownAndAssert(net, t, charlie)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, charlie) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, charlie)
if err != nil {
t.Fatalf("unable to send coins to charlie: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
if err := net.ConnectNodes(ctxt, carol, charlie); err != nil { if err := net.ConnectNodes(ctxt, carol, charlie); err != nil {
@ -6317,10 +6219,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Create Dave, and a channel to Alice of 100k. // Create Dave, and a channel to Alice of 100k.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6328,10 +6227,8 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -6351,10 +6248,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Next, we'll create Carol and establish a channel from her to // Next, we'll create Carol and establish a channel from her to
// Dave of 100k. // Dave of 100k.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6362,10 +6256,8 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -6648,10 +6540,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
// Then, we'll create Carol's node and open a public channel between her // Then, we'll create Carol's node and open a public channel between her
// and Alice. This channel will not be considered as a routing hint due // and Alice. This channel will not be considered as a routing hint due
// to it being public. // to it being public.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6689,10 +6578,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
// and Alice. We will not include a push amount in order to not consider // and Alice. We will not include a push amount in order to not consider
// this channel as a routing hint as it will not have enough remote // this channel as a routing hint as it will not have enough remote
// balance for the invoice's amount. // balance for the invoice's amount.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create dave's node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6712,10 +6598,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
// her and Alice. This time though, we'll take Eve's node down after the // her and Alice. This time though, we'll take Eve's node down after the
// channel has been created to avoid populating routing hints for // channel has been created to avoid populating routing hints for
// inactive channels. // inactive channels.
eve, err := net.NewNode("Eve", nil) eve := net.NewNode(t.t, "Eve", nil)
if err != nil {
t.Fatalf("unable to create eve's node: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
if err := net.ConnectNodes(ctxt, net.Alice, eve); err != nil { if err := net.ConnectNodes(ctxt, net.Alice, eve); err != nil {
t.Fatalf("unable to connect alice to eve: %v", err) t.Fatalf("unable to connect alice to eve: %v", err)
@ -6741,7 +6624,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
} }
for i, chanPoint := range aliceChans { for i, chanPoint := range aliceChans {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint) err := net.Alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil { if err != nil {
t.Fatalf("timed out waiting for channel open %s: %v", t.Fatalf("timed out waiting for channel open %s: %v",
chanNames[i], err) chanNames[i], err)
@ -6762,7 +6645,7 @@ func testInvoiceRoutingHints(net *lntest.NetworkHarness, t *harnessTest) {
// Alice and Bob should be the only channel used as a routing hint. // Alice and Bob should be the only channel used as a routing hint.
var predErr error var predErr error
var decoded *lnrpc.PayReq var decoded *lnrpc.PayReq
err = wait.Predicate(func() bool { err := wait.Predicate(func() bool {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
resp, err := net.Alice.AddInvoice(ctxt, invoice) resp, err := net.Alice.AddInvoice(ctxt, invoice)
if err != nil { if err != nil {
@ -6892,10 +6775,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *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, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6941,10 +6821,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
// Next, we'll create Dave's node and open a private channel between him // Next, we'll create Dave's node and open a private channel between him
// and Carol with Carol being the funder. // and Carol with Carol being the funder.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create dave's node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -6952,10 +6829,8 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -7588,10 +7463,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
args := []string{ args := []string{
fmt.Sprintf("--maxpendingchannels=%v", maxPendingChannels), fmt.Sprintf("--maxpendingchannels=%v", maxPendingChannels),
} }
carol, err := net.NewNode("Carol", args) carol := net.NewNode(t.t, "Carol", args)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
@ -7601,9 +7473,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
carolBalance := btcutil.Amount(maxPendingChannels) * amount carolBalance := btcutil.Amount(maxPendingChannels) * amount
if err := net.SendCoins(ctxt, carolBalance, carol); err != nil { net.SendCoins(ctxt, t.t, carolBalance, carol)
t.Fatalf("unable to send coins to carol: %v", err)
}
// Send open channel requests without generating new blocks thereby // Send open channel requests without generating new blocks thereby
// increasing pool of pending channels. Then check that we can't open // increasing pool of pending channels. Then check that we can't open
@ -7623,7 +7493,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Carol exhausted available amount of pending channels, next open // Carol exhausted available amount of pending channels, next open
// channel request should cause ErrorGeneric to be sent back to Alice. // channel request should cause ErrorGeneric to be sent back to Alice.
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
_, err = net.OpenChannel( _, err := net.OpenChannel(
ctxt, net.Alice, carol, ctxt, net.Alice, carol,
lntest.OpenChannelParams{ lntest.OpenChannelParams{
Amt: amount, Amt: amount,
@ -7750,10 +7620,7 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
// We'll introduce Carol, which will settle any incoming invoice with a // We'll introduce Carol, which will settle any incoming invoice with a
// totally unrelated preimage. // totally unrelated preimage.
carol, err := net.NewNode("Carol", []string{"--hodl.bogus-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.bogus-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Let Alice connect and open a channel to Carol, // Let Alice connect and open a channel to Carol,
@ -7954,10 +7821,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
) )
// Create Carol's node and connect Alice to her. // Create Carol's node and connect Alice to her.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
if err := net.ConnectNodes(ctxt, net.Alice, carol); err != nil { if err := net.ConnectNodes(ctxt, net.Alice, carol); err != nil {
@ -7977,11 +7841,9 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
// Now, create Dave's a node and also open a channel between Alice and // Now, create Dave's a node and also open a channel between Alice and
// him. This link will serve as the only persistent link throughout // him. This link will serve as the only persistent link throughout
// restarts in this test. // restarts in this test.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create dave's node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
if err := net.ConnectNodes(ctxt, net.Alice, dave); err != nil { if err := net.ConnectNodes(ctxt, net.Alice, dave); err != nil {
t.Fatalf("unable to connect alice to dave: %v", err) t.Fatalf("unable to connect alice to dave: %v", err)
} }
@ -8043,7 +7905,7 @@ func testGarbageCollectLinkNodes(net *lntest.NetworkHarness, t *harnessTest) {
require.Eventually(t.t, func() bool { require.Eventually(t.t, func() bool {
return isConnected(dave.PubKeyStr) return isConnected(dave.PubKeyStr)
}, defaultTimeout, 20*time.Millisecond) }, defaultTimeout, 20*time.Millisecond)
err = wait.Predicate(func() bool { err := wait.Predicate(func() bool {
return isConnected(dave.PubKeyStr) return isConnected(dave.PubKeyStr)
}, defaultTimeout) }, defaultTimeout)
@ -8202,13 +8064,10 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
// protection logic automatically. We also can't have Carol // protection logic automatically. We also can't have Carol
// automatically re-connect too early, otherwise DLP would be initiated // automatically re-connect too early, otherwise DLP would be initiated
// instead of the breach we want to provoke. // instead of the breach we want to provoke.
carol, err := net.NewNode( carol := net.NewNode(
"Carol", t.t, "Carol",
[]string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"}, []string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"},
) )
if err != nil {
t.Fatalf("unable to create new carol node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// We must let Bob communicate with Carol before they are able to open // We must let Bob communicate with Carol before they are able to open
@ -8221,10 +8080,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
// Before we make a channel, we'll load up Carol with some coins sent // Before we make a channel, we'll load up Carol with some coins sent
// directly from the miner. // directly from the miner.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
// In order to test Carol's response to an uncooperative channel // In order to test Carol's response to an uncooperative channel
// closure by Bob, we'll first open up a channel between them with a // closure by Bob, we'll first open up a channel between them with a
@ -8468,10 +8324,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
// 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.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Dave will be the breached party. We set --nolisten to ensure Carol // Dave will be the breached party. We set --nolisten to ensure Carol
@ -8479,13 +8332,10 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
// protection logic automatically. We also can't have Dave automatically // protection logic automatically. We also can't have Dave automatically
// re-connect too early, otherwise DLP would be initiated instead of the // re-connect too early, otherwise DLP would be initiated instead of the
// breach we want to provoke. // breach we want to provoke.
dave, err := net.NewNode( dave := net.NewNode(
"Dave", t.t, "Dave",
[]string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"}, []string{"--hodl.exit-settle", "--nolisten", "--minbackoff=1h"},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// We must let Dave have an open channel before she can send a node // We must let Dave have an open channel before she can send a node
@ -8498,10 +8348,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
// Before we make a channel, we'll load up Dave with some coins sent // Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner. // directly from the miner.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
// In order to test Dave's response to an uncooperative channel // In order to test Dave's response to an uncooperative channel
// closure by Carol, we'll first open up a channel between them with a // closure by Carol, we'll first open up a channel between them with a
@ -8719,10 +8566,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// Since this test will result in the counterparty being left in a // Since this test will result in the counterparty being left in a
// weird state, we will introduce another node into our test network: // weird state, we will introduce another node into our test network:
// Carol. // Carol.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// We'll also create a new node Dave, who will have a channel with // We'll also create a new node Dave, who will have a channel with
@ -8730,13 +8574,10 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// with active HTLCs. Dave will be the breached party. We set // with active HTLCs. Dave will be the breached party. We set
// --nolisten to ensure Carol won't be able to connect to him and // --nolisten to ensure Carol won't be able to connect to him and
// trigger the channel data protection logic automatically. // trigger the channel data protection logic automatically.
dave, err := net.NewNode( dave := net.NewNode(
"Dave", t.t, "Dave",
[]string{"--hodl.exit-settle", "--nolisten"}, []string{"--hodl.exit-settle", "--nolisten"},
) )
if err != nil {
t.Fatalf("unable to create new dave node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// We must let Dave communicate with Carol before they are able to open // We must let Dave communicate with Carol before they are able to open
@ -8749,10 +8590,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// Before we make a channel, we'll load up Dave with some coins sent // Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner. // directly from the miner.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
// In order to test Dave's response to an uncooperative channel closure // In order to test Dave's response to an uncooperative channel closure
// by Carol, we'll first open up a channel between them with a // by Carol, we'll first open up a channel between them with a
@ -9186,22 +9024,16 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
if anchors { if anchors {
carolArgs = append(carolArgs, "--protocol.anchors") carolArgs = append(carolArgs, "--protocol.anchors")
} }
carol, err := net.NewNode("Carol", carolArgs) carol := net.NewNode(t.t, "Carol", carolArgs)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Willy the watchtower will protect Dave from Carol's breach. He will // Willy the watchtower will protect Dave from Carol's breach. He will
// remain online in order to punish Carol on Dave's behalf, since the // remain online in order to punish Carol on Dave's behalf, since the
// breach will happen while Dave is offline. // breach will happen while Dave is offline.
willy, err := net.NewNode("Willy", []string{ willy := net.NewNode(t.t, "Willy", []string{
"--watchtower.active", "--watchtower.active",
"--watchtower.externalip=" + externalIP, "--watchtower.externalip=" + externalIP,
}) })
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, willy) defer shutdownAndAssert(net, t, willy)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
@ -9246,10 +9078,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
if anchors { if anchors {
daveArgs = append(daveArgs, "--protocol.anchors") daveArgs = append(daveArgs, "--protocol.anchors")
} }
dave, err := net.NewNode("Dave", daveArgs) dave := net.NewNode(t.t, "Dave", daveArgs)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -9269,10 +9098,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
// Before we make a channel, we'll load up Dave with some coins sent // Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner. // directly from the miner.
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
// In order to test Dave's response to an uncooperative channel // In order to test Dave's response to an uncooperative channel
// closure by Carol, we'll first open up a channel between them with a // closure by Carol, we'll first open up a channel between them with a
@ -9766,28 +9592,19 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
// protection logic automatically. We also can't have Carol // protection logic automatically. We also can't have Carol
// automatically re-connect too early, otherwise DLP would be initiated // automatically re-connect too early, otherwise DLP would be initiated
// at the wrong moment. // at the wrong moment.
carol, err := net.NewNode( carol := net.NewNode(
"Carol", []string{"--nolisten", "--minbackoff=1h"}, t.t, "Carol", []string{"--nolisten", "--minbackoff=1h"},
) )
if err != nil {
t.Fatalf("unable to create new carol node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Dave will be the party losing his state. // Dave will be the party losing his state.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// Before we make a channel, we'll load up Carol with some coins sent // Before we make a channel, we'll load up Carol with some coins sent
// directly from the miner. // directly from the miner.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
// timeTravel is a method that will make Carol open a channel to the // timeTravel is a method that will make Carol open a channel to the
// passed node, settle a series of payments, then reset the node back // passed node, settle a series of payments, then reset the node back
@ -10122,10 +9939,7 @@ func testRejectHTLC(net *lntest.NetworkHarness, t *harnessTest) {
ctxb := context.Background() ctxb := context.Background()
// Create Carol with reject htlc flag. // Create Carol with reject htlc flag.
carol, err := net.NewNode("Carol", []string{"--rejecthtlc"}) carol := net.NewNode(t.t, "Carol", []string{"--rejecthtlc"})
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
// Connect Alice to Carol. // Connect Alice to Carol.
@ -10139,16 +9953,10 @@ func testRejectHTLC(net *lntest.NetworkHarness, t *harnessTest) {
} }
// Send coins to Carol. // Send coins to Carol.
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
// Send coins to Alice. // Send coins to Alice.
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcent, net.Alice) net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcent, net.Alice)
if err != nil {
t.Fatalf("unable to send coins to alice: %v", err)
}
// Open a channel between Alice and Carol. // Open a channel between Alice and Carol.
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
@ -10175,7 +9983,7 @@ func testRejectHTLC(net *lntest.NetworkHarness, t *harnessTest) {
genPreImage := func() []byte { genPreImage := func() []byte {
preimage := make([]byte, 32) preimage := make([]byte, 32)
_, err = rand.Read(preimage) _, err := rand.Read(preimage)
if err != nil { if err != nil {
t.Fatalf("unable to generate preimage: %v", err) t.Fatalf("unable to generate preimage: %v", err)
} }
@ -10397,8 +10205,7 @@ func testGraphTopologyNtfns(net *lntest.NetworkHarness, t *harnessTest, pinned b
// 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, err := net.NewNode("bob", nil) bob := net.NewNode(t.t, "bob", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, bob) defer shutdownAndAssert(net, t, bob)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
@ -10416,8 +10223,7 @@ func testGraphTopologyNtfns(net *lntest.NetworkHarness, t *harnessTest, pinned b
} }
} }
alice, err := net.NewNode("alice", aliceArgs) alice := net.NewNode(t.t, "alice", aliceArgs)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, alice) defer shutdownAndAssert(net, t, alice)
// Connect Alice and Bob. // Connect Alice and Bob.
@ -10427,13 +10233,11 @@ func testGraphTopologyNtfns(net *lntest.NetworkHarness, t *harnessTest, pinned b
// Alice stimmy. // Alice stimmy.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, alice) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
require.NoError(t.t, err)
// Bob stimmy. // Bob stimmy.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, bob) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, bob)
require.NoError(t.t, err)
// Assert that Bob has the correct sync type before proceeeding. // Assert that Bob has the correct sync type before proceeeding.
if pinned { if pinned {
@ -10582,10 +10386,7 @@ out:
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil { if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
t.Fatalf("unable to disconnect alice and bob: %v", err) t.Fatalf("unable to disconnect alice and bob: %v", err)
} }
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -10687,10 +10488,7 @@ func testNodeAnnouncement(net *lntest.NetworkHarness, t *harnessTest) {
lndArgs = append(lndArgs, "--externalip="+addr) lndArgs = append(lndArgs, "--externalip="+addr)
} }
dave, err := net.NewNode("Dave", lndArgs) dave := net.NewNode(t.t, "Dave", lndArgs)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// We must let Dave have an open channel before he can send a node // We must let Dave have an open channel before he can send a node
@ -10811,10 +10609,7 @@ func testNodeSignVerify(net *lntest.NetworkHarness, t *harnessTest) {
} }
// carol is a new node that is unconnected to alice or bob. // carol is a new node that is unconnected to alice or bob.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
carolMsg := []byte("carol msg") carolMsg := []byte("carol msg")
@ -11368,10 +11163,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// Carol -> Dave -> Alice -> Bob // Carol -> Dave -> Alice -> Bob
// //
// First, we'll create Dave and establish a channel to Alice. // First, we'll create Dave and establish a channel to Alice.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -11379,10 +11171,8 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -11404,10 +11194,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. Carol is started in htlchodl mode so that we can disconnect the // Dave. Carol is started in htlchodl mode so that we can disconnect the
// intermediary hops before starting the settle. // intermediary hops before starting the settle.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -11415,10 +11202,8 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -11688,10 +11473,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
// Carol -> Dave -> Alice -> Bob // Carol -> Dave -> Alice -> Bob
// //
// First, we'll create Dave and establish a channel to Alice. // First, we'll create Dave and establish a channel to Alice.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -11699,10 +11481,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -11724,10 +11504,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. Carol is started in htlchodl mode so that we can disconnect the // Dave. Carol is started in htlchodl mode so that we can disconnect the
// intermediary hops before starting the settle. // intermediary hops before starting the settle.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -11735,10 +11512,8 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -12027,10 +11802,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
// Carol -> Dave -> Alice -> Bob // Carol -> Dave -> Alice -> Bob
// //
// First, we'll create Dave and establish a channel to Alice. // First, we'll create Dave and establish a channel to Alice.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12038,10 +11810,8 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -12064,10 +11834,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. Carol is started in htlchodl mode so that we can disconnect the // Dave. Carol is started in htlchodl mode so that we can disconnect the
// intermediary hops before starting the settle. // intermediary hops before starting the settle.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12075,10 +11842,8 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -12360,10 +12125,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
// Carol -> Dave -> Alice -> Bob // Carol -> Dave -> Alice -> Bob
// //
// First, we'll create Dave and establish a channel to Alice. // First, we'll create Dave and establish a channel to Alice.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12371,10 +12133,8 @@ func testSwitchOfflineDeliveryOutgoingOffline(
t.Fatalf("unable to connect dave to alice: %v", err) t.Fatalf("unable to connect dave to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, dave) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
if err != nil {
t.Fatalf("unable to send coins to dave: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointDave := openChannelAndAssert( chanPointDave := openChannelAndAssert(
ctxt, t, net, dave, net.Alice, ctxt, t, net, dave, net.Alice,
@ -12396,19 +12156,14 @@ func testSwitchOfflineDeliveryOutgoingOffline(
// Next, we'll create Carol and establish a channel to from her to // Next, we'll create Carol and establish a channel to from her to
// Dave. Carol is started in htlchodl mode so that we can disconnect the // Dave. Carol is started in htlchodl mode so that we can disconnect the
// intermediary hops before starting the settle. // intermediary hops before starting the settle.
carol, err := net.NewNode("Carol", []string{"--hodl.exit-settle"}) carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
if err := net.ConnectNodes(ctxt, carol, dave); err != nil { if err := net.ConnectNodes(ctxt, carol, dave); err != nil {
t.Fatalf("unable to connect carol to dave: %v", err) t.Fatalf("unable to connect carol to dave: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -12617,10 +12372,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
networkChans = append(networkChans, chanPointAlice) networkChans = append(networkChans, chanPointAlice)
// Create Carol and establish a channel from Bob. // Create Carol and establish a channel from Bob.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12628,10 +12380,8 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to bob: %v", err) t.Fatalf("unable to connect carol to bob: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, net.Bob) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
if err != nil {
t.Fatalf("unable to send coins to bob: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointBob := openChannelAndAssert( chanPointBob := openChannelAndAssert(
ctxt, t, net, net.Bob, carol, ctxt, t, net, net.Bob, carol,
@ -12642,10 +12392,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
networkChans = append(networkChans, chanPointBob) networkChans = append(networkChans, chanPointBob)
// Create Dave and establish a channel from Carol. // Create Dave and establish a channel from Carol.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create new nodes: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12653,10 +12400,8 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect dave to carol: %v", err) t.Fatalf("unable to connect dave to carol: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointCarol := openChannelAndAssert( chanPointCarol := openChannelAndAssert(
ctxt, t, net, carol, dave, ctxt, t, net, carol, dave,
@ -12926,10 +12671,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
// Create Carol's node and open a channel between her and Alice with // Create Carol's node and open a channel between her and Alice with
// Alice being the funder. // Alice being the funder.
carol, err := net.NewNode("Carol", nil) carol := net.NewNode(t.t, "Carol", nil)
if err != nil {
t.Fatalf("unable to create carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -12937,10 +12679,8 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
t.Fatalf("unable to connect carol to alice: %v", err) t.Fatalf("unable to connect carol to alice: %v", err)
} }
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, carol) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout) ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
chanPointAliceCarol := openChannelAndAssert( chanPointAliceCarol := openChannelAndAssert(
ctxt, t, net, net.Alice, carol, ctxt, t, net, net.Alice, carol,
@ -12951,10 +12691,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
// Create Dave's node and open a channel between him and Bob with Bob // Create Dave's node and open a channel between him and Bob with Bob
// being the funder. // being the funder.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create dave's node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -13198,15 +12935,13 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
}, },
) )
carol, err := net.NewNode("Carol", []string{ carol := net.NewNode(
"--minbackoff=10s", t.t, "Carol", []string{
"--chan-enable-timeout=1.5s", "--minbackoff=10s",
"--chan-disable-timeout=3s", "--chan-enable-timeout=1.5s",
"--chan-status-sample-interval=.5s", "--chan-disable-timeout=3s",
}) "--chan-status-sample-interval=.5s",
if err != nil { })
t.Fatalf("unable to create carol's node: %v", err)
}
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -13224,23 +12959,18 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
// We create a new node Eve that has an inactive channel timeout of // We create a new node Eve that has an inactive channel timeout of
// just 2 seconds (down from the default 20m). It will be used to test // just 2 seconds (down from the default 20m). It will be used to test
// channel updates for channels going inactive. // channel updates for channels going inactive.
eve, err := net.NewNode("Eve", []string{ eve := net.NewNode(
"--minbackoff=10s", t.t, "Eve", []string{
"--chan-enable-timeout=1.5s", "--minbackoff=10s",
"--chan-disable-timeout=3s", "--chan-enable-timeout=1.5s",
"--chan-status-sample-interval=.5s", "--chan-disable-timeout=3s",
}) "--chan-status-sample-interval=.5s",
if err != nil { })
t.Fatalf("unable to create eve's node: %v", err)
}
defer shutdownAndAssert(net, t, eve) defer shutdownAndAssert(net, t, eve)
// Give Eve some coins. // Give Eve some coins.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, eve) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, eve)
if err != nil {
t.Fatalf("unable to send coins to eve: %v", err)
}
// Connect Eve to Carol and Bob, and open a channel to carol. // Connect Eve to Carol and Bob, and open a channel to carol.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -13263,10 +12993,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
// Launch a node for Dave which will connect to Bob in order to receive // Launch a node for Dave which will connect to Bob in order to receive
// graph updates from. This will ensure that the channel updates are // graph updates from. This will ensure that the channel updates are
// propagated throughout the network. // propagated throughout the network.
dave, err := net.NewNode("Dave", nil) dave := net.NewNode(t.t, "Dave", nil)
if err != nil {
t.Fatalf("unable to create dave's node: %v", err)
}
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
@ -13588,24 +13315,16 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
// 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.
ainz, err := net.NewNode("Ainz", nil) ainz := net.NewNode(t.t, "Ainz", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, ainz) defer shutdownAndAssert(net, t, ainz)
// Next, we'll give Ainz exactly 2 utxos of 1 BTC each, with one of // Next, we'll give Ainz exactly 2 utxos of 1 BTC each, with one of
// them being p2wkh and the other being a n2wpkh address. // them being p2wkh and the other being a n2wpkh address.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout) ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoins(ctxt, btcutil.SatoshiPerBitcoin, ainz) net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, ainz)
if err != nil {
t.Fatalf("unable to send coins to eve: %v", err)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout) ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
err = net.SendCoinsNP2WKH(ctxt, btcutil.SatoshiPerBitcoin, ainz) net.SendCoinsNP2WKH(ctxt, t.t, btcutil.SatoshiPerBitcoin, ainz)
if err != nil {
t.Fatalf("unable to send coins to eve: %v", err)
}
// Ensure that we can't send coins to our own Pubkey. // Ensure that we can't send coins to our own Pubkey.
info, err := ainz.GetInfo(ctxt, &lnrpc.GetInfoRequest{}) info, err := ainz.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
@ -14123,7 +13842,9 @@ func TestLightningNetworkDaemon(t *testing.T) {
testCase.name, " ", "_", testCase.name, " ", "_",
) )
err = lndHarness.SetUp(cleanTestCaseName, aliceBobArgs) err = lndHarness.SetUp(
t1, cleanTestCaseName, aliceBobArgs,
)
require.NoError(t1, require.NoError(t1,
err, "unable to set up test lightning network", err, "unable to set up test lightning network",
) )

@ -606,12 +606,10 @@ func testWalletImportAccountScenario(net *lntest.NetworkHarness, t *harnessTest,
// We'll start our test by having two nodes, Carol and Dave. Carol's // We'll start our test by having two nodes, Carol and Dave. Carol's
// default wallet account will be imported into Dave's node. // default wallet account will be imported into Dave's node.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
dave, err := net.NewNode("dave", nil) dave := net.NewNode(t.t, "dave", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@ -754,12 +752,10 @@ func testWalletImportPubKeyScenario(net *lntest.NetworkHarness, t *harnessTest,
const utxoAmt int64 = btcutil.SatoshiPerBitcoin const utxoAmt int64 = btcutil.SatoshiPerBitcoin
// We'll start our test by having two nodes, Carol and Dave. // We'll start our test by having two nodes, Carol and Dave.
carol, err := net.NewNode("carol", nil) carol := net.NewNode(t.t, "carol", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, carol) defer shutdownAndAssert(net, t, carol)
dave, err := net.NewNode("dave", nil) dave := net.NewNode(t.t, "dave", nil)
require.NoError(t.t, err)
defer shutdownAndAssert(net, t, dave) defer shutdownAndAssert(net, t, dave)
// We'll define a helper closure that we'll use throughout the test to // We'll define a helper closure that we'll use throughout the test to

@ -19,31 +19,22 @@ func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
// //
// We'll make two new nodes, with one of them signalling support for // We'll make two new nodes, with one of them signalling support for
// wumbo channels while the other doesn't. // wumbo channels while the other doesn't.
wumboNode, err := net.NewNode( wumboNode := net.NewNode(
"wumbo", []string{"--protocol.wumbo-channels"}, t.t, "wumbo", []string{"--protocol.wumbo-channels"},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, wumboNode) defer shutdownAndAssert(net, t, wumboNode)
miniNode, err := net.NewNode("mini", nil) miniNode := net.NewNode(t.t, "mini", nil)
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, miniNode) defer shutdownAndAssert(net, t, miniNode)
// We'll send coins to the wumbo node, as it'll be the one imitating // We'll send coins to the wumbo node, as it'll be the one imitating
// the channel funding. // the channel funding.
ctxb := context.Background() ctxb := context.Background()
err = net.SendCoins(ctxb, btcutil.SatoshiPerBitcoin, wumboNode) net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, wumboNode)
if err != nil {
t.Fatalf("unable to send coins to carol: %v", err)
}
// Next we'll connect both nodes, then attempt to make a wumbo channel // Next we'll connect both nodes, then attempt to make a wumbo channel
// funding request to the mini node we created above. The wumbo request // funding request to the mini node we created above. The wumbo request
// should fail as the node isn't advertising wumbo channels. // should fail as the node isn't advertising wumbo channels.
err = net.EnsureConnected(ctxb, wumboNode, miniNode) err := net.EnsureConnected(ctxb, wumboNode, miniNode)
if err != nil { if err != nil {
t.Fatalf("unable to connect peers: %v", err) t.Fatalf("unable to connect peers: %v", err)
} }
@ -67,12 +58,9 @@ func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
// We'll now make another wumbo node to accept our wumbo channel // We'll now make another wumbo node to accept our wumbo channel
// funding. // funding.
wumboNode2, err := net.NewNode( wumboNode2 := net.NewNode(
"wumbo2", []string{"--protocol.wumbo-channels"}, t.t, "wumbo2", []string{"--protocol.wumbo-channels"},
) )
if err != nil {
t.Fatalf("unable to create new node: %v", err)
}
defer shutdownAndAssert(net, t, wumboNode2) defer shutdownAndAssert(net, t, wumboNode2)
// Creating a wumbo channel between these two nodes should succeed. // Creating a wumbo channel between these two nodes should succeed.