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

Function test_self_disable

tests/test_plugin.py:3058–3097  ·  view source on GitHub ↗

Test that plugin can disable itself without penalty.

(node_factory)

Source from the content-addressed store, hash-verified

3056
3057
3058def test_self_disable(node_factory):
3059 """Test that plugin can disable itself without penalty.
3060 """
3061 # This disables in response to getmanifest.
3062 p1 = os.path.join(
3063 os.path.dirname(__file__), 'plugins/test_selfdisable_after_getmanifest'
3064 )
3065 # This disables in response to init.
3066 p2 = os.path.join(os.getcwd(), "tests/plugins/test_libplugin")
3067
3068 pydisable = os.path.join(
3069 os.path.dirname(__file__), 'plugins/selfdisable.py'
3070 )
3071 l1 = node_factory.get_node(options={'important-plugin': [p1, p2],
3072 'plugin': pydisable,
3073 'selfdisable': None})
3074
3075 # Could happen before it gets set up.
3076 l1.daemon.logsearch_start = 0
3077 l1.daemon.wait_for_logs(['test_selfdisable_after_getmanifest: .* disabled itself: Self-disable test after getmanifest',
3078 'test_libplugin: .* disabled itself at init: Disabled via selfdisable option',
3079 'selfdisable.py: .* disabled itself at init: init saying disable'])
3080
3081 assert p1 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
3082 assert p2 not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
3083 assert pydisable not in [p['name'] for p in l1.rpc.plugin_list()['plugins']]
3084
3085 # Also works with dynamic load attempts
3086 with pytest.raises(RpcError, match="Self-disable test after getmanifest"):
3087 l1.rpc.plugin_start(p1)
3088
3089 # Also works with dynamic load attempts
3090 with pytest.raises(RpcError, match="Disabled via selfdisable option"):
3091 l1.rpc.plugin_start(p2, selfdisable=True)
3092
3093 with pytest.raises(RpcError, match="init saying disable"):
3094 l1.rpc.plugin_start(pydisable)
3095
3096 with pytest.raises(RpcError, match="init saying disable"):
3097 l1.rpc.plugin_start(pydisable, **{"dummy-option": True})
3098
3099
3100def test_restart_on_update(node_factory):

Callers

nothing calls this directly

Calls 5

joinMethod · 0.80
wait_for_logsMethod · 0.80
plugin_listMethod · 0.80
plugin_startMethod · 0.80
get_nodeMethod · 0.45

Tested by

no test coverage detected