MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_db_sanity_checks

Function test_db_sanity_checks

tests/test_db.py:463–485  ·  view source on GitHub ↗
(bitcoind, node_factory)

Source from the content-addressed store, hash-verified

461
462@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Don't know how to swap dbs in Postgres")
463def test_db_sanity_checks(bitcoind, node_factory):
464 l1, l2 = node_factory.get_nodes(2, opts=[{'may_fail': True, 'broken_log': 'Wallet node_id does not match HSM|Wallet blockchain hash does not match network blockchain hash'}, {}])
465
466 l1.stop()
467 l2.stop()
468
469 # Provide the --wallet option and start with wrong db
470 l1.daemon.opts['wallet'] = "sqlite3://" + l2.db.path
471 l1.daemon.start(wait_for_initialized=False, stderr_redir=True)
472 l1.daemon.wait_for_log(r'\*\*BROKEN\*\* wallet: Wallet node_id does not match HSM')
473 # Will have exited with non-zero status.
474 assert l1.daemon.proc.wait(TIMEOUT) != 0
475 assert l1.daemon.is_in_stderr('Wallet sanity check failed')
476
477 # Now try wrong network,
478 l1.daemon.opts['wallet'] = "sqlite3://" + l1.db.path
479 l1.daemon.opts['network'] = "bitcoin"
480
481 l1.daemon.start(wait_for_initialized=False, stderr_redir=True)
482 l1.daemon.wait_for_log(r'\*\*BROKEN\*\* wallet: Wallet blockchain hash does not match network blockchain hash')
483 # Will have exited with non-zero status.
484 assert l1.daemon.proc.wait(TIMEOUT) != 0
485 assert l1.daemon.is_in_stderr('Wallet sanity check failed')
486
487
488@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Canned db used")

Callers

nothing calls this directly

Calls 6

get_nodesMethod · 0.80
wait_for_logMethod · 0.80
is_in_stderrMethod · 0.80
stopMethod · 0.45
startMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected