mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
pytest: test plugin does not register same option "name"
This commit is contained in:
parent
2fddfe3ffc
commit
7115611249
2 changed files with 16 additions and 0 deletions
|
@ -22,4 +22,6 @@ plugin.add_flag_option('flag_opt', 'an example flag type option')
|
|||
plugin.add_option('str_optm', None, 'an example string option', multi=True)
|
||||
plugin.add_option('int_optm', 7, 'an example int type option', opt_type='int', multi=True)
|
||||
|
||||
plugin.add_option('greeting', 7, 'option _names_ should be unique', opt_type='int', multi=True)
|
||||
|
||||
plugin.run()
|
||||
|
|
|
@ -30,8 +30,10 @@ def test_option_passthrough(node_factory, directory):
|
|||
""" 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.
|
||||
"""
|
||||
plugin_path = os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')
|
||||
plugin_path2 = os.path.join(os.getcwd(), 'tests/plugins/options.py')
|
||||
|
||||
help_out = subprocess.check_output([
|
||||
'lightningd/lightningd',
|
||||
|
@ -53,6 +55,18 @@ def test_option_passthrough(node_factory, directory):
|
|||
n = node_factory.get_node(options={'plugin': plugin_path, 'greeting': 'Ciao'})
|
||||
n.stop()
|
||||
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
err_out = subprocess.run([
|
||||
'lightningd/lightningd',
|
||||
'--lightning-dir={}'.format(directory),
|
||||
'--plugin={}'.format(plugin_path),
|
||||
'--plugin={}'.format(plugin_path2),
|
||||
'--help'
|
||||
], capture_output=True, check=True).stderr.decode('utf-8')
|
||||
|
||||
# first come first serve
|
||||
assert("error starting plugin '{}': option name '--greeting' is already taken".format(plugin_path2) in err_out)
|
||||
|
||||
|
||||
def test_option_types(node_factory):
|
||||
"""Ensure that desired types of options are
|
||||
|
|
Loading…
Add table
Reference in a new issue