@@ -269,11 +269,8 @@ func (n *NetworkHarness) Stop() {
269
269
n .autopilotServer .Stop ()
270
270
}
271
271
272
- // NewNode initializes a new HarnessNode.
273
- func (n * NetworkHarness ) NewNode (t * testing.T , name string , extraArgs []string ,
274
- remoteMode bool , wait bool ) (* HarnessNode , error ) {
275
-
276
- litArgs := []string {
272
+ func (n * NetworkHarness ) litArgs () []string {
273
+ return []string {
277
274
fmt .Sprintf ("--loop.server.host=%s" , n .server .ServerHost ),
278
275
fmt .Sprintf ("--loop.server.tlspath=%s" , n .server .CertFile ),
279
276
fmt .Sprintf ("--pool.auctionserver=%s" , n .server .ServerHost ),
@@ -284,10 +281,15 @@ func (n *NetworkHarness) NewNode(t *testing.T, name string, extraArgs []string,
284
281
n .autopilotServer .GetPort (),
285
282
),
286
283
}
284
+ }
285
+
286
+ // NewNode initializes a new HarnessNode.
287
+ func (n * NetworkHarness ) NewNode (t * testing.T , name string , extraArgs []string ,
288
+ remoteMode bool , wait bool ) (* HarnessNode , error ) {
287
289
288
290
return n .newNode (
289
- t , name , extraArgs , litArgs , false , remoteMode , nil , wait ,
290
- false ,
291
+ t , name , extraArgs , n . litArgs () , false , remoteMode , nil ,
292
+ wait , false ,
291
293
)
292
294
}
293
295
@@ -348,6 +350,61 @@ func (n *NetworkHarness) newNode(t *testing.T, name string, extraArgs,
348
350
return node , nil
349
351
}
350
352
353
+ // NewNodeWithSeed fully initializes a new HarnessNode after creating a fresh
354
+ // aezeed. The provided password is used as both the aezeed password and the
355
+ // wallet password. The harness node is returned along with an admin macaroon
356
+ // for the LND node.
357
+ func (n * NetworkHarness ) NewNodeWithSeed (t * testing.T , name string ,
358
+ extraArgs []string , walletPassword []byte , remoteMode ,
359
+ statelessInit bool ) (* HarnessNode , []byte ) {
360
+
361
+ node , err := n .newNode (
362
+ t , name , extraArgs , n .litArgs (), true , remoteMode ,
363
+ walletPassword , false , true ,
364
+ )
365
+ require .NoError (t , err )
366
+
367
+ conn , err := node .ConnectRPC (false )
368
+ require .NoError (t , err )
369
+
370
+ // Initially, we just care about LND's wallet being ready for unlock.
371
+ err = node .WaitForLNDWalletReady ()
372
+ require .NoError (t , err )
373
+
374
+ // Set the wallet unlocker client.
375
+ node .WalletUnlockerClient = lnrpc .NewWalletUnlockerClient (conn )
376
+
377
+ ctxt , cancel := context .WithTimeout (
378
+ context .Background (), defaultTimeout ,
379
+ )
380
+ defer cancel ()
381
+
382
+ // Generate a new seed.
383
+ genSeedResp , err := node .GenSeed (ctxt , & lnrpc.GenSeedRequest {
384
+ AezeedPassphrase : walletPassword ,
385
+ })
386
+ require .NoError (t , err )
387
+
388
+ // With the seed created, construct the init request to the node,
389
+ // including the newly generated seed.
390
+ initReq := & lnrpc.InitWalletRequest {
391
+ WalletPassword : walletPassword ,
392
+ CipherSeedMnemonic : genSeedResp .CipherSeedMnemonic ,
393
+ AezeedPassphrase : walletPassword ,
394
+ StatelessInit : statelessInit ,
395
+ }
396
+
397
+ // Create the wallet and obtain the admin macaroon.
398
+ resp , err := node .Init (ctxt , initReq )
399
+ require .NoError (t , err )
400
+
401
+ // Now wait for the full LiT node to start.
402
+ err = node .WaitUntilStarted (conn , defaultTimeout )
403
+ require .NoError (t , err )
404
+
405
+ return node , resp .AdminMacaroon
406
+ }
407
+
351
408
// RegisterNode records a new HarnessNode in the NetworkHarnesses map of known
352
409
// nodes. This method should only be called with nodes that have successfully
353
410
// retrieved their public keys via FetchNodeInfo.
0 commit comments