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

Function test_max_htlc

tests/test_askrene.py:1413–1445  ·  view source on GitHub ↗

A route which looks good isn't actually, because of max htlc limits

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1411
1412
1413def test_max_htlc(node_factory, bitcoind):
1414 """A route which looks good isn't actually, because of max htlc limits"""
1415 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=500_000,
1416 forward=GenChannel.Half(htlc_max=1_000_000)),
1417 GenChannel(0, 1, capacity_sats=20_000)])
1418 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1419
1420 routes = l1.rpc.getroutes(source=nodemap[0],
1421 destination=nodemap[1],
1422 amount_msat=20_000_000,
1423 layers=[],
1424 maxfee_msat=20_000_000,
1425 final_cltv=10)
1426
1427 dir01 = direction(nodemap[0], nodemap[1])
1428 check_route_as_expected(routes['routes'],
1429 [[{'short_channel_id_dir': f'0x1x0/{dir01}', 'amount_in_msat': 1_000_001, 'cltv_in': 10 + 6}],
1430 [{'short_channel_id_dir': f'1x1x1/{dir01}', 'amount_in_msat': 19_000_019, 'cltv_in': 10 + 6}]])
1431
1432 # If we can't use channel 2, we fail.
1433 l1.rpc.askrene_create_layer('removechan2')
1434 l1.rpc.askrene_inform_channel(layer='removechan2',
1435 short_channel_id_dir=f'1x1x1/{dir01}',
1436 amount_msat=1,
1437 inform='constrained')
1438
1439 with pytest.raises(RpcError, match=rf"We could not find a usable set of paths. The shortest path is 0x1x0, but 0x1x0/{dir01} exceeds htlc_maximum_msat ~1000448msat"):
1440 l1.rpc.getroutes(source=nodemap[0],
1441 destination=nodemap[1],
1442 amount_msat=20_000_000,
1443 layers=['removechan2'],
1444 maxfee_msat=20_000_000,
1445 final_cltv=10)
1446
1447
1448def test_min_htlc(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 6

generate_gossip_storeFunction · 0.90
GenChannelClass · 0.90
check_route_as_expectedFunction · 0.85
getroutesMethod · 0.80
directionFunction · 0.70
get_nodeMethod · 0.45

Tested by

no test coverage detected