From 2c9023ee25d6aa6f6b7f602c2b10395045aad6a1 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Nov 2024 14:03:37 +1030 Subject: [PATCH] pytest: reenable askrene bias test. We can fix the median calc by removing the (unused) reverse edges. Also analyze the failure case in test_real_data: it's a real edge case, so hardcode that one as "ok". Signed-off-by: Rusty Russell --- tests/test_askrene.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test_askrene.py b/tests/test_askrene.py index b0941125cab6..580215a70653 100644 --- a/tests/test_askrene.py +++ b/tests/test_askrene.py @@ -552,22 +552,26 @@ def test_getroutes(node_factory): 'delay': 99 + 6}]]) -@pytest.mark.skip def test_getroutes_fee_fallback(node_factory): """Test getroutes call takes into account fees, if excessive""" # 0 -> 1 -> 3: high capacity, high fee (1%) # 0 -> 2 -> 3: low capacity, low fee. + # (We disable reverse, since it breaks median calc!) gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=20000, - forward=GenChannel.Half(propfee=10000)), + forward=GenChannel.Half(propfee=10000), + reverse=GenChannel.Half(enabled=False)), GenChannel(0, 2, - capacity_sats=10000), + capacity_sats=10000, + reverse=GenChannel.Half(enabled=False)), GenChannel(1, 3, capacity_sats=20000, - forward=GenChannel.Half(propfee=10000)), + forward=GenChannel.Half(propfee=10000), + reverse=GenChannel.Half(enabled=False)), GenChannel(2, 3, - capacity_sats=10000)]) + capacity_sats=10000, + reverse=GenChannel.Half(enabled=False))]) # Set up l1 with this as the gossip_store l1 = node_factory.get_node(gossip_store_file=gsfile.name) @@ -1204,6 +1208,13 @@ def amount_through_chan(chan, routes): amount_after = amount_through_chan(chan, route2['routes']) if amount_after < amount_before: num_changed[bias] += 1 + else: + # We bias -4 against 83x88x31908/0 going to node 83, and this is violated. + # Both routes contain three paths, all via 83x88x31908/0. + # The first amounts 49490584, 1018832, 49490584, + # The second amounts 25254708, 25254708, 49490584, + # Due to fees and rounding, we actually spend 1msat more on the second case! + assert (n, bias, chan) == (83, 4, '83x88x31908/0') # Undo bias l1.rpc.askrene_bias_channel(layer='biases', short_channel_id_dir=chan, bias=0)