(node_factory)
| 2886 | |
| 2887 | |
| 2888 | def test_hook_dep(node_factory): |
| 2889 | dep_a = os.path.join(os.path.dirname(__file__), 'plugins/dep_a.py') |
| 2890 | dep_b = os.path.join(os.path.dirname(__file__), 'plugins/dep_b.py') |
| 2891 | dep_c = os.path.join(os.path.dirname(__file__), 'plugins/dep_c.py') |
| 2892 | l1, l2, l3 = node_factory.line_graph(3, opts=[{}, |
| 2893 | {'plugin': dep_b}, |
| 2894 | {'plugin': [dep_a, dep_b]}]) |
| 2895 | |
| 2896 | # l2 complains about the two unknown plugins, only. |
| 2897 | # (Could be already past) |
| 2898 | l2.daemon.logsearch_start = 0 |
| 2899 | l2.daemon.wait_for_logs(["unknown plugin dep_a.py", |
| 2900 | "unknown plugin dep_c.py"]) |
| 2901 | assert not l2.daemon.is_in_log("unknown plugin (?!dep_a.py|dep_c.py)") |
| 2902 | logstart = l2.daemon.logsearch_start |
| 2903 | |
| 2904 | # l3 complains about the dep_c, only. |
| 2905 | assert l3.daemon.is_in_log("unknown plugin dep_c.py") |
| 2906 | assert not l3.daemon.is_in_log("unknown plugin (?!dep_c.py)") |
| 2907 | |
| 2908 | # A says it has to be before B. |
| 2909 | l2.rpc.plugin_start(plugin=dep_a) |
| 2910 | l2.daemon.wait_for_log(r"started.*dep_a.py") |
| 2911 | # Still doesn't know about c. |
| 2912 | assert l2.daemon.is_in_log("unknown plugin dep_c.py", logstart) |
| 2913 | |
| 2914 | l1.pay(l2, 100000) |
| 2915 | # They must be called in this order! |
| 2916 | l2.daemon.wait_for_log(r"dep_a.py: htlc_accepted called") |
| 2917 | l2.daemon.wait_for_log(r"dep_b.py: htlc_accepted called") |
| 2918 | |
| 2919 | # But depc will not load, due to cyclical dep |
| 2920 | with pytest.raises(RpcError, match=r'Cannot meet required hook dependencies'): |
| 2921 | l2.rpc.plugin_start(plugin=dep_c) |
| 2922 | |
| 2923 | l1.rpc.plugin_start(plugin=dep_c) |
| 2924 | l1.daemon.wait_for_log(r"started.*dep_c.py") |
| 2925 | |
| 2926 | # Complaints about unknown plugin a, but nothing else |
| 2927 | assert l1.daemon.is_in_log("unknown plugin dep_a.py") |
| 2928 | assert not l1.daemon.is_in_log("unknown plugin (?!dep_a.py)") |
| 2929 | |
| 2930 | |
| 2931 | def test_hook_dep_stable(node_factory): |
nothing calls this directly
no test coverage detected