Skip to content

Commit 76b162d

Browse files
committed
itest: export NewNode, remove OpenChannelParams
1 parent a144cfe commit 76b162d

File tree

2 files changed

+22
-55
lines changed

2 files changed

+22
-55
lines changed

itest/network_harness.go

Lines changed: 20 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/lightningnetwork/lnd/lnrpc"
2323
"github.com/lightningnetwork/lnd/lntest"
2424
"github.com/lightningnetwork/lnd/lntest/wait"
25-
"github.com/lightningnetwork/lnd/lnwire"
2625
"github.com/stretchr/testify/require"
2726
"golang.org/x/sync/errgroup"
2827
"google.golang.org/grpc/grpclog"
@@ -131,31 +130,20 @@ func (n *NetworkHarness) SetUp(t *testing.T,
131130
err := n.server.start()
132131
require.NoError(t, err)
133132

134-
litArgs := []string{
135-
fmt.Sprintf("--loop.server.host=%s", mockServerAddr),
136-
fmt.Sprintf("--loop.server.tlspath=%s", n.server.certFile),
137-
fmt.Sprintf("--pool.auctionserver=%s", mockServerAddr),
138-
fmt.Sprintf("--pool.tlspathauctserver=%s", n.server.certFile),
139-
}
140-
141133
// Start the initial seeder nodes within the test network, then connect
142134
// their respective RPC clients.
143135
eg := errgroup.Group{}
144136
eg.Go(func() error {
145137
var err error
146-
n.Alice, err = n.newNode(
147-
t, "Alice", lndArgs, litArgs, false, false, nil, true,
148-
)
138+
n.Alice, err = n.NewNode(t, "Alice", lndArgs, false, true)
149139
if err != nil {
150140
t.Logf("Error starting Alice: %v", err)
151141
}
152142
return err
153143
})
154144
eg.Go(func() error {
155145
var err error
156-
n.Bob, err = n.newNode(
157-
t, "Bob", lndArgs, litArgs, false, true, nil, true,
158-
)
146+
n.Bob, err = n.NewNode(t, "Bob", lndArgs, true, true)
159147
if err != nil {
160148
t.Logf("Error starting Bob: %v", err)
161149
}
@@ -274,6 +262,22 @@ func (n *NetworkHarness) Stop() {
274262

275263
}
276264

265+
// NewNode initializes a new HarnessNode.
266+
func (n *NetworkHarness) NewNode(t *testing.T, name string, extraArgs []string,
267+
remoteMode bool, wait bool) (*HarnessNode, error) {
268+
269+
litArgs := []string{
270+
fmt.Sprintf("--loop.server.host=%s", n.server.serverHost),
271+
fmt.Sprintf("--loop.server.tlspath=%s", n.server.certFile),
272+
fmt.Sprintf("--pool.auctionserver=%s", n.server.serverHost),
273+
fmt.Sprintf("--pool.tlspathauctserver=%s", n.server.certFile),
274+
}
275+
276+
return n.newNode(
277+
t, name, extraArgs, litArgs, false, remoteMode, nil, wait,
278+
)
279+
}
280+
277281
// newNode initializes a new HarnessNode, supporting the ability to initialize a
278282
// wallet with or without a seed. If hasSeed is false, the returned harness node
279283
// can be used immediately. Otherwise, the node will require an additional
@@ -728,53 +732,16 @@ func (n *NetworkHarness) waitForTxInMempool(ctx context.Context,
728732
}
729733
}
730734

731-
// OpenChannelParams houses the params to specify when opening a new channel.
732-
type OpenChannelParams struct {
733-
// Amt is the local amount being put into the channel.
734-
Amt btcutil.Amount
735-
736-
// PushAmt is the amount that should be pushed to the remote when the
737-
// channel is opened.
738-
PushAmt btcutil.Amount
739-
740-
// Private is a boolan indicating whether the opened channel should be
741-
// private.
742-
Private bool
743-
744-
// SpendUnconfirmed is a boolean indicating whether we can utilize
745-
// unconfirmed outputs to fund the channel.
746-
SpendUnconfirmed bool
747-
748-
// MinHtlc is the htlc_minimum_msat value set when opening the channel.
749-
MinHtlc lnwire.MilliSatoshi
750-
751-
// RemoteMaxHtlcs is the remote_max_htlcs value set when opening the
752-
// channel, restricting the number of concurrent HTLCs the remote party
753-
// can add to a commitment.
754-
RemoteMaxHtlcs uint16
755-
756-
// FundingShim is an optional funding shim that the caller can specify
757-
// in order to modify the channel funding workflow.
758-
FundingShim *lnrpc.FundingShim
759-
760-
// SatPerVByte is the amount of satoshis to spend in chain fees per virtual
761-
// byte of the transaction.
762-
SatPerVByte btcutil.Amount
763-
764-
// CommitmentType is the commitment type that should be used for the
765-
// channel to be opened.
766-
CommitmentType lnrpc.CommitmentType
767-
}
768-
769735
// OpenChannel attempts to open a channel between srcNode and destNode with the
770736
// passed channel funding parameters. If the passed context has a timeout, then
771737
// if the timeout is reached before the channel pending notification is
772738
// received, an error is returned. The confirmed boolean determines whether we
773739
// should fund the channel with confirmed outputs or not.
774740
func (n *NetworkHarness) OpenChannel(srcNode, destNode *HarnessNode,
775-
p OpenChannelParams) (lnrpc.Lightning_OpenChannelClient, error) {
741+
p lntest.OpenChannelParams) (lnrpc.Lightning_OpenChannelClient, error) {
776742

777743
ctxb := context.Background()
744+
778745
// The cancel is intentionally left out here because the returned
779746
// item(open channel client) relies on the context being active. This
780747
// will be fixed once we finish refactoring the NetworkHarness.

itest/test_harness.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func waitForNTxsInMempool(miner *rpcclient.Client, n int,
159159
// give all network participants time to catch up.
160160
//
161161
// NOTE: This function currently is just an alias for mineBlocksSlow.
162-
func mineBlocks(t *harnessTest, net *lntest.NetworkHarness,
162+
func mineBlocks(t *harnessTest, net *NetworkHarness,
163163
num uint32, numTxs int) []*wire.MsgBlock {
164164

165165
return mineBlocksSlow(t, net, num, numTxs)
@@ -170,7 +170,7 @@ func mineBlocks(t *harnessTest, net *lntest.NetworkHarness,
170170
// transactions (excluding the coinbase) we expect to be included in the first
171171
// mined block. Between each mined block an artificial delay is introduced to
172172
// give all network participants time to catch up.
173-
func mineBlocksSlow(t *harnessTest, net *lntest.NetworkHarness,
173+
func mineBlocksSlow(t *harnessTest, net *NetworkHarness,
174174
num uint32, numTxs int) []*wire.MsgBlock {
175175

176176
t.t.Helper()

0 commit comments

Comments
 (0)