Skip to content

Commit 66a151d

Browse files
committed
pytest: fix timing flake in test_invoice_expiry.
Under Postgres, this actually takes more than 2 seconds, so w2 really has timed out already: ``` time.sleep(2) # total 2 assert not w1.done() > assert not w2.done() E assert not True E + where True = done() E + where done = <Future at 0x7fe14e54fee0 state=finished raised RpcError>.done tests/test_invoices.py:420: AssertionError ``` So space the timeouts out more, and sleep one second too short; the .result() (which sleeps) will catch up if we were extremely slow. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent cf6cf36 commit 66a151d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/test_invoices.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,10 @@ def test_invoice_expiry(node_factory, executor):
407407

408408
# Test expiration waiting.
409409
# The second invoice created expires first.
410-
l2.rpc.invoice('any', 'inv1', 'description', 10)
411-
l2.rpc.invoice('any', 'inv2', 'description', 4)
412-
l2.rpc.invoice('any', 'inv3', 'description', 16)
410+
# Times should be long enough even for our terrible CI runners!
411+
l2.rpc.invoice('any', 'inv1', 'description', 16)
412+
l2.rpc.invoice('any', 'inv2', 'description', 10)
413+
l2.rpc.invoice('any', 'inv3', 'description', 22)
413414

414415
# Check waitinvoice correctly waits
415416
w1 = executor.submit(l2.rpc.waitinvoice, 'inv1')
@@ -419,19 +420,18 @@ def test_invoice_expiry(node_factory, executor):
419420
assert not w1.done()
420421
assert not w2.done()
421422
assert not w3.done()
422-
time.sleep(4) # total 6
423+
time.sleep(7) # total 9
423424
assert not w1.done()
424425

425-
with pytest.raises(RpcError):
426+
with pytest.raises(RpcError): # total 10
426427
w2.result()
427428
assert not w3.done()
428429

429-
time.sleep(6) # total 12
430-
with pytest.raises(RpcError):
430+
time.sleep(5) # total 15
431+
with pytest.raises(RpcError): # total 16
431432
w1.result()
432433
assert not w3.done()
433434

434-
time.sleep(8) # total 20
435435
with pytest.raises(RpcError):
436436
w3.result()
437437

0 commit comments

Comments
 (0)