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

Function test_plugin_disable

tests/test_plugin.py:336–397  ·  view source on GitHub ↗

--disable-plugin works

(node_factory)

Source from the content-addressed store, hash-verified

334
335
336def test_plugin_disable(node_factory):
337 """--disable-plugin works"""
338 plugin_dir = os.path.join(os.getcwd(), 'contrib/plugins')
339 # We used to need plugin-dir before disable-plugin!
340 n = node_factory.get_node(options=OrderedDict([('plugin-dir', plugin_dir),
341 ('disable-plugin',
342 '{}/helloworld.py'
343 .format(plugin_dir))]))
344 with pytest.raises(RpcError):
345 n.rpc.hello(name='Sun')
346 assert n.daemon.is_in_log('helloworld.py: disabled via disable-plugin')
347 n.stop()
348
349 # Also works by basename.
350 n = node_factory.get_node(options=OrderedDict([('plugin-dir', plugin_dir),
351 ('disable-plugin',
352 'helloworld.py')]))
353 with pytest.raises(RpcError):
354 n.rpc.hello(name='Sun')
355 assert n.daemon.is_in_log('helloworld.py: disabled via disable-plugin')
356 n.stop()
357
358 # Other order also works!
359 n = node_factory.get_node(options=OrderedDict([('disable-plugin',
360 'helloworld.py'),
361 ('plugin-dir', plugin_dir)]))
362 with pytest.raises(RpcError):
363 n.rpc.hello(name='Sun')
364 assert n.daemon.is_in_log('helloworld.py: disabled via disable-plugin')
365 n.stop()
366
367 # Both orders of explicit specification work.
368 n = node_factory.get_node(options=OrderedDict([('disable-plugin',
369 'helloworld.py'),
370 ('plugin',
371 '{}/helloworld.py'
372 .format(plugin_dir))]))
373 with pytest.raises(RpcError):
374 n.rpc.hello(name='Sun')
375 assert n.daemon.is_in_log('helloworld.py: disabled via disable-plugin')
376 n.stop()
377
378 # Both orders of explicit specification work.
379 n = node_factory.get_node(options=OrderedDict([('plugin',
380 '{}/helloworld.py'
381 .format(plugin_dir)),
382 ('disable-plugin',
383 'helloworld.py')]))
384 with pytest.raises(RpcError):
385 n.rpc.hello(name='Sun')
386 assert n.daemon.is_in_log('helloworld.py: disabled via disable-plugin')
387
388 # Still disabled if we load directory.
389 n.rpc.plugin_startdir(directory=os.path.join(os.getcwd(), "contrib/plugins"))
390 n.daemon.wait_for_log('helloworld.py: disabled via disable-plugin')
391 n.stop()
392
393 # Check that list works

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
is_in_logMethod · 0.80
plugin_startdirMethod · 0.80
wait_for_logMethod · 0.80
listconfigsMethod · 0.80
get_nodeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected