itest: manage context inside SendCoins

This commit is contained in:
yyforyongyu 2021-08-19 20:49:39 +08:00
parent 8de495b96b
commit d10d1e3e24
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
19 changed files with 126 additions and 183 deletions

View file

@ -1386,12 +1386,11 @@ func (n *NetworkHarness) DumpLogs(node *HarnessNode) (string, error) {
// 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
// order to confirm the transaction.
func (n *NetworkHarness) SendCoins(ctx context.Context, t *testing.T,
amt btcutil.Amount, target *HarnessNode) {
func (n *NetworkHarness) SendCoins(t *testing.T, amt btcutil.Amount,
target *HarnessNode) {
err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH,
true,
amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH, true,
)
require.NoErrorf(t, err, "unable to send coins for %s", target.Cfg.Name)
}
@ -1399,12 +1398,11 @@ func (n *NetworkHarness) SendCoins(ctx context.Context, t *testing.T,
// SendCoinsUnconfirmed sends coins from the internal mining node to the target
// lightning node using a P2WPKH address. No blocks are mined after, so the
// transaction remains unconfirmed.
func (n *NetworkHarness) SendCoinsUnconfirmed(ctx context.Context,
t *testing.T, amt btcutil.Amount, target *HarnessNode) {
func (n *NetworkHarness) SendCoinsUnconfirmed(t *testing.T, amt btcutil.Amount,
target *HarnessNode) {
err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH,
false,
amt, target, lnrpc.AddressType_WITNESS_PUBKEY_HASH, false,
)
require.NoErrorf(
t, err, "unable to send unconfirmed coins for %s",
@ -1414,12 +1412,11 @@ func (n *NetworkHarness) SendCoinsUnconfirmed(ctx context.Context,
// SendCoinsNP2WKH attempts to send amt satoshis from the internal mining node
// to the targeted lightning node using a NP2WKH address.
func (n *NetworkHarness) SendCoinsNP2WKH(ctx context.Context,
t *testing.T, amt btcutil.Amount, target *HarnessNode) {
func (n *NetworkHarness) SendCoinsNP2WKH(t *testing.T, amt btcutil.Amount,
target *HarnessNode) {
err := n.sendCoins(
ctx, amt, target, lnrpc.AddressType_NESTED_PUBKEY_HASH,
true,
amt, target, lnrpc.AddressType_NESTED_PUBKEY_HASH, true,
)
require.NoErrorf(
t, err, "unable to send NP2WKH coins for %s",
@ -1430,9 +1427,12 @@ func (n *NetworkHarness) SendCoinsNP2WKH(ctx context.Context,
// sendCoins attempts to send amt satoshis from the internal mining node to the
// targeted lightning node. The confirmed boolean indicates whether the
// transaction that pays to the target should confirm.
func (n *NetworkHarness) sendCoins(ctx context.Context, amt btcutil.Amount,
target *HarnessNode, addrType lnrpc.AddressType,
confirmed bool) error {
func (n *NetworkHarness) sendCoins(amt btcutil.Amount, target *HarnessNode,
addrType lnrpc.AddressType, confirmed bool) error {
ctxb := context.Background()
ctx, cancel := context.WithTimeout(ctxb, DefaultTimeout)
defer cancel()
balReq := &lnrpc.WalletBalanceRequest{}
initialBalance, err := target.WalletBalance(ctx, balReq)

View file

@ -876,17 +876,15 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
// Now that our new nodes are created, we'll give them some coins for
// channel opening and anchor sweeping.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// For the anchor output case we need two UTXOs for Carol so she can
// sweep both the local and remote anchor.
if testCase.anchorCommit {
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
var from, to *lntest.HarnessNode
if testCase.initiator {
@ -904,7 +902,7 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
var chanPoint *lnrpc.ChannelPoint
switch {
case testCase.unconfirmed:
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
_, err := net.OpenPendingChannel(
ctxt, from, to, chanAmt, pushAmt,
)
@ -945,7 +943,7 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
)
// Wait for both sides to see the opened channel.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("dave didn't report channel: %v", err)
@ -959,6 +957,8 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
// If both parties should start with existing channel updates, then
// we'll send+settle an HTLC between 'from' and 'to' now.
if testCase.channelsUpdated {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
invoice := &lnrpc.Invoice{
Memo: "testing",
Value: 100000,
@ -968,7 +968,6 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
t.Fatalf("unable to add invoice: %v", err)
}
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = completePaymentRequests(
ctxt, from, from.RouterClient,
[]string{invoiceResp.PaymentRequest}, true,
@ -1007,7 +1006,7 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
// Before we start the recovery, we'll record the balances of both
// Carol and Dave to ensure they both sweep their coins at the end.
balReq := &lnrpc.WalletBalanceRequest{}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolBalResp, err := carol.WalletBalance(ctxt, balReq)
if err != nil {
t.Fatalf("unable to get carol's balance: %v", err)

View file

@ -73,19 +73,19 @@ func testCommitmentTransactionDeadline(net *lntest.NetworkHarness,
net.SetFeeEstimate(feeRateDefault)
// setupNode creates a new node and sends 1 btc to the node.
setupNode := func(ctx context.Context, name string) *lntest.HarnessNode {
setupNode := func(name string) *lntest.HarnessNode {
// Create the node.
args := []string{"--hodl.exit-settle"}
args = append(args, commitTypeAnchors.Args()...)
node := net.NewNode(t.t, name, args)
// Send some coins to the node.
net.SendCoins(ctx, t.t, btcutil.SatoshiPerBitcoin, node)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, node)
// For neutrino backend, we need one additional UTXO to create
// the sweeping tx for the remote anchor.
if net.BackendCfg.Name() == lntest.NeutrinoBackendName {
net.SendCoins(ctx, t.t, btcutil.SatoshiPerBitcoin, node)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, node)
}
return node
@ -98,10 +98,10 @@ func testCommitmentTransactionDeadline(net *lntest.NetworkHarness,
defer cancel()
// Create two nodes, Alice and Bob.
alice := setupNode(ctxt, "Alice")
alice := setupNode("Alice")
defer shutdownAndAssert(net, t, alice)
bob := setupNode(ctxt, "Bob")
bob := setupNode("Bob")
defer shutdownAndAssert(net, t, bob)
// Connect Alice to Bob.
@ -277,14 +277,11 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
// Each time, we'll send Alice new set of coins in
// order to fund the channel.
ctxt, _ := context.WithTimeout(
context.Background(), defaultTimeout,
)
net.SendCoins(ctxt, t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t, btcutil.SatoshiPerBitcoin, alice)
// Also give Carol some coins to allow her to sweep her
// anchor.
net.SendCoins(ctxt, t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t, btcutil.SatoshiPerBitcoin, carol)
channelForceClosureTest(
net, ht, alice, carol, channelType,
@ -320,14 +317,13 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
net.ConnectNodes(t.t, alice, carol)
// We need one additional UTXO for sweeping the remote anchor.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)
// Before we start, obtain Carol's current wallet balance, we'll check
// to ensure that at the end of the force closure by Alice, Carol
// recognizes his new on-chain output.
carolBalReq := &lnrpc.WalletBalanceRequest{}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolBalResp, err := carol.WalletBalance(ctxt, carolBalReq)
if err != nil {
t.Fatalf("unable to get carol's balance: %v", err)

View file

@ -48,8 +48,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
net.ConnectNodes(t.t, alice, bob)
// Give Alice some coins so she can fund a channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)
// Open a channel with 100k satoshis between Alice and Bob with Alice
// being the sole funder of the channel.
@ -63,7 +62,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the
// funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("alice didn't see the alice->bob channel before "+
@ -445,12 +444,10 @@ func testGraphTopologyNtfns(net *lntest.NetworkHarness, t *harnessTest, pinned b
net.EnsureConnected(ctxt, t.t, alice, bob)
// Alice stimmy.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)
// Bob stimmy.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, bob)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, bob)
// Assert that Bob has the correct sync type before proceeeding.
if pinned {

View file

@ -109,8 +109,7 @@ func testUpdateChannelPolicy(net *lntest.NetworkHarness, t *harnessTest) {
nodes = append(nodes, carol)
// Send some coins to Carol that can be used for channel funding.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
net.ConnectNodes(t.t, carol, net.Bob)

View file

@ -354,10 +354,7 @@ func (c *interceptorTestContext) prepareTestCases() []*interceptorTestCase {
func (c *interceptorTestContext) openChannel(from, to *lntest.HarnessNode,
chanSize btcutil.Amount) {
ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
c.net.SendCoins(ctxt, c.t.t, btcutil.SatoshiPerBitcoin, from)
c.net.SendCoins(c.t.t, btcutil.SatoshiPerBitcoin, from)
chanPoint := openChannelAndAssert(
c.t, c.net, from, to,

View file

@ -49,8 +49,7 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
// Each time, we'll send Carol a new set of coins in order to
// fund the channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
daveArgs := daveCommitType.Args()
dave := net.NewNode(t.t, "Dave", daveArgs)
@ -58,7 +57,7 @@ func testBasicChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
// Before we start the test, we'll ensure both sides are
// connected to the funding flow can properly be executed.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.EnsureConnected(ctxt, t.t, carol, dave)
carolChan, daveChan, closeChan, err := basicChannelFundingTest(
@ -265,15 +264,14 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
// We'll send her some confirmed funds.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, 2*chanAmt, carol)
net.SendCoins(t.t, 2*chanAmt, carol)
// Now let Carol send some funds to herself, making a unconfirmed
// change output.
addrReq := &lnrpc.NewAddressRequest{
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := carol.NewAddress(ctxt, addrReq)
require.NoError(t.t, err, "unable to get new address")
@ -388,12 +386,11 @@ func testExternalFundingChanPoint(net *lntest.NetworkHarness, t *harnessTest) {
// Carol will be funding the channel, so we'll send some coins over to
// her and ensure they have enough confirmations before we proceed.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// Before we start the test, we'll ensure both sides are connected to
// the funding flow can properly be executed.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.EnsureConnected(ctxt, t.t, carol, dave)
// At this point, we're ready to simulate our external channel funding

View file

@ -30,7 +30,7 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
// We'll send 11 BTC to the wumbo node so it can test the wumbo soft limit.
ctxb := context.Background()
net.SendCoins(ctxb, t.t, 11*btcutil.SatoshiPerBitcoin, wumboNode)
net.SendCoins(t.t, 11*btcutil.SatoshiPerBitcoin, wumboNode)
// Next we'll connect both nodes, then attempt to make a wumbo channel
// funding request, which should fail as it exceeds the default wumbo

View file

@ -53,8 +53,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
assertNumConnections(t, alice, bob, 1)
// Give Alice some coins so she can fund a channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)
chanAmt := funding.MaxBtcFundingAmount
pushAmt := btcutil.Amount(0)
@ -62,7 +61,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
// Create a new channel that requires 1 confs before it's considered
// open, then broadcast the funding transaction
const numConfs = 1
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
pendingUpdate, err := net.OpenPendingChannel(
ctxt, alice, bob, chanAmt, pushAmt,
)
@ -199,8 +198,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPoint := openChannelAndAssert(
t, net, carol, dave,
@ -218,8 +216,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, fred)
net.ConnectNodes(t.t, fred, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, fred)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, fred)
chanPointFC := openChannelAndAssert(
t, net, fred, carol,
@ -238,7 +235,7 @@ func testSphinxReplayPersistence(net *lntest.NetworkHarness, t *harnessTest) {
RPreimage: preimage,
Value: paymentAmt,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
invoiceResp, err := dave.AddInvoice(ctxt, invoice)
if err != nil {
t.Fatalf("unable to add invoice: %v", err)
@ -376,8 +373,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
net.ConnectNodes(t.t, alice, bob)
// Give Alice some coins so she can fund a channel.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, 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
@ -396,7 +392,7 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Wait for Alice and Bob to receive the channel edge from the
// funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err := alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("alice didn't see the alice->bob channel before "+
@ -506,16 +502,15 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
net.ConnectNodes(t.t, net.Alice, carol)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolBalance := btcutil.Amount(maxPendingChannels) * amount
net.SendCoins(ctxt, t.t, carolBalance, carol)
net.SendCoins(t.t, carolBalance, carol)
// Send open channel requests without generating new blocks thereby
// increasing pool of pending channels. Then check that we can't open
// the channel if the number of pending channels exceed max value.
openStreams := make([]lnrpc.Lightning_OpenChannelClient, maxPendingChannels)
for i := 0; i < maxPendingChannels; i++ {
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
stream := openChannelStream(
ctxt, t, net, net.Alice, carol,
lntest.OpenChannelParams{
@ -527,7 +522,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Carol exhausted available amount of pending channels, next open
// channel request should cause ErrorGeneric to be sent back to Alice.
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
_, err := net.OpenChannel(
ctxt, net.Alice, carol,
lntest.OpenChannelParams{
@ -855,8 +850,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
// Before we make a channel, we'll load up Carol with some coins sent
// directly from the miner.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// 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
@ -868,7 +862,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
// We must let the node communicate with Carol before they are
// able to open channel, so we connect them.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.EnsureConnected(ctxt, t.t, carol, node)
// We'll first open up a channel between them with a 0.5 BTC
@ -1016,7 +1010,7 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
// We make a note of the nodes' current on-chain balances, to make sure
// they are able to retrieve the channel funds eventually,
balReq := &lnrpc.WalletBalanceRequest{}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolBalResp, err := carol.WalletBalance(ctxt, balReq)
if err != nil {
t.Fatalf("unable to get carol's balance: %v", err)
@ -1153,10 +1147,10 @@ func testRejectHTLC(net *lntest.NetworkHarness, t *harnessTest) {
net.ConnectNodes(t.t, carol, net.Bob)
// Send coins to Carol.
net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// Send coins to Alice.
net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcent, net.Alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcent, net.Alice)
// Open a channel between Alice and Carol.
chanPointAlice := openChannelAndAssert(
@ -1403,8 +1397,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, eve)
// Give Eve some coins.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, eve)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, eve)
// Connect Eve to Carol and Bob, and open a channel to carol.
net.ConnectNodes(t.t, eve, carol)
@ -1469,7 +1462,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
// Now we'll test a long disconnection. Disconnect Carol and Eve and
// ensure they both detect each other as disabled. Their min backoffs
// are high enough to not interfere with disabling logic.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
if err := net.DisconnectNodes(ctxt, carol, eve); err != nil {
t.Fatalf("unable to disconnect Carol from Eve: %v", err)
}
@ -1716,13 +1709,12 @@ func testSweepAllCoins(net *lntest.NetworkHarness, t *harnessTest) {
// 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.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, ainz)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, ainz)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoinsNP2WKH(ctxt, t.t, btcutil.SatoshiPerBitcoin, ainz)
net.SendCoinsNP2WKH(t.t, btcutil.SatoshiPerBitcoin, ainz)
// Ensure that we can't send coins to our own Pubkey.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
info, err := ainz.GetInfo(ctxt, &lnrpc.GetInfoRequest{})
if err != nil {
t.Fatalf("unable to get node info: %v", err)

View file

@ -290,11 +290,10 @@ func newMppTestContext(t *harnessTest,
}
// openChannel is a helper to open a channel from->to.
func (c *mppTestContext) openChannel(from, to *lntest.HarnessNode, chanSize btcutil.Amount) {
ctxb := context.Background()
func (c *mppTestContext) openChannel(from, to *lntest.HarnessNode,
chanSize btcutil.Amount) {
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
c.net.SendCoins(ctxt, c.t.t, btcutil.SatoshiPerBitcoin, from)
c.net.SendCoins(c.t.t, btcutil.SatoshiPerBitcoin, from)
chanPoint := openChannelAndAssert(
c.t, c.net, from, to,

View file

@ -50,8 +50,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -75,8 +74,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -109,7 +107,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -132,7 +130,7 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the
// network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err)

View file

@ -211,11 +211,8 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
// Make sure there are enough utxos for anchoring.
for i := 0; i < 2; i++ {
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, alice)
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, bob)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, bob)
}
// We'll start the test by creating a channel between Alice and Bob,
@ -256,8 +253,7 @@ func createThreeHopNetwork(t *harnessTest, net *lntest.NetworkHarness,
// needs to be attached as an additional input. This can still lead to a
// positively-yielding transaction.
for i := 0; i < 2; i++ {
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
}
// We'll then create a channel from Bob to Carol. After this channel is

View file

@ -31,14 +31,13 @@ func testCPFP(net *lntest.NetworkHarness, t *harnessTest) {
// We'll start the test by sending Alice some coins, which she'll use to
// send to Bob.
ctxb := context.Background()
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Alice)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Alice)
// Create an address for Bob to send the coins to.
addrReq := &lnrpc.NewAddressRequest{
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
resp, err := net.Bob.NewAddress(ctxt, addrReq)
if err != nil {
t.Fatalf("unable to get new address for bob: %v", err)
@ -185,13 +184,12 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
feeEst = 8000
)
ctxt, _ := context.WithTimeout(context.Background(), defaultTimeout)
net.SendCoins(ctxt, t.t, chanAmt+feeEst, alice)
net.SendCoins(t.t, chanAmt+feeEst, alice)
// wallet, without a change output. This should not be allowed.
resErr := lnwallet.ErrReservedValueInvalidated.Error()
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
ctxt, _ := context.WithTimeout(context.Background(), defaultTimeout)
_, err := net.OpenChannel(
ctxt, alice, bob,
lntest.OpenChannelParams{

View file

@ -31,7 +31,7 @@ func testPsbtChanFunding(net *lntest.NetworkHarness, t *harnessTest) {
dave := net.NewNode(t.t, "dave", nil)
defer shutdownAndAssert(net, t, dave)
net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
// Before we start the test, we'll ensure both sides are connected so
// the funding flow can be properly executed.

View file

@ -233,15 +233,11 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
}
// Send one BTC to the next P2WKH address.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(
ctxt, t.t, btcutil.SatoshiPerBitcoin, node,
)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, node)
// And another to the next NP2WKH address.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoinsNP2WKH(
ctxt, t.t, btcutil.SatoshiPerBitcoin, node,
t.t, btcutil.SatoshiPerBitcoin, node,
)
}
}

View file

@ -48,8 +48,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
// Before we make a channel, we'll load up Carol with some coins sent
// directly from the miner.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// 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
@ -71,7 +70,7 @@ func testRevokedCloseRetribution(net *lntest.NetworkHarness, t *harnessTest) {
}
// Wait for Carol to receive the channel edge from the funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = carol.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("carol didn't see the carol->bob channel before "+
@ -304,8 +303,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
// Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
// 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
@ -327,7 +325,7 @@ func testRevokedCloseRetributionZeroValueRemoteOutput(net *lntest.NetworkHarness
}
// Wait for Dave to receive the channel edge from the funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("dave didn't see the dave->carol channel before "+
@ -535,8 +533,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner.
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
// 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
@ -561,7 +558,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// We'll introduce a closure to validate that Carol's current balance
// matches the given expected amount.
checkCarolBalance := func(expectedAmt int64) {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolChan, err := getChanInfo(ctxt, carol)
if err != nil {
t.Fatalf("unable to get carol's channel info: %v", err)
@ -577,7 +574,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
// number of updates is at least as large as the provided minimum
// number.
checkCarolNumUpdatesAtLeast := func(minimum uint64) {
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
carolChan, err := getChanInfo(ctxt, carol)
if err != nil {
t.Fatalf("unable to get carol's channel info: %v", err)
@ -590,7 +587,7 @@ func testRevokedCloseRetributionRemoteHodl(net *lntest.NetworkHarness,
}
// Wait for Dave to receive the channel edge from the funding manager.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("dave didn't see the dave->carol channel before "+
@ -1030,7 +1027,7 @@ func testRevokedCloseRetributionAltruistWatchtowerCase(
// Before we make a channel, we'll load up Dave with some coins sent
// directly from the miner.
net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
// 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

View file

@ -104,8 +104,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
// Open a channel with 100k satoshis between Carol and Dave with Carol
// being the sole funder of the channel.
@ -139,7 +138,7 @@ func testSingleHopSendToRouteCase(net *lntest.NetworkHarness, t *harnessTest,
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -467,8 +466,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, net.Bob)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)
chanPointBob := openChannelAndAssert(
t, net, net.Bob, carol,
@ -500,7 +498,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -532,7 +530,7 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) {
Amt: paymentAmt,
FinalCltvDelta: chainreg.DefaultBitcoinTimeLockDelta,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
routes, err := net.Alice.QueryRoutes(ctxt, routesReq)
if err != nil {
t.Fatalf("unable to get route: %v", err)
@ -636,14 +634,12 @@ func testSendToRouteErrorPropagation(net *lntest.NetworkHarness, t *harnessTest)
carol := net.NewNode(t.t, "Carol", nil)
defer shutdownAndAssert(net, t, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
charlie := net.NewNode(t.t, "Charlie", nil)
defer shutdownAndAssert(net, t, charlie)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, charlie)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, charlie)
net.ConnectNodes(t.t, carol, charlie)
@ -759,8 +755,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -784,8 +779,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -819,7 +813,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -831,7 +825,7 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
// Now create a _private_ channel directly between Carol and
// Alice of 100k.
net.ConnectNodes(t.t, carol, net.Alice)
ctxt, _ = context.WithTimeout(ctxb, channelOpenTimeout)
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
chanOpenUpdate := openChannelStream(
ctxt, t, net, carol, net.Alice,
lntest.OpenChannelParams{
@ -1459,8 +1453,7 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest)
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -1594,8 +1587,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, net.Bob)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, net.Bob)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, net.Bob)
chanPointBob := openChannelAndAssert(
t, net, net.Bob, carol,
@ -1610,8 +1602,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, carol)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -1635,7 +1626,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -1651,7 +1642,7 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) {
PubKey: dave.PubKeyStr,
Amt: paymentAmt,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
routesRes, err := net.Alice.QueryRoutes(ctxt, routesReq)
if err != nil {
t.Fatalf("unable to get route: %v", err)
@ -1881,8 +1872,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointAliceCarol := openChannelAndAssert(
t, net, net.Alice, carol,
@ -1969,7 +1959,7 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) {
ChanPoint: chanPointCarolDave,
},
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
if _, err := carol.UpdateChannelPolicy(ctxt, updateFeeReq); err != nil {
t.Fatalf("unable to update chan policy: %v", err)
}

View file

@ -58,8 +58,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -85,8 +84,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -120,7 +118,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -143,7 +141,7 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the
// network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err)
@ -344,8 +342,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -371,8 +368,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -406,7 +402,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -429,7 +425,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
// We'll wait for all parties to recognize the new channels within the
// network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err)
@ -656,8 +652,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -684,8 +679,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
defer shutdownAndAssert(net, t, carol)
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -719,7 +713,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -742,7 +736,7 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness
// We'll wait for all parties to recognize the new channels within the
// network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err)
@ -955,8 +949,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
defer shutdownAndAssert(net, t, dave)
net.ConnectNodes(t.t, dave, net.Alice)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, dave)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, dave)
chanPointDave := openChannelAndAssert(
t, net, dave, net.Alice,
@ -980,8 +973,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
// intermediary hops before starting the settle.
carol := net.NewNode(t.t, "Carol", []string{"--hodl.exit-settle"})
net.ConnectNodes(t.t, carol, dave)
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
net.SendCoins(ctxt, t.t, btcutil.SatoshiPerBitcoin, carol)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, carol)
chanPointCarol := openChannelAndAssert(
t, net, carol, dave,
@ -1015,7 +1007,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
Index: chanPoint.OutputIndex,
}
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = node.WaitForNetworkChannelOpen(ctxt, chanPoint)
if err != nil {
t.Fatalf("%s(%d): timeout waiting for "+
@ -1038,7 +1030,7 @@ func testSwitchOfflineDeliveryOutgoingOffline(
// We'll wait for all parties to recognize the new channels within the
// network.
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
err = dave.WaitForNetworkChannelOpen(ctxt, chanPointDave)
if err != nil {
t.Fatalf("dave didn't advertise his channel: %v", err)

View file

@ -29,7 +29,7 @@ func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
// We'll send coins to the wumbo node, as it'll be the one imitating
// the channel funding.
ctxb := context.Background()
net.SendCoins(ctxb, t.t, btcutil.SatoshiPerBitcoin, wumboNode)
net.SendCoins(t.t, btcutil.SatoshiPerBitcoin, wumboNode)
// 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