Browse Source

pytest: fix flaky test_setchannel_fee_restart test.

gossipd in l1 might not have registered l2 reconnecting, thus considering
the channel local-disabled.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
issue-2504
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
a498b1fdbf
  1. 18
      tests/test_pay.py

18
tests/test_pay.py

@ -1734,25 +1734,23 @@ def test_setchannelfee_restart(node_factory, bitcoind):
l1, l2, l3 = node_factory.line_graph(3, announce_channels=True, wait_for_announce=True, opts=OPTS) l1, l2, l3 = node_factory.line_graph(3, announce_channels=True, wait_for_announce=True, opts=OPTS)
# get short channel id for 2->3 # get short channel idS
scid = l2.get_channel_scid(l3) scid12 = l1.get_channel_scid(l2)
scid23 = l2.get_channel_scid(l3)
# l2 set custom fees # l2 set custom fees
l2.rpc.setchannelfee(scid, 1337, 137) l2.rpc.setchannelfee(scid23, 1337, 137)
# restart l2 and reconnect # restart l2 and reconnect
l2.restart() l2.restart()
l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l2.rpc.connect(l3.info['id'], 'localhost', l3.port) l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
# l1 wait for channel update # Make sure l1's gossipd registered channeld activating channel.
wait_for(lambda: [c['base_fee_millisatoshi'] for c in l1.rpc.listchannels(scid)['channels']] == [1337, DEF_BASE]) wait_for(lambda: [c['active'] for c in l1.rpc.listchannels(scid12)['channels']] == [True, True])
wait_for(lambda: [c['fee_per_millionth'] for c in l1.rpc.listchannels(scid)['channels']] == [137, DEF_PPM])
# for slow travis: wait for everyone to see all channels # l1 wait for channel update from l2
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 4) 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)])
wait_for(lambda: len(l2.rpc.listchannels()['channels']) == 4)
wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 4)
# l1 can make payment to l3 with custom fees being applied # l1 can make payment to l3 with custom fees being applied
# Note: BOLT #7 math works out to 2021 msat fees # Note: BOLT #7 math works out to 2021 msat fees

Loading…
Cancel
Save