Skip to content

Commit

Permalink
pytest: simple getroutes tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Aug 4, 2024
1 parent 52827f3 commit 5d38768
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_askrene.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,42 @@ def test_getroutes(node_factory):
'next_node_id': nodemap[2],
'amount_msat': 9500009,
'delay': 99 + 6}]])


def test_getroutes_fee_fallback(node_factory):
"""Test getroutes call takes into account fees, if excessive"""

l1 = node_factory.get_node(start=False)
# 0 -> 1 -> 3: high capacity, high fee (1%)
# 0 -> 2 -> 3: low capacity, low fee.
gsfile, nodemap = generate_gossip_store([GenChannel(0, 1,
capacity_sats=20000,
forward=GenChannel.Half(propfee=10000)),
GenChannel(0, 2,
capacity_sats=10000),
GenChannel(1, 3,
capacity_sats=20000,
forward=GenChannel.Half(propfee=10000)),
GenChannel(2, 3,
capacity_sats=10000)])
# Set up l1 with this as the gossip_store
shutil.copy(gsfile.name, os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'))
l1.start()

# Don't hit maxfee? Go easy path.
check_getroute_paths(l1,
nodemap[0],
nodemap[3],
10000,
maxfee_msat=201,
paths=[[{'short_channel_id': '0x1x0'},
{'short_channel_id': '1x3x2'}]])

# maxfee exceeded? lower prob path.
check_getroute_paths(l1,
nodemap[0],
nodemap[3],
10000,
maxfee_msat=200,
paths=[[{'short_channel_id': '0x2x1'},
{'short_channel_id': '2x3x3'}]])

0 comments on commit 5d38768

Please sign in to comment.