lntest: extend OpenChannel to specify whether confirmed funds should be
used
This commit is contained in:
parent
130124bb79
commit
9ec6433863
16
lnd_test.go
16
lnd_test.go
@ -153,7 +153,7 @@ func openChannelAndAssert(ctx context.Context, t *harnessTest,
|
|||||||
private bool) *lnrpc.ChannelPoint {
|
private bool) *lnrpc.ChannelPoint {
|
||||||
|
|
||||||
chanOpenUpdate, err := net.OpenChannel(
|
chanOpenUpdate, err := net.OpenChannel(
|
||||||
ctx, alice, bob, fundingAmt, pushAmt, private,
|
ctx, alice, bob, fundingAmt, pushAmt, private, true,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
@ -3694,8 +3694,9 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
if err := net.ConnectNodes(ctxb, carol, net.Alice); err != nil {
|
if err := net.ConnectNodes(ctxb, carol, net.Alice); err != nil {
|
||||||
t.Fatalf("unable to connect dave to alice: %v", err)
|
t.Fatalf("unable to connect dave to alice: %v", err)
|
||||||
}
|
}
|
||||||
chanOpenUpdate, err := net.OpenChannel(ctxb, carol, net.Alice, chanAmt,
|
chanOpenUpdate, err := net.OpenChannel(
|
||||||
0, true)
|
ctxb, carol, net.Alice, chanAmt, 0, true, true,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
}
|
}
|
||||||
@ -4576,8 +4577,9 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
openStreams := make([]lnrpc.Lightning_OpenChannelClient, maxPendingChannels)
|
openStreams := make([]lnrpc.Lightning_OpenChannelClient, maxPendingChannels)
|
||||||
for i := 0; i < maxPendingChannels; i++ {
|
for i := 0; i < maxPendingChannels; i++ {
|
||||||
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
||||||
stream, err := net.OpenChannel(ctx, net.Alice, carol, amount,
|
stream, err := net.OpenChannel(
|
||||||
0, false)
|
ctx, net.Alice, carol, amount, 0, false, true,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to open channel: %v", err)
|
t.Fatalf("unable to open channel: %v", err)
|
||||||
}
|
}
|
||||||
@ -4587,7 +4589,9 @@ 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.
|
||||||
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
ctx, _ = context.WithTimeout(context.Background(), timeout)
|
||||||
_, err = net.OpenChannel(ctx, net.Alice, carol, amount, 0, false)
|
_, err = net.OpenChannel(
|
||||||
|
ctx, net.Alice, carol, amount, 0, false, true,
|
||||||
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("error wasn't received")
|
t.Fatalf("error wasn't received")
|
||||||
} else if grpc.Code(err) != lnwire.ErrMaxPendingChannels.ToGrpcCode() {
|
} else if grpc.Code(err) != lnwire.ErrMaxPendingChannels.ToGrpcCode() {
|
||||||
|
@ -676,10 +676,12 @@ func (n *NetworkHarness) WaitForTxBroadcast(ctx context.Context, txid chainhash.
|
|||||||
// OpenChannel attempts to open a channel between srcNode and destNode with the
|
// OpenChannel attempts to open a channel between srcNode and destNode with the
|
||||||
// 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. The confirmed boolean determines whether we
|
||||||
|
// should fund the channel with confirmed outputs or not.
|
||||||
func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
||||||
srcNode, destNode *HarnessNode, amt btcutil.Amount,
|
srcNode, destNode *HarnessNode, amt btcutil.Amount,
|
||||||
pushAmt btcutil.Amount, private bool) (lnrpc.Lightning_OpenChannelClient, error) {
|
pushAmt btcutil.Amount,
|
||||||
|
private, confirmed bool) (lnrpc.Lightning_OpenChannelClient, error) {
|
||||||
|
|
||||||
// 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
|
||||||
@ -692,11 +694,17 @@ func (n *NetworkHarness) OpenChannel(ctx context.Context,
|
|||||||
return nil, fmt.Errorf("Unable to sync destNode chain: %v", err)
|
return nil, fmt.Errorf("Unable to sync destNode chain: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minConfs := int32(0)
|
||||||
|
if confirmed {
|
||||||
|
minConfs = 1
|
||||||
|
}
|
||||||
|
|
||||||
openReq := &lnrpc.OpenChannelRequest{
|
openReq := &lnrpc.OpenChannelRequest{
|
||||||
NodePubkey: destNode.PubKey[:],
|
NodePubkey: destNode.PubKey[:],
|
||||||
LocalFundingAmount: int64(amt),
|
LocalFundingAmount: int64(amt),
|
||||||
PushSat: int64(pushAmt),
|
PushSat: int64(pushAmt),
|
||||||
Private: private,
|
Private: private,
|
||||||
|
MinConfs: minConfs,
|
||||||
}
|
}
|
||||||
|
|
||||||
respStream, err := srcNode.OpenChannel(ctx, openReq)
|
respStream, err := srcNode.OpenChannel(ctx, openReq)
|
||||||
|
Loading…
Reference in New Issue
Block a user