lntest: add new ChanBackupPath method to expose channels.backup for node

This commit is contained in:
Olaoluwa Osuntokun 2019-03-10 16:32:59 -07:00
parent b419179c86
commit d9c9d6ed73
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

@ -25,6 +25,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chanbackup"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/macaroons" "github.com/lightningnetwork/lnd/macaroons"
) )
@ -142,6 +143,16 @@ func (cfg nodeConfig) DBPath() string {
fmt.Sprintf("%v/channel.db", cfg.NetParams.Name)) fmt.Sprintf("%v/channel.db", cfg.NetParams.Name))
} }
func (cfg nodeConfig) ChanBackupPath() string {
return filepath.Join(
cfg.DataDir, "chain", "bitcoin",
fmt.Sprintf(
"%v/%v", cfg.NetParams.Name,
chanbackup.DefaultBackupFileName,
),
)
}
// genArgs generates a slice of command line arguments from the lightning node // genArgs generates a slice of command line arguments from the lightning node
// config struct. // config struct.
func (cfg nodeConfig) genArgs() []string { func (cfg nodeConfig) genArgs() []string {
@ -279,6 +290,12 @@ func (hn *HarnessNode) Name() string {
return hn.cfg.Name return hn.cfg.Name
} }
// ChanBackupPath returns the fielpath to the on-disk channels.backup file for
// this node.
func (hn *HarnessNode) ChanBackupPath() string {
return hn.cfg.ChanBackupPath()
}
// Start launches a new process running lnd. Additionally, the PID of the // Start launches a new process running lnd. Additionally, the PID of the
// launched process is saved in order to possibly kill the process forcibly // launched process is saved in order to possibly kill the process forcibly
// later. // later.