Skip to content

Commit 922d78e

Browse files
committed
pytest: fix flake in test_onionmessage_ratelimit.
By submitting them all at once, rather than serially, we should *definitely* hit the ratelimit. We can also reduce the timeout (from 60 seconds) to speed the test up. ``` @pytest.mark.slow_test def test_onionmessage_ratelimit(node_factory): l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'allow_warning': True}) offer = l2.rpc.call('offer', {'amount': '2msat', 'description': 'simple test'}) # Hopefully we can do this fast enough to reach ratelimit! > with pytest.raises(RpcError, match="Timeout waiting for response"): E Failed: DID NOT RAISE <class 'pyln.client.lightning.RpcError'> tests/test_pay.py:5825: Failed ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 2050f9a commit 922d78e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/test_pay.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,17 +5814,21 @@ def test_pay_legacy_forward(node_factory, bitcoind, executor):
58145814

58155815
# CI is so slow under valgrind that this does not reach the ratelimit!
58165816
@pytest.mark.slow_test
5817-
def test_onionmessage_ratelimit(node_factory):
5817+
def test_onionmessage_ratelimit(node_factory, executor):
58185818
l1, l2 = node_factory.line_graph(2, fundchannel=False,
58195819
opts={'allow_warning': True})
58205820

58215821
offer = l2.rpc.call('offer', {'amount': '2msat',
58225822
'description': 'simple test'})
58235823

58245824
# Hopefully we can do this fast enough to reach ratelimit!
5825+
futs = []
5826+
for _ in range(8):
5827+
futs.append(executor.submit(l1.rpc.fetchinvoice, offer=offer['bolt12'], timeout=10))
5828+
58255829
with pytest.raises(RpcError, match="Timeout waiting for response"):
5826-
for _ in range(8):
5827-
l1.rpc.fetchinvoice(offer['bolt12'])
5830+
for f in futs:
5831+
f.result(TIMEOUT)
58285832

58295833
# Normally l2 gets upset, but actually l1 can get upset with replies!
58305834
assert (l1.daemon.is_in_log('WARNING: Ratelimited onion_message: exceeded one per 250msec')

0 commit comments

Comments
 (0)