Skip to content

Commit 93f7c08

Browse files
committed
itest+make: add lnd remote signing mode
This commit adds a new flag to the integration test suite that starts the single lnd node (alice) either in normal or in remote-signing mode. In remote-signing mode, alice is actually a watch-only node that is connected to a seconardy signer node over RPC.
1 parent 8785003 commit 93f7c08

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

itest/test_harness.go

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/lightninglabs/taproot-assets/taprpc"
1919
unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
2020
"github.com/lightningnetwork/lnd/build"
21+
"github.com/lightningnetwork/lnd/lnrpc"
22+
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
2123
"github.com/lightningnetwork/lnd/lntest"
2224
"github.com/lightningnetwork/lnd/lntest/node"
2325
"github.com/lightningnetwork/lnd/lntest/port"
@@ -40,13 +42,24 @@ var (
4042

4143
// noDelete is a command line flag for disabling deleting the tapd
4244
// data directories.
43-
noDelete = flag.Bool("nodelete", false, "Set to true to keep all "+
44-
"tapd data directories after completing the tests")
45+
noDelete = flag.Bool(
46+
"nodelete", false, "Set to true to keep all tapd data "+
47+
"directories after completing the tests",
48+
)
4549

4650
// logLevel is a command line flag for setting the log level of the
4751
// integration test output.
48-
logLevel = flag.String("loglevel", "info", "Set the log level of the "+
49-
"integration test output")
52+
logLevel = flag.String(
53+
"loglevel", "info", "Set the log level of the integration "+
54+
"test output",
55+
)
56+
57+
// lndRemoteSigner is a command line flag that indicates whether the
58+
// lnd instances should be set up to use a remote signer.
59+
lndRemoteSigner = flag.Bool(
60+
"lndremotesigner", false, "if true, the lnd instances will "+
61+
"be set up to use a remote signer",
62+
)
5063
)
5164

5265
const (
@@ -303,7 +316,45 @@ func setupHarnesses(t *testing.T, ht *harnessTest,
303316
proofCourier = universeServer
304317
}
305318

306-
alice := lndHarness.NewNodeWithCoins("Alice", nil)
319+
var alice *node.HarnessNode
320+
if *lndRemoteSigner {
321+
signer := lndHarness.NewNode("Signer", nil)
322+
323+
rpcAccts := signer.RPC.ListAccounts(
324+
&walletrpc.ListAccountsRequest{},
325+
)
326+
327+
watchOnlyAccounts, err := walletrpc.AccountsToWatchOnly(
328+
rpcAccts.Accounts,
329+
)
330+
require.NoError(t, err)
331+
alice = lndHarness.NewNodeRemoteSigner(
332+
"WatchOnly", append([]string{
333+
"--remotesigner.enable",
334+
fmt.Sprintf(
335+
"--remotesigner.rpchost=localhost:%d",
336+
signer.Cfg.RPCPort,
337+
),
338+
fmt.Sprintf(
339+
"--remotesigner.tlscertpath=%s",
340+
signer.Cfg.TLSCertPath,
341+
),
342+
fmt.Sprintf(
343+
"--remotesigner.macaroonpath=%s",
344+
signer.Cfg.AdminMacPath,
345+
),
346+
}),
347+
[]byte("itestpassword"), &lnrpc.WatchOnly{
348+
MasterKeyBirthdayTimestamp: 0,
349+
MasterKeyFingerprint: nil,
350+
Accounts: watchOnlyAccounts,
351+
},
352+
)
353+
354+
lndHarness.FundNumCoins(alice, 5)
355+
} else {
356+
alice = lndHarness.NewNodeWithCoins("Alice", nil)
357+
}
307358

308359
// Create a tapd that uses Alice and connect it to the universe server.
309360
tapdHarness := setupTapdHarness(

make/testing_flags.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ ifneq ($(nodelete),)
6262
ITEST_FLAGS += -nodelete
6363
endif
6464

65+
# Run the lnd node in remote signing mode.
66+
ifneq ($(remote-signing),)
67+
ITEST_FLAGS += -lndremotesigner
68+
endif
69+
6570
# Run the optional tests.
6671
ifneq ($(optional),)
6772
ITEST_FLAGS += -optional -postgrestimeout=240m

0 commit comments

Comments
 (0)