Skip to content

Commit b368a3e

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

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
@@ -1608,3 +1608,74 @@ def test_askrene_timeout(node_factory, bitcoind):
16081608
layers=['auto.localchans'],
16091609
maxfee_msat=1,
16101610
final_cltv=5)
1611+
1612+
1613+
@pytest.mark.xfail(strict=True)
1614+
def test_askrene_reserve_clash(node_factory, bitcoind):
1615+
"""Reserves get (erroneously) counted globally by scid, even for fake scids."""
1616+
l1 = node_factory.get_node()
1617+
1618+
node1 = "020000000000000000000000000000000000000000000000000000000000000001"
1619+
node2 = "020000000000000000000000000000000000000000000000000000000000000002"
1620+
l1.rpc.askrene_create_layer('layer1')
1621+
l1.rpc.askrene_create_layer('layer2')
1622+
l1.rpc.askrene_create_channel(layer="layer1",
1623+
source=l1.info['id'],
1624+
destination=node1,
1625+
short_channel_id="0x0x0",
1626+
capacity_msat=1000000)
1627+
l1.rpc.askrene_update_channel(layer='layer1',
1628+
short_channel_id_dir='0x0x0/1',
1629+
enabled=True,
1630+
htlc_minimum_msat=0,
1631+
htlc_maximum_msat=1000000,
1632+
fee_base_msat=1,
1633+
fee_proportional_millionths=2,
1634+
cltv_expiry_delta=18)
1635+
l1.rpc.askrene_create_channel(layer="layer2",
1636+
source=l1.info['id'],
1637+
destination=node2,
1638+
short_channel_id="0x0x0",
1639+
capacity_msat=1000000)
1640+
l1.rpc.askrene_update_channel(layer='layer2',
1641+
short_channel_id_dir='0x0x0/1',
1642+
enabled=True,
1643+
htlc_minimum_msat=0,
1644+
htlc_maximum_msat=1000000,
1645+
fee_base_msat=1,
1646+
fee_proportional_millionths=2,
1647+
cltv_expiry_delta=18)
1648+
l1.rpc.getroutes(source=l1.info['id'],
1649+
destination=node1,
1650+
amount_msat=500000,
1651+
layers=['layer1'],
1652+
maxfee_msat=1000,
1653+
final_cltv=5)
1654+
l1.rpc.getroutes(source=l1.info['id'],
1655+
destination=node2,
1656+
amount_msat=500000,
1657+
layers=['layer2'],
1658+
maxfee_msat=1000,
1659+
final_cltv=5)
1660+
1661+
l1.rpc.askrene_reserve(path=[{'short_channel_id_dir': '0x0x0/1',
1662+
'amount_msat': 950000,
1663+
# 'layer': 'layer1'
1664+
}])
1665+
1666+
# We can't use this on layer 1 anymore, only 50000 msat left.
1667+
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"):
1668+
l1.rpc.getroutes(source=l1.info['id'],
1669+
destination=node1,
1670+
amount_msat=500000,
1671+
layers=['layer1'],
1672+
maxfee_msat=1000,
1673+
final_cltv=5)
1674+
1675+
# But layer2 should be unaffected
1676+
l1.rpc.getroutes(source=l1.info['id'],
1677+
destination=node2,
1678+
amount_msat=500000,
1679+
layers=['layer2'],
1680+
maxfee_msat=1000,
1681+
final_cltv=5)

0 commit comments

Comments
 (0)