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

Function test_plugin_hook

tests/test_plugin.py:400–417  ·  view source on GitHub ↗

The helloworld plugin registers a htlc_accepted hook. The hook will sleep for a few seconds and log a message. `lightningd` should wait for the response and only then complete the payment.

(node_factory, executor)

Source from the content-addressed store, hash-verified

398
399
400def test_plugin_hook(node_factory, executor):
401 """The helloworld plugin registers a htlc_accepted hook.
402
403 The hook will sleep for a few seconds and log a
404 message. `lightningd` should wait for the response and only then
405 complete the payment.
406
407 """
408 l1, l2 = node_factory.line_graph(2, opts={'plugin': os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')})
409 start_time = time.time()
410 f = executor.submit(l1.pay, l2, 100000)
411 l2.daemon.wait_for_log(r'on_htlc_accepted called')
412
413 # The hook will sleep for 20 seconds before answering, so `f`
414 # should take at least that long.
415 f.result()
416 end_time = time.time()
417 assert(end_time >= start_time + 20)
418
419
420def test_plugin_connect_notifications(node_factory):

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
joinMethod · 0.80
wait_for_logMethod · 0.80

Tested by

no test coverage detected