If a hook is in use when we add a plugin to it, we have to defer
(node_factory)
| 2967 | |
| 2968 | @pytest.mark.slow_test # VALGRIND running generally too slow to trigger race we need. |
| 2969 | def test_hook_in_use(node_factory): |
| 2970 | """If a hook is in use when we add a plugin to it, we have to defer""" |
| 2971 | dep_a = os.path.join(os.path.dirname(__file__), 'plugins/dep_a.py') |
| 2972 | dep_b = os.path.join(os.path.dirname(__file__), 'plugins/dep_b.py') |
| 2973 | |
| 2974 | l1, l2 = node_factory.line_graph(2, opts=[{}, {'plugin': [dep_a]}]) |
| 2975 | |
| 2976 | NUM_ITERATIONS = 10 |
| 2977 | |
| 2978 | invs = [l2.rpc.invoice(1, f'test_hook_in_use{i}', 'test_hook_in_use') for i in range(NUM_ITERATIONS)] |
| 2979 | |
| 2980 | route = [{'amount_msat': 1, |
| 2981 | 'id': l2.info['id'], |
| 2982 | 'delay': 20, |
| 2983 | 'channel': l1.get_channel_scid(l2)}] |
| 2984 | |
| 2985 | for i in range(NUM_ITERATIONS): |
| 2986 | l1.rpc.sendpay(route, |
| 2987 | amount_msat=1, |
| 2988 | payment_hash=invs[i]['payment_hash'], |
| 2989 | payment_secret=invs[i]['payment_secret']) |
| 2990 | if i % 2 == 1: |
| 2991 | l1.rpc.waitsendpay(payment_hash=invs[i - 1]['payment_hash']) |
| 2992 | l1.rpc.waitsendpay(payment_hash=invs[i]['payment_hash']) |
| 2993 | else: |
| 2994 | l2.rpc.plugin_start(plugin=dep_b) |
| 2995 | l2.rpc.plugin_stop(plugin=dep_b) |
| 2996 | |
| 2997 | # We should have deferred hook update at least once! |
| 2998 | l2.daemon.wait_for_log("UNUSUAL plugin-dep_b.py: Deferring registration of hook htlc_accepted until it's not in use.") |
| 2999 | l2.daemon.wait_for_log("UNUSUAL lightningd: Updating hooks for htlc_accepted now usage is done.") |
| 3000 | |
| 3001 | |
| 3002 | def test_htlc_accepted_hook_fwdto(node_factory): |
nothing calls this directly
no test coverage detected