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

Function test_real_biases

tests/test_askrene.py:1687–1799  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

1685
1686@pytest.mark.slow_test
1687def test_real_biases(node_factory, bitcoind, executor):
1688 # Route from Rusty's node to the top 100.
1689 # From tests/data/gossip-store-2026-02-03-node-map.xz:
1690 # Me: 2134:024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605:BLUEIRON
1691 # So we make l2 node 2134.
1692 outfile = tempfile.NamedTemporaryFile(prefix='gossip-store-')
1693 nodeids = subprocess.check_output(['devtools/gossmap-compress',
1694 'decompress',
1695 '--node-map=2134=033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a',
1696 'tests/data/gossip-store-2026-02-03.compressed',
1697 outfile.name]).decode('utf-8').splitlines()
1698
1699 # This is in msat, but is also the size of channel we create.
1700 AMOUNT = 100000000
1701
1702 # l2 complains being given bad gossip from l1, throttle to reduce
1703 # the sheer amount of log noise.
1704 l1, l2 = node_factory.line_graph(2, fundamount=AMOUNT,
1705 opts=[{'gossip_store_file': outfile.name,
1706 'allow_warning': True,
1707 'broken_log': 'Throttling (incoming|outgoing) peer',
1708 'dev-throttle-gossip': None},
1709 {'allow_warning': True}])
1710
1711 # CI, it's slow.
1712 if SLOW_MACHINE:
1713 limit = 25
1714 expected = ({1: 5, 2: 6, 4: 13, 8: 16, 16: 22, 32: 24, 64: 24, 100: 24}, 0)
1715 else:
1716 limit = 100
1717 expected = ({1: 23, 2: 32, 4: 52, 8: 64, 16: 89, 32: 95, 64: 95, 100: 95}, 0)
1718
1719 l1.rpc.askrene_create_layer('biases')
1720 num_changed = {}
1721 bias_ineffective = 0
1722
1723 # 0.5% is the norm
1724 MAX_FEE = AMOUNT // 200
1725
1726 # To exercise parallelism, do bases all at once.
1727 futures = {}
1728 for n in range(0, limit):
1729 if n in canned_gossmap_badnodes:
1730 continue
1731 futures[n] = executor.submit(l1.rpc.getroutes,
1732 source=l1.info['id'],
1733 destination=nodeids[n],
1734 amount_msat=AMOUNT,
1735 layers=['auto.sourcefree', 'auto.localchans'],
1736 maxfee_msat=MAX_FEE,
1737 final_cltv=18)
1738
1739 base_routes = {}
1740 for n in range(0, limit):
1741 if n in canned_gossmap_badnodes:
1742 continue
1743 base_routes[n] = futures[n].result(TIMEOUT)
1744

Callers

nothing calls this directly

Calls 4

amount_through_chanFunction · 0.85
line_graphMethod · 0.80
getroutesMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected