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

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2018-01-24 15:47:35 +01:00 committed by Rusty Russell
parent 24ba5d6250
commit 45c935ddba

View file

@ -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)