@@ -22,7 +22,6 @@ import (
22
22
"github.com/lightningnetwork/lnd/lnrpc"
23
23
"github.com/lightningnetwork/lnd/lntest"
24
24
"github.com/lightningnetwork/lnd/lntest/wait"
25
- "github.com/lightningnetwork/lnd/lnwire"
26
25
"github.com/stretchr/testify/require"
27
26
"golang.org/x/sync/errgroup"
28
27
"google.golang.org/grpc/grpclog"
@@ -131,31 +130,20 @@ func (n *NetworkHarness) SetUp(t *testing.T,
131
130
err := n .server .start ()
132
131
require .NoError (t , err )
133
132
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
-
141
133
// Start the initial seeder nodes within the test network, then connect
142
134
// their respective RPC clients.
143
135
eg := errgroup.Group {}
144
136
eg .Go (func () error {
145
137
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 )
149
139
if err != nil {
150
140
t .Logf ("Error starting Alice: %v" , err )
151
141
}
152
142
return err
153
143
})
154
144
eg .Go (func () error {
155
145
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 )
159
147
if err != nil {
160
148
t .Logf ("Error starting Bob: %v" , err )
161
149
}
@@ -274,6 +262,22 @@ func (n *NetworkHarness) Stop() {
274
262
275
263
}
276
264
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
+
277
281
// newNode initializes a new HarnessNode, supporting the ability to initialize a
278
282
// wallet with or without a seed. If hasSeed is false, the returned harness node
279
283
// can be used immediately. Otherwise, the node will require an additional
@@ -728,53 +732,16 @@ func (n *NetworkHarness) waitForTxInMempool(ctx context.Context,
728
732
}
729
733
}
730
734
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
-
769
735
// OpenChannel attempts to open a channel between srcNode and destNode with the
770
736
// passed channel funding parameters. If the passed context has a timeout, then
771
737
// if the timeout is reached before the channel pending notification is
772
738
// received, an error is returned. The confirmed boolean determines whether we
773
739
// should fund the channel with confirmed outputs or not.
774
740
func (n * NetworkHarness ) OpenChannel (srcNode , destNode * HarnessNode ,
775
- p OpenChannelParams ) (lnrpc.Lightning_OpenChannelClient , error ) {
741
+ p lntest. OpenChannelParams ) (lnrpc.Lightning_OpenChannelClient , error ) {
776
742
777
743
ctxb := context .Background ()
744
+
778
745
// The cancel is intentionally left out here because the returned
779
746
// item(open channel client) relies on the context being active. This
780
747
// will be fixed once we finish refactoring the NetworkHarness.
0 commit comments