mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
tests: Added test_recover to test --recover flag.
This commit is contained in:
parent
581677691d
commit
82c11529ab
1 changed files with 39 additions and 0 deletions
|
@ -1344,6 +1344,45 @@ def test_funding_reorg_remote_lags(node_factory, bitcoind):
|
|||
l2.daemon.wait_for_log(r'Deleting channel')
|
||||
|
||||
|
||||
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "deletes database, which is assumed sqlite3")
|
||||
def test_recover(node_factory, bitcoind):
|
||||
"""Test the recover option
|
||||
"""
|
||||
# Start the node with --recovery with valid codex32 secret
|
||||
l1 = node_factory.get_node(start=False,
|
||||
options={"recover": "ms10leetsllhdmn9m42vcsamx24zrxgs3qrl7ahwvhw4fnzrhve25gvezzyqqtum9pgv99ycma"})
|
||||
|
||||
os.unlink(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "hsm_secret"))
|
||||
l1.daemon.start()
|
||||
|
||||
basedir = l1.daemon.opts.get("lightning-dir")
|
||||
with open(os.path.join(basedir, TEST_NETWORK, 'hsm_secret'), 'rb') as f:
|
||||
buff = f.read()
|
||||
|
||||
# Check the node secret
|
||||
assert buff.hex() == "ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221100"
|
||||
l1.stop()
|
||||
|
||||
os.unlink(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3"))
|
||||
|
||||
# Node should throw error to recover flag if HSM already exists.
|
||||
l1.daemon.opts['recover'] = "ms10leetsllhdmn9m42vcsamx24zrxgs3qrl7ahwvhw4fnzrhve25gvezzyqqtum9pgv99ycma"
|
||||
l1.daemon.start(wait_for_initialized=False, stderr_redir=True)
|
||||
# Will exit with failure code.
|
||||
assert l1.daemon.wait() == 1
|
||||
assert l1.daemon.is_in_stderr(r"hsm_secret already exists!")
|
||||
|
||||
os.unlink(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "hsm_secret"))
|
||||
|
||||
l1.daemon.opts.update({"recover": "MS12NAMES6XQGUZTTXKEQNJSJZV4JV3NZ5K3KWGSPHUH6EVW"})
|
||||
l1.daemon.start(wait_for_initialized=False, stderr_redir=True)
|
||||
assert l1.daemon.wait() == 1
|
||||
assert l1.daemon.is_in_stderr(r"Expected 32 Byte secret: d1808e096b35b209ca12132b264662a5")
|
||||
|
||||
l1.daemon.opts.pop("recover")
|
||||
l1.start()
|
||||
|
||||
|
||||
def test_rescan(node_factory, bitcoind):
|
||||
"""Test the rescan option
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue