MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_plugin_shutdown

Function test_plugin_shutdown

tests/test_plugin.py:3149–3177  ·  view source on GitHub ↗

test 'shutdown' notifications, via `plugin stop` or via `stop`

(node_factory)

Source from the content-addressed store, hash-verified

3147
3148
3149def test_plugin_shutdown(node_factory):
3150 """test 'shutdown' notifications, via `plugin stop` or via `stop`"""
3151
3152 p = os.path.join(os.getcwd(), "tests/plugins/test_libplugin")
3153 p2 = os.path.join(os.getcwd(), 'tests/plugins/misc_notifications.py')
3154 l1 = node_factory.get_node(options={'plugin': [p, p2]})
3155
3156 l1.rpc.plugin_stop(p)
3157 l1.daemon.wait_for_log(r"test_libplugin: shutdown called")
3158 # FIXME: clean this up!
3159 l1.daemon.wait_for_log(r"test_libplugin: Killing plugin: exited during normal operation")
3160
3161 # Via `plugin stop` it can make RPC calls before it (self-)terminates
3162 l1.rpc.plugin_stop(p2)
3163 l1.daemon.wait_for_log(r'misc_notifications.py: via plugin stop, datastore success')
3164 l1.rpc.plugin_start(p2)
3165
3166 # Now try timeout via `plugin stop`
3167 l1.rpc.plugin_start(p, dont_shutdown=True)
3168 l1.rpc.plugin_stop(p)
3169 l1.daemon.wait_for_log(r"test_libplugin: shutdown called")
3170 l1.daemon.wait_for_log(r"test_libplugin: Timeout on shutdown: killing anyway")
3171
3172 # Now, should also shutdown or timeout on finish, RPC calls then fail with error code -5
3173 l1.rpc.plugin_start(p, dont_shutdown=True)
3174 l1.rpc.stop()
3175 l1.daemon.wait_for_logs(['test_libplugin: shutdown called',
3176 'misc_notifications.py: .* Connection refused',
3177 'test_libplugin: failed to self-terminate in time, killing.'])
3178
3179
3180def test_commando(node_factory, executor):

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
plugin_stopMethod · 0.80
wait_for_logMethod · 0.80
plugin_startMethod · 0.80
wait_for_logsMethod · 0.80
get_nodeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected