test that options from config file get remembered across plugin stop/start
(node_factory)
| 4532 | |
| 4533 | |
| 4534 | def test_plugin_persist_option(node_factory): |
| 4535 | """test that options from config file get remembered across plugin stop/start""" |
| 4536 | plugin_path = os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py') |
| 4537 | |
| 4538 | l1 = node_factory.get_node(options={"plugin": plugin_path, |
| 4539 | "greeting": "Static option"}) |
| 4540 | assert l1.rpc.call("hello") == "Static option world" |
| 4541 | c = l1.rpc.listconfigs('greeting')['configs']['greeting'] |
| 4542 | assert c['source'] == "cmdline" |
| 4543 | assert c['value_str'] == "Static option" |
| 4544 | assert c['plugin'] == plugin_path |
| 4545 | l1.rpc.plugin_stop(plugin_path) |
| 4546 | assert 'greeting' not in l1.rpc.listconfigs()['configs'] |
| 4547 | |
| 4548 | # Restart works |
| 4549 | l1.rpc.plugin_start(plugin_path) |
| 4550 | c = l1.rpc.listconfigs('greeting')['configs']['greeting'] |
| 4551 | assert c['source'] == "cmdline" |
| 4552 | assert c['value_str'] == "Static option" |
| 4553 | assert c['plugin'] == plugin_path |
| 4554 | assert l1.rpc.call("hello") == "Static option world" |
| 4555 | l1.rpc.plugin_stop(plugin_path) |
| 4556 | assert 'greeting' not in l1.rpc.listconfigs()['configs'] |
| 4557 | |
| 4558 | # This overrides! |
| 4559 | l1.rpc.plugin_start(plugin_path, greeting="Dynamic option") |
| 4560 | c = l1.rpc.listconfigs('greeting')['configs']['greeting'] |
| 4561 | assert c['source'] == "pluginstart" |
| 4562 | assert c['value_str'] == "Dynamic option" |
| 4563 | assert c['plugin'] == plugin_path |
| 4564 | assert l1.rpc.call("hello") == "Dynamic option world" |
| 4565 | l1.rpc.plugin_stop(plugin_path) |
| 4566 | assert 'greeting' not in l1.rpc.listconfigs()['configs'] |
| 4567 | |
| 4568 | # Now restored! |
| 4569 | l1.rpc.plugin_start(plugin_path) |
| 4570 | c = l1.rpc.listconfigs('greeting')['configs']['greeting'] |
| 4571 | assert c['source'] == "cmdline" |
| 4572 | assert c['value_str'] == "Static option" |
| 4573 | assert c['plugin'] == plugin_path |
| 4574 | assert l1.rpc.call("hello") == "Static option world" |
| 4575 | |
| 4576 | |
| 4577 | def test_all_subscription(node_factory, directory): |
nothing calls this directly
no test coverage detected