Ensure that registering options works. First attempts without the plugin and then with the plugin. Then a plugin tries to register the same option "name" again, fails startup.
(node_factory, directory)
| 51 | |
| 52 | |
| 53 | def test_option_passthrough(node_factory, directory): |
| 54 | """ Ensure that registering options works. |
| 55 | |
| 56 | First attempts without the plugin and then with the plugin. |
| 57 | Then a plugin tries to register the same option "name" again, fails startup. |
| 58 | """ |
| 59 | plugin_path = os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py') |
| 60 | plugin_path2 = os.path.join(os.getcwd(), 'tests/plugins/options.py') |
| 61 | |
| 62 | help_out = subprocess.check_output([ |
| 63 | 'lightningd/lightningd', |
| 64 | '--lightning-dir={}'.format(directory), |
| 65 | '--help' |
| 66 | ]).decode('utf-8') |
| 67 | assert('--greeting' not in help_out) |
| 68 | |
| 69 | help_out = subprocess.check_output([ |
| 70 | 'lightningd/lightningd', |
| 71 | '--lightning-dir={}'.format(directory), |
| 72 | '--plugin={}'.format(plugin_path), |
| 73 | '--help' |
| 74 | ]).decode('utf-8') |
| 75 | assert('--greeting' in help_out) |
| 76 | |
| 77 | # Now try to see if it gets accepted, would fail to start if the |
| 78 | # option didn't exist |
| 79 | n = node_factory.get_node(options={'plugin': plugin_path, 'greeting': 'Ciao'}) |
| 80 | n.stop() |
| 81 | |
| 82 | with pytest.raises(subprocess.CalledProcessError): |
| 83 | err_out = subprocess.run([ |
| 84 | 'lightningd/lightningd', |
| 85 | '--lightning-dir={}'.format(directory), |
| 86 | '--plugin={}'.format(plugin_path), |
| 87 | '--plugin={}'.format(plugin_path2), |
| 88 | '--help' |
| 89 | ], capture_output=True, check=True).stderr.decode('utf-8') |
| 90 | |
| 91 | # first come first serve |
| 92 | assert("error starting plugin '{}': option name 'greeting' is already taken".format(plugin_path2) in err_out) |
| 93 | |
| 94 | |
| 95 | def test_option_types(node_factory): |