itest: add etcd flag to control if new lnd nodes should run on etcd

This commit is contained in:
Andras Banki-Horvath 2020-06-22 19:36:12 +02:00
parent 511e817624
commit 98342433ab
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8
3 changed files with 21 additions and 3 deletions

@ -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

@ -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)
}

@ -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)
}