pyln: Allow non-empty directory when creating node in node_factory

So far we've always cleared the node directory when provisioning the node, but
while testing some plugins we noticed that pre-generating some files in that
directory is useful. This just adds yet another flag to `get_node` that
disables deleting any existing node directory.
This commit is contained in:
Christian Decker 2020-04-06 11:41:46 +02:00 committed by Rusty Russell
parent b68066e8e8
commit 3b09662768
1 changed files with 3 additions and 2 deletions

View File

@ -1011,7 +1011,8 @@ class NodeFactory(object):
def get_node(self, node_id=None, options=None, dbfile=None,
feerates=(15000, 11000, 7500, 3750), start=True,
wait_for_bitcoind_sync=True, expect_fail=False, **kwargs):
wait_for_bitcoind_sync=True, expect_fail=False,
cleandir=True, **kwargs):
node_id = self.get_node_id() if not node_id else node_id
port = self.get_next_port()
@ -1019,7 +1020,7 @@ class NodeFactory(object):
lightning_dir = os.path.join(
self.directory, "lightning-{}/".format(node_id))
if os.path.exists(lightning_dir):
if cleandir and os.path.exists(lightning_dir):
shutil.rmtree(lightning_dir)
# Get the DB backend DSN we should be using for this test and this