mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-17 23:30:02 +02:00
lntest: allow node restore by extended root key
To allow testing restoring a node from an extended master root key, we add an extra argument to the RestoreNodeWithSeed function.
This commit is contained in:
parent
bbd5980d42
commit
3fd944e7e4
@ -426,7 +426,7 @@ func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string,
|
|||||||
// will finish initializing the LightningClient such that the HarnessNode can
|
// will finish initializing the LightningClient such that the HarnessNode can
|
||||||
// be used for regular rpc operations.
|
// be used for regular rpc operations.
|
||||||
func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
||||||
password []byte, mnemonic []string, recoveryWindow int32,
|
password []byte, mnemonic []string, rootKey string, recoveryWindow int32,
|
||||||
chanBackups *lnrpc.ChanBackupSnapshot,
|
chanBackups *lnrpc.ChanBackupSnapshot,
|
||||||
opts ...NodeOption) (*HarnessNode, error) {
|
opts ...NodeOption) (*HarnessNode, error) {
|
||||||
|
|
||||||
@ -441,6 +441,7 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string,
|
|||||||
WalletPassword: password,
|
WalletPassword: password,
|
||||||
CipherSeedMnemonic: mnemonic,
|
CipherSeedMnemonic: mnemonic,
|
||||||
AezeedPassphrase: password,
|
AezeedPassphrase: password,
|
||||||
|
ExtendedMasterKey: rootKey,
|
||||||
RecoveryWindow: recoveryWindow,
|
RecoveryWindow: recoveryWindow,
|
||||||
ChannelBackups: chanBackups,
|
ChannelBackups: chanBackups,
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// obtained above.
|
// obtained above.
|
||||||
return func() (*lntest.HarnessNode, error) {
|
return func() (*lntest.HarnessNode, error) {
|
||||||
return net.RestoreNodeWithSeed(
|
return net.RestoreNodeWithSeed(
|
||||||
"dave", nil, password,
|
"dave", nil, password, mnemonic,
|
||||||
mnemonic, 1000, backupSnapshot,
|
"", 1000, backupSnapshot,
|
||||||
copyPorts(oldNode),
|
copyPorts(oldNode),
|
||||||
)
|
)
|
||||||
}, nil
|
}, nil
|
||||||
@ -159,8 +159,8 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// restart it again using Unlock.
|
// restart it again using Unlock.
|
||||||
return func() (*lntest.HarnessNode, error) {
|
return func() (*lntest.HarnessNode, error) {
|
||||||
newNode, err := net.RestoreNodeWithSeed(
|
newNode, err := net.RestoreNodeWithSeed(
|
||||||
"dave", nil, password,
|
"dave", nil, password, mnemonic,
|
||||||
mnemonic, 1000, nil,
|
"", 1000, nil,
|
||||||
copyPorts(oldNode),
|
copyPorts(oldNode),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -208,7 +208,8 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
return func() (*lntest.HarnessNode, error) {
|
return func() (*lntest.HarnessNode, error) {
|
||||||
newNode, err := net.RestoreNodeWithSeed(
|
newNode, err := net.RestoreNodeWithSeed(
|
||||||
"dave", nil, password, mnemonic,
|
"dave", nil, password, mnemonic,
|
||||||
1000, nil, copyPorts(oldNode),
|
"", 1000, nil,
|
||||||
|
copyPorts(oldNode),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to "+
|
return nil, fmt.Errorf("unable to "+
|
||||||
@ -1322,7 +1323,7 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness, password []byte,
|
|||||||
|
|
||||||
return func() (*lntest.HarnessNode, error) {
|
return func() (*lntest.HarnessNode, error) {
|
||||||
newNode, err := net.RestoreNodeWithSeed(
|
newNode, err := net.RestoreNodeWithSeed(
|
||||||
"dave", nil, password, mnemonic, 1000, nil,
|
"dave", nil, password, mnemonic, "", 1000, nil,
|
||||||
copyPorts(oldNode),
|
copyPorts(oldNode),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -34,7 +34,8 @@ func testGetRecoveryInfo(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Restore Carol, passing in the password, mnemonic, and
|
// Restore Carol, passing in the password, mnemonic, and
|
||||||
// desired recovery window.
|
// desired recovery window.
|
||||||
node, err := net.RestoreNodeWithSeed(
|
node, err := net.RestoreNodeWithSeed(
|
||||||
"Carol", nil, password, mnemonic, recoveryWindow, nil,
|
"Carol", nil, password, mnemonic, "", recoveryWindow,
|
||||||
|
nil,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to restore node: %v", err)
|
t.Fatalf("unable to restore node: %v", err)
|
||||||
@ -130,6 +131,11 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
}
|
}
|
||||||
shutdownAndAssert(net, t, carol)
|
shutdownAndAssert(net, t, carol)
|
||||||
|
|
||||||
|
// As long as the mnemonic is non-nil and the extended key is empty, the
|
||||||
|
// closure below will always restore the node from the seed. The tests
|
||||||
|
// need to manually overwrite this value to change that behavior.
|
||||||
|
rootKey := ""
|
||||||
|
|
||||||
// Create a closure for testing the recovery of Carol's wallet. This
|
// Create a closure for testing the recovery of Carol's wallet. This
|
||||||
// method takes the expected value of Carol's balance when using the
|
// method takes the expected value of Carol's balance when using the
|
||||||
// given recovery window. Additionally, the caller can specify an action
|
// given recovery window. Additionally, the caller can specify an action
|
||||||
@ -140,7 +146,8 @@ func testOnchainFundRecovery(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Restore Carol, passing in the password, mnemonic, and
|
// Restore Carol, passing in the password, mnemonic, and
|
||||||
// desired recovery window.
|
// desired recovery window.
|
||||||
node, err := net.RestoreNodeWithSeed(
|
node, err := net.RestoreNodeWithSeed(
|
||||||
"Carol", nil, password, mnemonic, recoveryWindow, nil,
|
"Carol", nil, password, mnemonic, rootKey,
|
||||||
|
recoveryWindow, nil,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to restore node: %v", err)
|
t.Fatalf("unable to restore node: %v", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user