Skip to content

Commit 2a5fbd1

Browse files
committed
pytest: speed up test_sql significantly.
It uses the hold_invoice plugin to ensure that an HTLC is in flight, but it tells it to hold the HTLC for "TIMEOUT * 2" which is a big number under CI. Reduce it to sqrt(TIMEOUT + 1) * 2, which works for local testing (I run with TIMEOUT=10) and still should be enough for CI (TIMEOUT=180). Christian reported that the test took 763.00s (!!) under CI. On my build machine (TIMEOUT=90): Before: 383.00s After: 64.38s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 96adac4 commit 2a5fbd1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tests/test_plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import ast
1818
import copy
1919
import json
20+
import math
2021
import os
2122
import pytest
2223
import random
@@ -4034,7 +4035,7 @@ def test_sql(node_factory, bitcoind):
40344035

40354036
# And I need at least one HTLC in-flight so listpeers.channels.htlcs isn't empty:
40364037
l3.rpc.plugin_start(os.path.join(os.getcwd(), 'tests/plugins/hold_invoice.py'),
4037-
holdtime=TIMEOUT * 2)
4038+
holdtime=int(math.sqrt(TIMEOUT) + 1) * 2)
40384039
inv = l3.rpc.invoice(amount_msat=12300, label='inv3', description='description')
40394040
route = l1.rpc.getroute(l3.info['id'], 12300, 1)['route']
40404041
l1.rpc.sendpay(route, inv['payment_hash'], payment_secret=inv['payment_secret'])

0 commit comments

Comments
 (0)