pytest: fix timing flake in test_invoice_expiry.
What changed, and why it matters
This commit only adjusts timing values in a single test file to prevent a flaky test failure under slow CI runners (specifically Postgres). It does not change production code, protocol behavior, or any security-relevant logic.
No security action needed. Treat as a normal test reliability fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies tests/test_invoices.py in test_invoice_expiry. It increases invoice expiry times and the sleeps between waitinvoice checks so that the test’s assumptions about which futures have/haven’t completed remain valid even when CI is slow. No node, RPC, wallet, or cryptographic code is touched.
Changed components
tests/test_invoices.pyInspect captured patch +8 / −8
diff --git a/tests/test_invoices.py b/tests/test_invoices.py
index 6f4bc3ca..a3db715a 100644
--- a/tests/test_invoices.py
+++ b/tests/test_invoices.py
@@ -407,9 +407,10 @@ def test_invoice_expiry(node_factory, executor):
# Test expiration waiting.
# The second invoice created expires first.
- l2.rpc.invoice('any', 'inv1', 'description', 10)
- l2.rpc.invoice('any', 'inv2', 'description', 4)
- l2.rpc.invoice('any', 'inv3', 'description', 16)
+ # Times should be long enough even for our terrible CI runners!
+ l2.rpc.invoice('any', 'inv1', 'description', 16)
+ l2.rpc.invoice('any', 'inv2', 'description', 10)
+ l2.rpc.invoice('any', 'inv3', 'description', 22)
# Check waitinvoice correctly waits
w1 = executor.submit(l2.rpc.waitinvoice, 'inv1')
@@ -419,19 +420,18 @@ def test_invoice_expiry(node_factory, executor):
assert not w1.done()
assert not w2.done()
assert not w3.done()
- time.sleep(4) # total 6
+ time.sleep(7) # total 9
assert not w1.done()
- with pytest.raises(RpcError):
+ with pytest.raises(RpcError): # total 10
w2.result()
assert not w3.done()
- time.sleep(6) # total 12
- with pytest.raises(RpcError):
+ time.sleep(5) # total 15
+ with pytest.raises(RpcError): # total 16
w1.result()
assert not w3.done()
- time.sleep(8) # total 20
with pytest.raises(RpcError):
w3.result()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.