mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +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 json
|
||||||
import logging
|
import logging
|
||||||
|
import lzma
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
@ -753,7 +754,8 @@ class NodeFactory(object):
|
||||||
|
|
||||||
def get_node(self, disconnect=None, options=None, may_fail=False,
|
def get_node(self, disconnect=None, options=None, may_fail=False,
|
||||||
may_reconnect=False, random_hsm=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:
|
with self.lock:
|
||||||
node_id = self.next_id
|
node_id = self.next_id
|
||||||
self.next_id += 1
|
self.next_id += 1
|
||||||
|
@ -812,6 +814,11 @@ class NodeFactory(object):
|
||||||
'--log-file={}/valgrind-errors.%p'.format(node.daemon.lightning_dir)
|
'--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:
|
if start:
|
||||||
try:
|
try:
|
||||||
node.start()
|
node.start()
|
||||||
|
|
Loading…
Add table
Reference in a new issue