diff --git a/lntest/harness.go b/lntest/harness.go index 91aa88b0..417169dd 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -60,6 +60,10 @@ type NetworkHarness struct { Alice *HarnessNode Bob *HarnessNode + // useEtcd is set to true if new nodes are to be created with an + // embedded etcd backend instead of just bbolt. + useEtcd bool + // Channel for transmitting stderr output from failed lightning node // to main process. lndErrorChan chan error @@ -77,8 +81,8 @@ type NetworkHarness struct { // TODO(roasbeef): add option to use golang's build library to a binary of the // current repo. This will save developers from having to manually `go install` // within the repo each time before changes -func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string) ( - *NetworkHarness, error) { +func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string, + useEtcd bool) (*NetworkHarness, error) { feeService := startFeeService() @@ -92,6 +96,7 @@ func NewNetworkHarness(r *rpctest.Harness, b BackendConfig, lndBinary string) ( feeService: feeService, quit: make(chan struct{}), lndBinary: lndBinary, + useEtcd: useEtcd, } return &n, nil } @@ -376,6 +381,7 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool, NetParams: n.netParams, ExtraArgs: extraArgs, FeeURL: n.feeService.url, + Etcd: n.useEtcd, }) if err != nil { return nil, err diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index 93afb8be..1f1360bb 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -81,6 +81,9 @@ var ( "runtranche", defaultRunTranche, "run the tranche of the "+ "split test cases with the given (0-based) index", ) + + // useEtcd test LND nodes use (embedded) etcd as remote db. + useEtcd = flag.Bool("etcd", false, "Use etcd backend for lnd.") ) // getTestCaseSplitTranche returns the sub slice of the test cases that should @@ -14250,7 +14253,9 @@ func TestLightningNetworkDaemon(t *testing.T) { // Now we can set up our test harness (LND instance), with the chain // backend we just created. binary := ht.getLndBinary() - lndHarness, err = lntest.NewNetworkHarness(miner, chainBackend, binary) + lndHarness, err = lntest.NewNetworkHarness( + miner, chainBackend, binary, *useEtcd, + ) if err != nil { ht.Fatalf("unable to create lightning network harness: %v", err) } diff --git a/lntest/node.go b/lntest/node.go index a437adb4..ae3ebfc0 100644 --- a/lntest/node.go +++ b/lntest/node.go @@ -183,6 +183,8 @@ type NodeConfig struct { AcceptKeySend bool FeeURL string + + Etcd bool } func (cfg NodeConfig) P2PAddr() string { @@ -261,6 +263,11 @@ func (cfg NodeConfig) genArgs() []string { args = append(args, "--accept-keysend") } + if cfg.Etcd { + args = append(args, "--db.backend=etcd") + args = append(args, "--db.etcd.embedded") + } + if cfg.FeeURL != "" { args = append(args, "--feeurl="+cfg.FeeURL) }