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

Function test_limits_fake_gossmap

tests/test_askrene.py:1330–1410  ·  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

1328
1329
1330def test_limits_fake_gossmap(node_factory, bitcoind):
1331 """Like test_live_spendable, but using a generated gossmap not real nodes"""
1332 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=100_000),
1333 GenChannel(0, 1, capacity_sats=100_000),
1334 GenChannel(0, 1, capacity_sats=200_000),
1335 GenChannel(0, 1, capacity_sats=300_000),
1336 GenChannel(0, 1, capacity_sats=400_000),
1337 GenChannel(1, 2, capacity_sats=100_000),
1338 GenChannel(1, 2, capacity_sats=100_000),
1339 GenChannel(1, 2, capacity_sats=200_000),
1340 GenChannel(1, 2, capacity_sats=300_000),
1341 GenChannel(1, 2, capacity_sats=400_000)])
1342 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1343
1344 # Create a layer like auto.localchans would from "spendable"
1345 dir01 = direction(nodemap[0], nodemap[1])
1346 spendable = {f'0x1x0/{dir01}': 87718000,
1347 f'1x1x1/{dir01}': 87718000,
1348 f'2x1x2/{dir01}': 186718000,
1349 f'3x1x3/{dir01}': 285718000,
1350 f'4x1x4/{dir01}': 384718000}
1351
1352 # Sanity check that these exist!
1353 for scidd in spendable:
1354 assert scidd in [f"{c['short_channel_id']}/{c['direction']}" for c in l1.rpc.listchannels(source=nodemap[0])['channels']]
1355
1356 # We tell it we could get through amount, but not amount + 1.
1357 # This makes min == max, just like we do for auto.localchans spendable.
1358 l1.rpc.askrene_create_layer('localchans')
1359 for scidd, amount in spendable.items():
1360 l1.rpc.askrene_inform_channel(layer='localchans',
1361 short_channel_id_dir=scidd,
1362 amount_msat=amount,
1363 inform='unconstrained')
1364 l1.rpc.askrene_inform_channel(layer='localchans',
1365 short_channel_id_dir=scidd,
1366 amount_msat=amount + 1,
1367 inform='constrained')
1368
1369 routes = l1.rpc.getroutes(
1370 source=nodemap[0],
1371 destination=nodemap[2],
1372 amount_msat=800_000_001,
1373 layers=["localchans", "auto.sourcefree"],
1374 maxfee_msat=50_000_000,
1375 final_cltv=10,
1376 )
1377
1378 path_total = {}
1379 for r in routes["routes"]:
1380 key = r["path"][0]["short_channel_id_dir"]
1381 path_total[key] = path_total.get(key, 0) + r["path"][0]["amount_in_msat"]
1382
1383 exceeded = {}
1384 for scidd in spendable.keys():
1385 if scidd in path_total:
1386 if path_total[scidd] > spendable[scidd]:
1387 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