This tests the db hook.
(node_factory, executor)
| 609 | |
| 610 | @unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Only sqlite3 implements the db_write_hook currently") |
| 611 | def test_db_hook(node_factory, executor): |
| 612 | """This tests the db hook.""" |
| 613 | dbfile = os.path.join(node_factory.directory, "dblog.sqlite3") |
| 614 | l1 = node_factory.get_node(options={**BWATCH_OPTS, |
| 615 | 'plugin': os.path.join(os.getcwd(), 'tests/plugins/dblog.py'), |
| 616 | 'dblog-file': dbfile}) |
| 617 | |
| 618 | # It should see the db being created, and sometime later actually get |
| 619 | # initted. |
| 620 | # This precedes startup, so needle already past |
| 621 | assert l1.daemon.is_in_log(r'plugin-dblog.py: deferring \d+ commands') |
| 622 | l1.daemon.logsearch_start = 0 |
| 623 | l1.daemon.wait_for_log('plugin-dblog.py: replaying pre-init data:') |
| 624 | l1.daemon.wait_for_log('plugin-dblog.py: CREATE TABLE version \\(version INTEGER\\)') |
| 625 | l1.daemon.wait_for_log("plugin-dblog.py: initialized.* 'startup': True") |
| 626 | |
| 627 | # bwatch's first block-history write is async; if we stop before it runs, |
| 628 | # the main DB can diverge from dblog's mirror (hook may not run in time). |
| 629 | wait_bwatch_caught_up(l1) |
| 630 | |
| 631 | l1.stop() |
| 632 | |
| 633 | # Databases should be identical. |
| 634 | db1 = sqlite3.connect(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'lightningd.sqlite3')) |
| 635 | db2 = sqlite3.connect(dbfile) |
| 636 | |
| 637 | assert [x for x in db1.iterdump()] == [x for x in db2.iterdump()] |
| 638 | |
| 639 | |
| 640 | @unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Only sqlite3 implements the db_write_hook currently") |
nothing calls this directly
no test coverage detected