mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-10 11:50:28 +02:00
itest: manage context timeout inside network harness
This is the last commit to refactor the context management such that all the timeout are managed inside the network harness.
This commit is contained in:
parent
d9e9238b0c
commit
5a94919b7e
@ -723,7 +723,11 @@ func (n *NetworkHarness) ConnectNodes(t *testing.T, a, b *HarnessNode) {
|
|||||||
|
|
||||||
// DisconnectNodes disconnects node a from node b by sending RPC message
|
// DisconnectNodes disconnects node a from node b by sending RPC message
|
||||||
// from a node to b node
|
// from a node to b node
|
||||||
func (n *NetworkHarness) DisconnectNodes(ctx context.Context, a, b *HarnessNode) error {
|
func (n *NetworkHarness) DisconnectNodes(a, b *HarnessNode) error {
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, DefaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
bobInfo, err := b.GetInfo(ctx, &lnrpc.GetInfoRequest{})
|
bobInfo, err := b.GetInfo(ctx, &lnrpc.GetInfoRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -988,9 +992,12 @@ type OpenChannelParams struct {
|
|||||||
// if the timeout is reached before the channel pending notification is
|
// if the timeout is reached before the channel pending notification is
|
||||||
// received, an error is returned. The confirmed boolean determines whether we
|
// received, an error is returned. The confirmed boolean determines whether we
|
||||||
// should fund the channel with confirmed outputs or not.
|
// should fund the channel with confirmed outputs or not.
|
||||||
func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
|
||||||
srcNode, destNode *HarnessNode, p OpenChannelParams) (
|
p OpenChannelParams) (lnrpc.Lightning_OpenChannelClient, error) {
|
||||||
lnrpc.Lightning_OpenChannelClient, error) {
|
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, ChannelOpenTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Wait until srcNode and destNode have the latest chain synced.
|
// Wait until srcNode and destNode have the latest chain synced.
|
||||||
// Otherwise, we may run into a check within the funding manager that
|
// Otherwise, we may run into a check within the funding manager that
|
||||||
@ -1062,10 +1069,14 @@ func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
|||||||
// passed channel funding parameters. If the passed context has a timeout, then
|
// passed channel funding parameters. If the passed context has a timeout, then
|
||||||
// if the timeout is reached before the channel pending notification is
|
// if the timeout is reached before the channel pending notification is
|
||||||
// received, an error is returned.
|
// received, an error is returned.
|
||||||
func (n *NetworkHarness) OpenPendingChannel(ctx context.Context,
|
func (n *NetworkHarness) OpenPendingChannel(srcNode, destNode *HarnessNode,
|
||||||
srcNode, destNode *HarnessNode, amt btcutil.Amount,
|
amt btcutil.Amount,
|
||||||
pushAmt btcutil.Amount) (*lnrpc.PendingUpdate, error) {
|
pushAmt btcutil.Amount) (*lnrpc.PendingUpdate, error) {
|
||||||
|
|
||||||
|
ctxb := context.Background()
|
||||||
|
ctx, cancel := context.WithTimeout(ctxb, ChannelOpenTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Wait until srcNode and destNode have blockchain synced
|
// Wait until srcNode and destNode have blockchain synced
|
||||||
if err := srcNode.WaitForBlockchainSync(ctx); err != nil {
|
if err := srcNode.WaitForBlockchainSync(ctx); err != nil {
|
||||||
return nil, fmt.Errorf("unable to sync srcNode chain: %v", err)
|
return nil, fmt.Errorf("unable to sync srcNode chain: %v", err)
|
||||||
|
@ -43,17 +43,13 @@ func openChannelStream(t *harnessTest, net *lntest.NetworkHarness,
|
|||||||
|
|
||||||
t.t.Helper()
|
t.t.Helper()
|
||||||
|
|
||||||
ctxb := context.Background()
|
|
||||||
ctx, cancel := context.WithTimeout(ctxb, channelOpenTimeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// Wait until we are able to fund a channel successfully. This wait
|
// Wait until we are able to fund a channel successfully. This wait
|
||||||
// prevents us from erroring out when trying to create a channel while
|
// prevents us from erroring out when trying to create a channel while
|
||||||
// the node is starting up.
|
// the node is starting up.
|
||||||
var chanOpenUpdate lnrpc.Lightning_OpenChannelClient
|
var chanOpenUpdate lnrpc.Lightning_OpenChannelClient
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
var err error
|
var err error
|
||||||
chanOpenUpdate, err = net.OpenChannel(ctx, alice, bob, p)
|
chanOpenUpdate, err = net.OpenChannel(alice, bob, p)
|
||||||
return err
|
return err
|
||||||
}, defaultTimeout)
|
}, defaultTimeout)
|
||||||
require.NoError(t.t, err, "unable to open channel")
|
require.NoError(t.t, err, "unable to open channel")
|
||||||
|
@ -902,9 +902,8 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness,
|
|||||||
var chanPoint *lnrpc.ChannelPoint
|
var chanPoint *lnrpc.ChannelPoint
|
||||||
switch {
|
switch {
|
||||||
case testCase.unconfirmed:
|
case testCase.unconfirmed:
|
||||||
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
|
|
||||||
_, err := net.OpenPendingChannel(
|
_, err := net.OpenPendingChannel(
|
||||||
ctxt, from, to, chanAmt, pushAmt,
|
from, to, chanAmt, pushAmt,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("couldn't open pending channel: %v", err)
|
t.Fatalf("couldn't open pending channel: %v", err)
|
||||||
|
@ -190,8 +190,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// disconnections from automatically disabling the channel again
|
// disconnections from automatically disabling the channel again
|
||||||
// (we don't want to clutter the network with channels that are
|
// (we don't want to clutter the network with channels that are
|
||||||
// falsely advertised as enabled when they don't work).
|
// falsely advertised as enabled when they don't work).
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
||||||
}
|
}
|
||||||
expectedPolicy.Disabled = true
|
expectedPolicy.Disabled = true
|
||||||
@ -230,8 +229,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +259,7 @@ func testUpdateChanStatus(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// note the asymmetry between manual enable and manual disable!
|
// note the asymmetry between manual enable and manual disable!
|
||||||
assertEdgeDisabled(alice, chanPoint, true)
|
assertEdgeDisabled(alice, chanPoint, true)
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
t.Fatalf("unable to disconnect Alice from Bob: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,8 +580,7 @@ out:
|
|||||||
// that a node that does not have any channels open is ignored, so first
|
// that a node that does not have any channels open is ignored, so first
|
||||||
// we disconnect Alice and Bob, open a channel between Bob and Carol,
|
// we disconnect Alice and Bob, open a channel between Bob and Carol,
|
||||||
// and finally connect Alice to Bob again.
|
// and finally connect Alice to Bob again.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(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 := net.NewNode(t.t, "Carol", nil)
|
carol := net.NewNode(t.t, "Carol", nil)
|
||||||
|
@ -512,9 +512,9 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Create a new channel that requires 5 confs before it's considered
|
// Create a new channel that requires 5 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
|
pendingUpdate, err := net.OpenPendingChannel(
|
||||||
pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, carol,
|
net.Alice, carol, chanAmt, pushAmt,
|
||||||
chanAmt, pushAmt)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
}
|
}
|
||||||
@ -572,6 +572,7 @@ func testChannelFundingPersistence(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Assert that our wallet has our opening transaction with a label
|
// Assert that our wallet has our opening transaction with a label
|
||||||
// that does not have a channel ID set yet, because we have not
|
// that does not have a channel ID set yet, because we have not
|
||||||
// reached our required confirmations.
|
// reached our required confirmations.
|
||||||
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
tx := findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice)
|
tx := findTxAtHeight(ctxt, t, height, fundingTxStr, net.Alice)
|
||||||
|
|
||||||
// At this stage, we expect the transaction to be labelled, but not with
|
// At this stage, we expect the transaction to be labelled, but not with
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
package itest
|
package itest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -29,7 +28,6 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
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()
|
|
||||||
net.SendCoins(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
|
// Next we'll connect both nodes, then attempt to make a wumbo channel
|
||||||
@ -39,7 +37,7 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmountWumbo + 1
|
chanAmt := funding.MaxBtcFundingAmountWumbo + 1
|
||||||
_, err := net.OpenChannel(
|
_, err := net.OpenChannel(
|
||||||
ctxb, wumboNode, wumboNode2, lntest.OpenChannelParams{
|
wumboNode, wumboNode2, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -61,7 +59,7 @@ func testMaxChannelSize(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
net.EnsureConnected(t.t, wumboNode, miniNode)
|
net.EnsureConnected(t.t, wumboNode, miniNode)
|
||||||
|
|
||||||
_, err = net.OpenChannel(
|
_, err = net.OpenChannel(
|
||||||
ctxb, wumboNode, miniNode, lntest.OpenChannelParams{
|
wumboNode, miniNode, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -31,8 +31,6 @@ import (
|
|||||||
// Bob-peer and then re-connects them again. We expect Alice to be able to
|
// Bob-peer and then re-connects them again. We expect Alice to be able to
|
||||||
// disconnect at any point.
|
// disconnect at any point.
|
||||||
func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
||||||
ctxb := context.Background()
|
|
||||||
|
|
||||||
// We'll start both nodes with a high backoff so that they don't
|
// We'll start both nodes with a high backoff so that they don't
|
||||||
// reconnect automatically during our test.
|
// reconnect automatically during our test.
|
||||||
args := []string{
|
args := []string{
|
||||||
@ -61,9 +59,8 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Create a new channel that requires 1 confs before it's considered
|
// Create a new channel that requires 1 confs before it's considered
|
||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
const numConfs = 1
|
const numConfs = 1
|
||||||
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
|
|
||||||
pendingUpdate, err := net.OpenPendingChannel(
|
pendingUpdate, err := net.OpenPendingChannel(
|
||||||
ctxt, alice, bob, chanAmt, pushAmt,
|
alice, bob, chanAmt, pushAmt,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
@ -76,7 +73,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Disconnect Alice-peer from Bob-peer and get error causes by one
|
// Disconnect Alice-peer from Bob-peer and get error causes by one
|
||||||
// pending channel with detach node is existing.
|
// pending channel with detach node is existing.
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
t.Fatalf("Bob's peer was disconnected from Alice's"+
|
t.Fatalf("Bob's peer was disconnected from Alice's"+
|
||||||
" while one pending channel is existing: err %v", err)
|
" while one pending channel is existing: err %v", err)
|
||||||
}
|
}
|
||||||
@ -124,7 +121,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Disconnect Alice-peer from Bob-peer and get error causes by one
|
// Disconnect Alice-peer from Bob-peer and get error causes by one
|
||||||
// active channel with detach node is existing.
|
// active channel with detach node is existing.
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
t.Fatalf("Bob's peer was disconnected from Alice's"+
|
t.Fatalf("Bob's peer was disconnected from Alice's"+
|
||||||
" while one active channel is existing: err %v", err)
|
" while one active channel is existing: err %v", err)
|
||||||
}
|
}
|
||||||
@ -149,7 +146,7 @@ func testDisconnectingTargetPeer(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Disconnect Alice-peer from Bob-peer without getting error about
|
// Disconnect Alice-peer from Bob-peer without getting error about
|
||||||
// existing channels.
|
// existing channels.
|
||||||
if err := net.DisconnectNodes(ctxt, alice, bob); err != nil {
|
if err := net.DisconnectNodes(alice, bob); err != nil {
|
||||||
t.Fatalf("unable to disconnect Bob's peer from Alice's: err %v",
|
t.Fatalf("unable to disconnect Bob's peer from Alice's: err %v",
|
||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
@ -517,10 +514,8 @@ 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)
|
|
||||||
_, err := net.OpenChannel(
|
_, err := net.OpenChannel(
|
||||||
ctxt, net.Alice, carol,
|
net.Alice, carol, lntest.OpenChannelParams{
|
||||||
lntest.OpenChannelParams{
|
|
||||||
Amt: amount,
|
Amt: amount,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -558,7 +553,7 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Ensure that the funding transaction enters a block, and is
|
// Ensure that the funding transaction enters a block, and is
|
||||||
// properly advertised by Alice.
|
// properly advertised by Alice.
|
||||||
assertTxInBlock(t, block, fundingTxID)
|
assertTxInBlock(t, block, fundingTxID)
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
err = net.Alice.WaitForNetworkChannelOpen(ctxt, fundingChanPoint)
|
err = net.Alice.WaitForNetworkChannelOpen(ctxt, fundingChanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("channel not seen on network before "+
|
t.Fatalf("channel not seen on network before "+
|
||||||
@ -1452,8 +1447,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Now we'll test a long disconnection. Disconnect Carol and Eve and
|
// Now we'll test a long disconnection. Disconnect Carol and Eve and
|
||||||
// ensure they both detect each other as disabled. Their min backoffs
|
// ensure they both detect each other as disabled. Their min backoffs
|
||||||
// are high enough to not interfere with disabling logic.
|
// are high enough to not interfere with disabling logic.
|
||||||
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(carol, eve); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, carol, eve); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect Carol from Eve: %v", err)
|
t.Fatalf("unable to disconnect Carol from Eve: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1486,8 +1480,7 @@ func testSendUpdateDisableChannel(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// should allow for the disconnect to be detected, but still leave time
|
// should allow for the disconnect to be detected, but still leave time
|
||||||
// to cancel the announcement before the 3 second inactive timeout is
|
// to cancel the announcement before the 3 second inactive timeout is
|
||||||
// hit.
|
// hit.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(carol, eve); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, carol, eve); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect Carol from Eve: %v", err)
|
t.Fatalf("unable to disconnect Carol from Eve: %v", err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
@ -189,10 +189,8 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// 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()
|
||||||
|
|
||||||
ctxt, _ := context.WithTimeout(context.Background(), defaultTimeout)
|
|
||||||
_, err := net.OpenChannel(
|
_, err := net.OpenChannel(
|
||||||
ctxt, alice, bob,
|
alice, bob, lntest.OpenChannelParams{
|
||||||
lntest.OpenChannelParams{
|
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -232,7 +230,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
aliceChanPoint1, aliceChanPoint2, aliceChanPoint3,
|
aliceChanPoint1, aliceChanPoint2, aliceChanPoint3,
|
||||||
}
|
}
|
||||||
for _, chanPoint := range chanPoints {
|
for _, chanPoint := range chanPoints {
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
@ -247,7 +245,7 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
addrReq := &lnrpc.NewAddressRequest{
|
addrReq := &lnrpc.NewAddressRequest{
|
||||||
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
|
Type: lnrpc.AddressType_WITNESS_PUBKEY_HASH,
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
resp, err := alice.NewAddress(ctxt, addrReq)
|
resp, err := alice.NewAddress(ctxt, addrReq)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
@ -82,9 +82,9 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// open, then broadcast the funding transaction
|
// open, then broadcast the funding transaction
|
||||||
chanAmt := funding.MaxBtcFundingAmount
|
chanAmt := funding.MaxBtcFundingAmount
|
||||||
pushAmt := btcutil.Amount(0)
|
pushAmt := btcutil.Amount(0)
|
||||||
ctxt, _ := context.WithTimeout(ctxb, channelOpenTimeout)
|
pendingUpdate, err := net.OpenPendingChannel(
|
||||||
pendingUpdate, err := net.OpenPendingChannel(ctxt, net.Alice, net.Bob,
|
net.Alice, net.Bob, chanAmt, pushAmt,
|
||||||
chanAmt, pushAmt)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ func testOpenChannelAfterReorg(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to get current blockheight %v", err)
|
t.Fatalf("unable to get current blockheight %v", err)
|
||||||
}
|
}
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, _ := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
err = waitForNodeBlockHeight(ctxt, net.Alice, minerHeight)
|
err = waitForNodeBlockHeight(ctxt, net.Alice, minerHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to sync to chain: %v", err)
|
t.Fatalf("unable to sync to chain: %v", err)
|
||||||
|
@ -171,10 +171,8 @@ func testPaymentFollowingChannelOpen(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
channelCapacity := paymentAmt * 1000
|
channelCapacity := paymentAmt * 1000
|
||||||
|
|
||||||
// We first establish a channel between Alice and Bob.
|
// We first establish a channel between Alice and Bob.
|
||||||
ctxt, cancel := context.WithTimeout(ctxb, channelOpenTimeout)
|
|
||||||
defer cancel()
|
|
||||||
pendingUpdate, err := net.OpenPendingChannel(
|
pendingUpdate, err := net.OpenPendingChannel(
|
||||||
ctxt, net.Alice, net.Bob, channelCapacity, 0,
|
net.Alice, net.Bob, channelCapacity, 0,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
@ -221,7 +219,7 @@ func testPaymentFollowingChannelOpen(net *lntest.NetworkHarness, t *harnessTest)
|
|||||||
|
|
||||||
// At this point we want to make sure the channel is opened and not
|
// At this point we want to make sure the channel is opened and not
|
||||||
// pending.
|
// pending.
|
||||||
ctxt, cancel = context.WithTimeout(ctxb, defaultTimeout)
|
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
res, err := net.Bob.ListChannels(ctxt, &lnrpc.ListChannelsRequest{})
|
res, err := net.Bob.ListChannels(ctxt, &lnrpc.ListChannelsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -464,8 +464,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First, disconnect Dave and Alice so that their link is broken.
|
// First, disconnect Dave and Alice so that their link is broken.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(dave, net.Alice); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, dave, net.Alice); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,8 +484,7 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Now, disconnect Dave from Alice again before settling back the
|
// Now, disconnect Dave from Alice again before settling back the
|
||||||
// payment.
|
// payment.
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
if err := net.DisconnectNodes(dave, net.Alice); err != nil {
|
||||||
if err := net.DisconnectNodes(ctxt, dave, net.Alice); err != nil {
|
|
||||||
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
t.Fatalf("unable to disconnect alice from dave: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package itest
|
package itest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
@ -28,7 +27,6 @@ func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// 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()
|
|
||||||
net.SendCoins(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
|
// Next we'll connect both nodes, then attempt to make a wumbo channel
|
||||||
@ -38,7 +36,7 @@ func testWumboChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
chanAmt := funding.MaxBtcFundingAmount + 1
|
chanAmt := funding.MaxBtcFundingAmount + 1
|
||||||
_, err := net.OpenChannel(
|
_, err := net.OpenChannel(
|
||||||
ctxb, wumboNode, miniNode, lntest.OpenChannelParams{
|
wumboNode, miniNode, lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -40,7 +40,6 @@ const (
|
|||||||
defaultTimeout = lntest.DefaultTimeout
|
defaultTimeout = lntest.DefaultTimeout
|
||||||
minerMempoolTimeout = lntest.MinerMempoolTimeout
|
minerMempoolTimeout = lntest.MinerMempoolTimeout
|
||||||
channelCloseTimeout = lntest.ChannelCloseTimeout
|
channelCloseTimeout = lntest.ChannelCloseTimeout
|
||||||
channelOpenTimeout = lntest.ChannelOpenTimeout
|
|
||||||
itestLndBinary = "../../lnd-itest"
|
itestLndBinary = "../../lnd-itest"
|
||||||
anchorSize = 330
|
anchorSize = 330
|
||||||
noFeeLimitMsat = math.MaxInt64
|
noFeeLimitMsat = math.MaxInt64
|
||||||
|
Loading…
x
Reference in New Issue
Block a user