Start a minimal plugin and ensure it is well-behaved
(node_factory)
| 40 | |
| 41 | |
| 42 | def test_plugin_start(node_factory): |
| 43 | """Start a minimal plugin and ensure it is well-behaved |
| 44 | """ |
| 45 | bin_path = Path.cwd() / "target" / RUST_PROFILE / "examples" / "cln-plugin-startup" |
| 46 | l1, l2 = node_factory.get_nodes(2, opts=[ |
| 47 | {"plugin": str(bin_path), 'test-option': 31337}, {} |
| 48 | ]) |
| 49 | |
| 50 | # The plugin should be in the list of active plugins |
| 51 | plugins = l1.rpc.plugin('list')['plugins'] |
| 52 | assert len([p for p in plugins if 'cln-plugin-startup' in p['name'] and p['active']]) == 1 |
| 53 | |
| 54 | assert str(bin_path) in l1.rpc.listconfigs()['configs']['plugin']['values_str'] |
| 55 | |
| 56 | # Now check that the `testmethod was registered ok |
| 57 | assert l1.rpc.help("testmethod") == { |
| 58 | 'help': [ |
| 59 | { |
| 60 | 'command': 'testmethod ' |
| 61 | } |
| 62 | ], |
| 63 | 'format-hint': 'simple' |
| 64 | } |
| 65 | |
| 66 | assert l1.rpc.testmethod() == "Hello" |
| 67 | assert l1.rpc.test_custom_notification() == "Notification sent" |
| 68 | l1.daemon.wait_for_log(r'Received a test_custom_notification') |
| 69 | |
| 70 | l1.connect(l2) |
| 71 | l1.daemon.wait_for_log(r'Got a connect hook call') |
| 72 | l1.daemon.wait_for_log(r'Got a connect notification') |
| 73 | |
| 74 | l1.rpc.setconfig("test-dynamic-option", True) |
| 75 | assert l1.rpc.listconfigs("test-dynamic-option")["configs"]["test-dynamic-option"]["value_bool"] |
| 76 | wait_for(lambda: l1.daemon.is_in_log(r'cln-plugin-startup: Got dynamic option change: test-dynamic-option "true"')) |
| 77 | l1.rpc.setconfig("test-dynamic-option", False) |
| 78 | assert not l1.rpc.listconfigs("test-dynamic-option")["configs"]["test-dynamic-option"]["value_bool"] |
| 79 | wait_for(lambda: l1.daemon.is_in_log(r'cln-plugin-startup: Got dynamic option change: test-dynamic-option "false"')) |
| 80 | |
| 81 | |
| 82 | def test_plugin_options_handle_defaults(node_factory): |
nothing calls this directly
no test coverage detected