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

Function test_sqlite3_builtin_backup

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

Source from the content-addressed store, hash-verified

428
429@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Tests a feature unique to SQLITE3 backend")
430def test_sqlite3_builtin_backup(bitcoind, node_factory):
431 l1 = node_factory.get_node(start=False)
432
433 # Figure out the path to the actual db.
434 main_db_file = l1.db.path
435 # Create a backup copy in the same location with the suffix .bak
436 backup_db_file = main_db_file + ".bak"
437
438 # Provide the --wallet option and start.
439 l1.daemon.opts['wallet'] = "sqlite3://" + main_db_file + ':' + backup_db_file
440 l1.start()
441
442 # Get an address and put some funds.
443 addr = l1.rpc.newaddr('bech32')['bech32']
444 bitcoind.rpc.sendtoaddress(addr, 1)
445 bitcoind.generate_block(1)
446 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
447
448 # Stop the node.
449 l1.stop()
450
451 # Copy the backup over the main db file.
452 shutil.copyfile(backup_db_file, main_db_file)
453
454 # Remove the --wallet option and start.
455 del l1.daemon.opts['wallet']
456 l1.start()
457
458 # Should still see the funds.
459 assert(len(l1.rpc.listfunds()['outputs']) == 1)
460
461
462@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "Don't know how to swap dbs in Postgres")

Callers

nothing calls this directly

Calls 7

wait_forFunction · 0.90
generate_blockMethod · 0.80
get_nodeMethod · 0.45
startMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected