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

Function test_limits_fake_gossmap

tests/test_askrene.py:1377–1457  ·  view source on GitHub ↗

Like test_live_spendable, but using a generated gossmap not real nodes

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1375
1376
1377def test_limits_fake_gossmap(node_factory, bitcoind):
1378 """Like test_live_spendable, but using a generated gossmap not real nodes"""
1379 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=100_000),
1380 GenChannel(0, 1, capacity_sats=100_000),
1381 GenChannel(0, 1, capacity_sats=200_000),
1382 GenChannel(0, 1, capacity_sats=300_000),
1383 GenChannel(0, 1, capacity_sats=400_000),
1384 GenChannel(1, 2, capacity_sats=100_000),
1385 GenChannel(1, 2, capacity_sats=100_000),
1386 GenChannel(1, 2, capacity_sats=200_000),
1387 GenChannel(1, 2, capacity_sats=300_000),
1388 GenChannel(1, 2, capacity_sats=400_000)])
1389 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1390
1391 # Create a layer like auto.localchans would from "spendable"
1392 dir01 = direction(nodemap[0], nodemap[1])
1393 spendable = {f'0x1x0/{dir01}': 87718000,
1394 f'1x1x1/{dir01}': 87718000,
1395 f'2x1x2/{dir01}': 186718000,
1396 f'3x1x3/{dir01}': 285718000,
1397 f'4x1x4/{dir01}': 384718000}
1398
1399 # Sanity check that these exist!
1400 for scidd in spendable:
1401 assert scidd in [f"{c['short_channel_id']}/{c['direction']}" for c in l1.rpc.listchannels(source=nodemap[0])['channels']]
1402
1403 # We tell it we could get through amount, but not amount + 1.
1404 # This makes min == max, just like we do for auto.localchans spendable.
1405 l1.rpc.askrene_create_layer('localchans')
1406 for scidd, amount in spendable.items():
1407 l1.rpc.askrene_inform_channel(layer='localchans',
1408 short_channel_id_dir=scidd,
1409 amount_msat=amount,
1410 inform='unconstrained')
1411 l1.rpc.askrene_inform_channel(layer='localchans',
1412 short_channel_id_dir=scidd,
1413 amount_msat=amount + 1,
1414 inform='constrained')
1415
1416 routes = l1.rpc.getroutes(
1417 source=nodemap[0],
1418 destination=nodemap[2],
1419 amount_msat=800_000_001,
1420 layers=["localchans", "auto.sourcefree"],
1421 maxfee_msat=50_000_000,
1422 final_cltv=10,
1423 )
1424
1425 path_total = {}
1426 for r in routes["routes"]:
1427 key = r["path"][0]["short_channel_id_dir"]
1428 path_total[key] = path_total.get(key, 0) + r["path"][0]["amount_in_msat"]
1429
1430 exceeded = {}
1431 for scidd in spendable.keys():
1432 if scidd in path_total:
1433 if path_total[scidd] > spendable[scidd]:
1434 exceeded[scidd] = f"Path total {path_total[scidd]} > spendable {spendable[scidd]}"

Callers

nothing calls this directly

Calls 7

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45
listchannelsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected