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

Function test_max_htlc

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

1493
1494
1495def test_max_htlc(node_factory, bitcoind):
1496 """A route which looks good isn't actually, because of max htlc limits"""
1497 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=500_000,
1498 forward=GenChannel.Half(htlc_max=1_000_000)),
1499 GenChannel(0, 1, capacity_sats=20_000)])
1500 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1501
1502 routes = l1.rpc.getroutes(source=nodemap[0],
1503 destination=nodemap[1],
1504 amount_msat=20_000_000,
1505 layers=[],
1506 maxfee_msat=20_000_000,
1507 final_cltv=10)
1508
1509 dir01 = direction(nodemap[0], nodemap[1])
1510 check_route_as_expected(routes['routes'],
1511 [[{'short_channel_id_dir': f'0x1x0/{dir01}', 'amount_in_msat': 1_000_001, 'cltv_in': 10 + 6}],
1512 [{'short_channel_id_dir': f'1x1x1/{dir01}', 'amount_in_msat': 19_000_019, 'cltv_in': 10 + 6}]])
1513
1514 # If we can't use channel 2, we fail.
1515 l1.rpc.askrene_create_layer('removechan2')
1516 l1.rpc.askrene_inform_channel(layer='removechan2',
1517 short_channel_id_dir=f'1x1x1/{dir01}',
1518 amount_msat=1,
1519 inform='constrained')
1520
1521 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"):
1522 l1.rpc.getroutes(source=nodemap[0],
1523 destination=nodemap[1],
1524 amount_msat=20_000_000,
1525 layers=['removechan2'],
1526 maxfee_msat=20_000_000,
1527 final_cltv=10)
1528
1529
1530def 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