From e2f9a410f4191776d82d5b561a40bd6c6c78359a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 5 Aug 2019 19:07:45 +0200 Subject: [PATCH] pytest: Run plugin --help tests in the test directory This is a followup to #2892. Since we now attempt to lock the PID file before starting plugins we need to make sure that we actually use a unique lightning directory for anything that attempts to call `--help`. If not we may be conflicting with a `lightningd` that is running against that directory. Notice that this still means that we will be unable to call `--help` on `lightningd` if we have a running instance, but isolation in this case is good, otherwise we'd be reading the default config anyway. Signed-off-by: Christian Decker --- tests/test_plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 213e9f29a..27f5862f5 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -14,7 +14,7 @@ import time import unittest -def test_option_passthrough(node_factory): +def test_option_passthrough(node_factory, directory): """ Ensure that registering options works. First attempts without the plugin and then with the plugin. @@ -23,12 +23,14 @@ def test_option_passthrough(node_factory): help_out = subprocess.check_output([ 'lightningd/lightningd', + '--lightning-dir={}'.format(directory), '--help' ]).decode('utf-8') assert('--greeting' not in help_out) help_out = subprocess.check_output([ 'lightningd/lightningd', + '--lightning-dir={}'.format(directory), '--plugin={}'.format(plugin_path), '--help' ]).decode('utf-8') @@ -205,7 +207,7 @@ def test_plugin_connect_notifications(node_factory): l2.daemon.wait_for_log(r'Received disconnect event') -def test_failing_plugins(): +def test_failing_plugins(directory): fail_plugins = [ os.path.join(os.getcwd(), 'contrib/plugins/fail/failtimeout.py'), os.path.join(os.getcwd(), 'contrib/plugins/fail/doesnotexist.py'), @@ -215,6 +217,7 @@ def test_failing_plugins(): with pytest.raises(subprocess.CalledProcessError): subprocess.check_output([ 'lightningd/lightningd', + '--lightning-dir={}'.format(directory), '--plugin={}'.format(p), '--help', ])