Skip to content

Commit da4edd2

Browse files
committed
pytest: test to demonstrate that reservations of "private" channels overlap.
Signed-off-by: Rusty Russell <[email protected]>
1 parent 6e4bc1d commit da4edd2

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
@@ -1845,3 +1845,74 @@ def test_askrene_timeout(node_factory, bitcoind):
18451845
layers=['auto.localchans'],
18461846
maxfee_msat=1,
18471847
final_cltv=5)
1848+
1849+
1850+
@pytest.mark.xfail(strict=True)
1851+
def test_askrene_reserve_clash(node_factory, bitcoind):
1852+
"""Reserves get (erroneously) counted globally by scid, even for fake scids."""
1853+
l1 = node_factory.get_node()
1854+
1855+
node1 = "020000000000000000000000000000000000000000000000000000000000000001"
1856+
node2 = "020000000000000000000000000000000000000000000000000000000000000002"
1857+
l1.rpc.askrene_create_layer('layer1')
1858+
l1.rpc.askrene_create_layer('layer2')
1859+
l1.rpc.askrene_create_channel(layer="layer1",
1860+
source=l1.info['id'],
1861+
destination=node1,
1862+
short_channel_id="0x0x0",
1863+
capacity_msat=1000000)
1864+
l1.rpc.askrene_update_channel(layer='layer1',
1865+
short_channel_id_dir='0x0x0/1',
1866+
enabled=True,
1867+
htlc_minimum_msat=0,
1868+
htlc_maximum_msat=1000000,
1869+
fee_base_msat=1,
1870+
fee_proportional_millionths=2,
1871+
cltv_expiry_delta=18)
1872+
l1.rpc.askrene_create_channel(layer="layer2",
1873+
source=l1.info['id'],
1874+
destination=node2,
1875+
short_channel_id="0x0x0",
1876+
capacity_msat=1000000)
1877+
l1.rpc.askrene_update_channel(layer='layer2',
1878+
short_channel_id_dir='0x0x0/1',
1879+
enabled=True,
1880+
htlc_minimum_msat=0,
1881+
htlc_maximum_msat=1000000,
1882+
fee_base_msat=1,
1883+
fee_proportional_millionths=2,
1884+
cltv_expiry_delta=18)
1885+
l1.rpc.getroutes(source=l1.info['id'],
1886+
destination=node1,
1887+
amount_msat=500000,
1888+
layers=['layer1'],
1889+
maxfee_msat=1000,
1890+
final_cltv=5)
1891+
l1.rpc.getroutes(source=l1.info['id'],
1892+
destination=node2,
1893+
amount_msat=500000,
1894+
layers=['layer2'],
1895+
maxfee_msat=1000,
1896+
final_cltv=5)
1897+
1898+
l1.rpc.askrene_reserve(path=[{'short_channel_id_dir': '0x0x0/1',
1899+
'amount_msat': 950000,
1900+
# 'layer': 'layer1'
1901+
}])
1902+
1903+
# We can't use this on layer 1 anymore, only 50000 msat left.
1904+
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"):
1905+
l1.rpc.getroutes(source=l1.info['id'],
1906+
destination=node1,
1907+
amount_msat=500000,
1908+
layers=['layer1'],
1909+
maxfee_msat=1000,
1910+
final_cltv=5)
1911+
1912+
# But layer2 should be unaffected
1913+
l1.rpc.getroutes(source=l1.info['id'],
1914+
destination=node2,
1915+
amount_msat=500000,
1916+
layers=['layer2'],
1917+
maxfee_msat=1000,
1918+
final_cltv=5)

0 commit comments

Comments
 (0)