From 897fabdccd2507d5970a64836b450bf356bb6597 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 10 Aug 2019 14:54:55 +0930 Subject: [PATCH] pytest: add test that htlc_accepted hook only gets called after init. We fail this. Signed-off-by: Rusty Russell --- tests/plugins/hold_htlcs.py | 5 +++++ tests/test_plugin.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/plugins/hold_htlcs.py b/tests/plugins/hold_htlcs.py index 0533b1b2a..cd8799343 100755 --- a/tests/plugins/hold_htlcs.py +++ b/tests/plugins/hold_htlcs.py @@ -34,4 +34,9 @@ def on_htlc_accepted(htlc, onion, plugin, **kwargs): return {'result': 'continue'} +@plugin.init() +def init(options, configuration, plugin): + plugin.log("hold_htlcs.py initializing") + + plugin.run() diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 4ab2fceb6..ddd430a12 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -466,6 +466,7 @@ def test_htlc_accepted_hook_resolve(node_factory): assert len(inv) == 1 and inv[0]['status'] == 'unpaid' +@pytest.mark.xfail(strict=True) def test_htlc_accepted_hook_direct_restart(node_factory, executor): """l2 restarts while it is pondering what to do with an HTLC. """ @@ -479,12 +480,19 @@ def test_htlc_accepted_hook_direct_restart(node_factory, executor): f1 = executor.submit(l1.rpc.pay, i1) l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') + needle = l2.daemon.logsearch_start l2.restart() + # Now it should try again, *after* initializing. + # This may be before "Server started with public key" swallowed by restart() + l2.daemon.logsearch_start = needle + 1 + l2.daemon.wait_for_log(r'hold_htlcs.py initializing') + l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') f1.result() @unittest.skipIf(not DEVELOPER, "without DEVELOPER=1, gossip v slow") +@pytest.mark.xfail(strict=True) def test_htlc_accepted_hook_forward_restart(node_factory, executor): """l2 restarts while it is pondering what to do with an HTLC. """ @@ -500,8 +508,15 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor): l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') + needle = l2.daemon.logsearch_start l2.restart() + # Now it should try again, *after* initializing. + # This may be before "Server started with public key" swallowed by restart() + l2.daemon.logsearch_start = needle + 1 + l2.daemon.wait_for_log(r'hold_htlcs.py initializing') + l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds') + # Grab the file where the plugin wrote the onion and read it in for some # additional checks logline = l2.daemon.wait_for_log(r'Onion written to')