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

Function test_max_htlc

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

1458
1459
1460def test_max_htlc(node_factory, bitcoind):
1461 """A route which looks good isn't actually, because of max htlc limits"""
1462 gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=500_000,
1463 forward=GenChannel.Half(htlc_max=1_000_000)),
1464 GenChannel(0, 1, capacity_sats=20_000)])
1465 l1 = node_factory.get_node(gossip_store_file=gsfile.name)
1466
1467 routes = l1.rpc.getroutes(source=nodemap[0],
1468 destination=nodemap[1],
1469 amount_msat=20_000_000,
1470 layers=[],
1471 maxfee_msat=20_000_000,
1472 final_cltv=10)
1473
1474 dir01 = direction(nodemap[0], nodemap[1])
1475 check_route_as_expected(routes['routes'],
1476 [[{'short_channel_id_dir': f'0x1x0/{dir01}', 'amount_in_msat': 1_000_001, 'cltv_in': 10 + 6}],
1477 [{'short_channel_id_dir': f'1x1x1/{dir01}', 'amount_in_msat': 19_000_019, 'cltv_in': 10 + 6}]])
1478
1479 # If we can't use channel 2, we fail.
1480 l1.rpc.askrene_create_layer('removechan2')
1481 l1.rpc.askrene_inform_channel(layer='removechan2',
1482 short_channel_id_dir=f'1x1x1/{dir01}',
1483 amount_msat=1,
1484 inform='constrained')
1485
1486 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"):
1487 l1.rpc.getroutes(source=nodemap[0],
1488 destination=nodemap[1],
1489 amount_msat=20_000_000,
1490 layers=['removechan2'],
1491 maxfee_msat=20_000_000,
1492 final_cltv=10)
1493
1494
1495def 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