Skip to content

Commit 78fdb20

Browse files
committed
pytest: test to demonstrate that reservations of "private" channels overlap.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent dbbae17 commit 78fdb20

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/test_askrene.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,3 +1473,74 @@ def test_simple_dummy_channel(node_factory):
14731473
final_cltv=5,
14741474
layers=["mylayer"],
14751475
)
1476+
1477+
1478+
@pytest.mark.xfail(strict=True)
1479+
def test_askrene_reserve_clash(node_factory, bitcoind):
1480+
"""Reserves get (erroneously) counted globally by scid, even for fake scids."""
1481+
l1 = node_factory.get_node()
1482+
1483+
node1 = "020000000000000000000000000000000000000000000000000000000000000001"
1484+
node2 = "020000000000000000000000000000000000000000000000000000000000000002"
1485+
l1.rpc.askrene_create_layer('layer1')
1486+
l1.rpc.askrene_create_layer('layer2')
1487+
l1.rpc.askrene_create_channel(layer="layer1",
1488+
source=l1.info['id'],
1489+
destination=node1,
1490+
short_channel_id="0x0x0",
1491+
capacity_msat=1000000)
1492+
l1.rpc.askrene_update_channel(layer='layer1',
1493+
short_channel_id_dir='0x0x0/1',
1494+
enabled=True,
1495+
htlc_minimum_msat=0,
1496+
htlc_maximum_msat=1000000,
1497+
fee_base_msat=1,
1498+
fee_proportional_millionths=2,
1499+
cltv_expiry_delta=18)
1500+
l1.rpc.askrene_create_channel(layer="layer2",
1501+
source=l1.info['id'],
1502+
destination=node2,
1503+
short_channel_id="0x0x0",
1504+
capacity_msat=1000000)
1505+
l1.rpc.askrene_update_channel(layer='layer2',
1506+
short_channel_id_dir='0x0x0/1',
1507+
enabled=True,
1508+
htlc_minimum_msat=0,
1509+
htlc_maximum_msat=1000000,
1510+
fee_base_msat=1,
1511+
fee_proportional_millionths=2,
1512+
cltv_expiry_delta=18)
1513+
l1.rpc.getroutes(source=l1.info['id'],
1514+
destination=node1,
1515+
amount_msat=500000,
1516+
layers=['layer1'],
1517+
maxfee_msat=1000,
1518+
final_cltv=5)
1519+
l1.rpc.getroutes(source=l1.info['id'],
1520+
destination=node2,
1521+
amount_msat=500000,
1522+
layers=['layer2'],
1523+
maxfee_msat=1000,
1524+
final_cltv=5)
1525+
1526+
l1.rpc.askrene_reserve(path=[{'short_channel_id_dir': '0x0x0/1',
1527+
'amount_msat': 950000,
1528+
# 'layer': 'layer1'
1529+
}])
1530+
1531+
# We can't use this on layer 1 anymore, only 50000 msat left.
1532+
with pytest.raises(RpcError, match=r"We could not find a usable set of paths. The shortest path is 0x0x0, but 0x0x0/1 already reserved 950000msat by command"):
1533+
l1.rpc.getroutes(source=l1.info['id'],
1534+
destination=node1,
1535+
amount_msat=500000,
1536+
layers=['layer1'],
1537+
maxfee_msat=1000,
1538+
final_cltv=5)
1539+
1540+
# But layer2 should be unaffected
1541+
l1.rpc.getroutes(source=l1.info['id'],
1542+
destination=node2,
1543+
amount_msat=500000,
1544+
layers=['layer2'],
1545+
maxfee_msat=1000,
1546+
final_cltv=5)

0 commit comments

Comments
 (0)