Browse Source

pytest: Have the db_query helper work on a copy of the DB

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
45c935ddba
  1. 7
      tests/utils.py

7
tests/utils.py

@ -338,7 +338,12 @@ class LightningNode(object):
return [c for c in self.rpc.listchannels()['channels'] if c['active']]
def db_query(self, query):
db = sqlite3.connect(os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3"))
from shutil import copyfile
orig = os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3")
copy = os.path.join(self.daemon.lightning_dir, "lightningd-copy.sqlite3")
copyfile(orig, copy)
db = sqlite3.connect(copy)
db.row_factory = sqlite3.Row
c = db.cursor()
c.execute(query)

Loading…
Cancel
Save