mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
pytest: add support for starting nodes with a pre-canned db.
With xz, the db is only 9120 bytes, vs 163840. And lzma is a builtin in Python 3. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3b587a1c6d
commit
7887e5c00a
1 changed files with 8 additions and 1 deletions
|
@ -7,6 +7,7 @@ from lightning import LightningRpc
|
|||
|
||||
import json
|
||||
import logging
|
||||
import lzma
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
|
@ -753,7 +754,8 @@ class NodeFactory(object):
|
|||
|
||||
def get_node(self, disconnect=None, options=None, may_fail=False,
|
||||
may_reconnect=False, random_hsm=False,
|
||||
feerates=(15000, 7500, 3750), start=True, log_all_io=False):
|
||||
feerates=(15000, 7500, 3750), start=True, log_all_io=False,
|
||||
dbfile=None):
|
||||
with self.lock:
|
||||
node_id = self.next_id
|
||||
self.next_id += 1
|
||||
|
@ -812,6 +814,11 @@ class NodeFactory(object):
|
|||
'--log-file={}/valgrind-errors.%p'.format(node.daemon.lightning_dir)
|
||||
]
|
||||
|
||||
if dbfile:
|
||||
out = open(os.path.join(node.daemon.lightning_dir, 'lightningd.sqlite3'), 'xb')
|
||||
with lzma.open(os.path.join('tests/data', dbfile), 'rb') as f:
|
||||
out.write(f.read())
|
||||
|
||||
if start:
|
||||
try:
|
||||
node.start()
|
||||
|
|
Loading…
Add table
Reference in a new issue