mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
pytest: test plugin does not register same option "name"
This commit is contained in:
committed by
neil saitug
parent
2fddfe3ffc
commit
7115611249
@@ -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('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('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()
|
plugin.run()
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ def test_option_passthrough(node_factory, directory):
|
|||||||
""" Ensure that registering options works.
|
""" Ensure that registering options works.
|
||||||
|
|
||||||
First attempts without the plugin and then with the plugin.
|
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_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([
|
help_out = subprocess.check_output([
|
||||||
'lightningd/lightningd',
|
'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 = node_factory.get_node(options={'plugin': plugin_path, 'greeting': 'Ciao'})
|
||||||
n.stop()
|
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):
|
def test_option_types(node_factory):
|
||||||
"""Ensure that desired types of options are
|
"""Ensure that desired types of options are
|
||||||
|
|||||||
Reference in New Issue
Block a user