From 81569de709ce815aea4afe9701536f40737c1cc7 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 6 Oct 2020 11:25:20 +0200 Subject: [PATCH] pytest: Stabilize test_setchannelfee_{restart,zero} In both cases the flakyness arises from the destination not knowing about the modified fees of the forwarding node, thus including the outdated details in the routehint, and the sender being unlucky and always trying with the routehint anyway. The long-term solutions to this is going to be #4111, this commit just reduces the flakyness to get back to business. --- tests/test_pay.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_pay.py b/tests/test_pay.py index 287f74ce9..ec9861921 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2034,6 +2034,10 @@ def test_setchannelfee_routing(node_factory, bitcoind): assert route[0]['msatoshi'] == 5002020 assert route[1]['msatoshi'] == 4999999 + # In case l3 includes a routehint, we need to make sure they also know + # about the new fees, otherwise we may end up with the old feerate + wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l3.rpc.listchannels(scid)['channels']] == [(1337, 137, True), (DEF_BASE, DEF_PPM, True)]) + # do and check actual payment inv = l3.rpc.invoice(4999999, 'test_setchannelfee_1', 'desc')['bolt11'] result = l1.rpc.dev_pay(inv, use_shadow=False) @@ -2054,6 +2058,10 @@ def test_setchannelfee_routing(node_factory, bitcoind): assert route[0]['msatoshi'] == 5000049 assert route[1]['msatoshi'] == 4999999 + # In case l3 includes a routehint, we need to make sure they also know + # about the new fees, otherwise we may end up with the old feerate + wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l3.rpc.listchannels(scid)['channels']] == [(DEF_BASE, DEF_PPM, True), (DEF_BASE, DEF_PPM, True)]) + # do and check actual payment inv = l3.rpc.invoice(4999999, 'test_setchannelfee_2', 'desc')['bolt11'] result = l1.rpc.dev_pay(inv, use_shadow=False) @@ -2091,6 +2099,10 @@ def test_setchannelfee_zero(node_factory, bitcoind): assert route[0]['msatoshi'] == 4999999 assert route[1]['msatoshi'] == 4999999 + # Wait for l3 to know about our low-balling, otherwise they'll add a wrong + # routehint to the invoice. + wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l3.rpc.listchannels(scid)['channels']] == [(0, 0, True), (DEF_BASE, DEF_PPM, True)]) + # do and check actual payment inv = l3.rpc.invoice(4999999, 'test_setchannelfee_3', 'desc')['bolt11'] result = l1.rpc.dev_pay(inv, use_shadow=False) @@ -2132,6 +2144,10 @@ def test_setchannelfee_restart(node_factory, bitcoind): # l1 wait for channel update from l2 wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l1.rpc.listchannels(scid23)['channels']] == [(1337, 137, True), (DEF_BASE, DEF_PPM, True)]) + # In case l3 includes a routehint, we need to make sure they also know + # about the new fees, otherwise we may end up with the old feerate + wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l3.rpc.listchannels(scid23)['channels']] == [(1337, 137, True), (DEF_BASE, DEF_PPM, True)]) + # l1 can make payment to l3 with custom fees being applied # Note: BOLT #7 math works out to 2021 msat fees inv = l3.rpc.invoice(4999999, 'test_setchannelfee_1', 'desc')['bolt11']