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

Function test_real_data_maxhops

tests/test_askrene.py:2920–3057  ·  view source on GitHub ↗

maxhops on real gossip: every route respects it, a non-binding limit changes nothing, and squeezing it trades fees for shorter paths.

(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

2918
2919@pytest.mark.slow_test
2920def test_real_data_maxhops(node_factory, bitcoind, executor):
2921 """maxhops on real gossip: every route respects it, a non-binding limit
2922 changes nothing, and squeezing it trades fees for shorter paths."""
2923 # Same setup as test_real_data: route from Rusty's node (2134) to the
2924 # top nodes of tests/data/gossip-store-2026-02-03.
2925 outfile = tempfile.NamedTemporaryFile(prefix="gossip-store-")
2926 nodeids = (
2927 subprocess.check_output(
2928 [
2929 "devtools/gossmap-compress",
2930 "decompress",
2931 "--node-map=2134=033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a",
2932 "tests/data/gossip-store-2026-02-03.compressed",
2933 outfile.name,
2934 ]
2935 )
2936 .decode("utf-8")
2937 .splitlines()
2938 )
2939
2940 AMOUNT = 100000000
2941 # 0.5% is the norm
2942 MAX_FEE = AMOUNT // 200
2943
2944 l1, l2 = node_factory.line_graph(
2945 2,
2946 fundamount=AMOUNT,
2947 opts=[
2948 {
2949 "gossip_store_file": outfile.name,
2950 "allow_warning": True,
2951 "dev-throttle-gossip": None,
2952 "broken_log": "Throttling (incoming|outgoing) peer",
2953 "askrene-timeout": TIMEOUT,
2954 },
2955 {"allow_warning": True},
2956 ],
2957 )
2958
2959 # Per maxhops: (succeeded, failed, longest path, total fee, mean probability_ppm)
2960 if SLOW_MACHINE:
2961 limit = 25
2962 expected = {
2963 None: (24, 0, 6, 4663500, 982051),
2964 6: (24, 0, 6, 4663500, 982051),
2965 5: (24, 0, 5, 4520423, 978569),
2966 4: (24, 0, 4, 4489275, 978123),
2967 3: (17, 7, 3, 3313847, 988287),
2968 }
2969 else:
2970 limit = 100
2971 expected = {
2972 None: (95, 0, 6, 16558980, 985039),
2973 6: (95, 0, 6, 16558980, 985039),
2974 5: (95, 0, 5, 16415903, 984160),
2975 4: (94, 1, 4, 16310514, 984205),
2976 3: (57, 38, 3, 10180411, 982875),
2977 }

Callers

nothing calls this directly

Calls 6

getroutes_allFunction · 0.85
longestFunction · 0.85
summaryFunction · 0.85
line_graphMethod · 0.80
anyClass · 0.50
decodeMethod · 0.45

Tested by

no test coverage detected