pytest: clean up test_currencyrate.py using wait_for_logs()
What changed, and why it matters
This commit is a minor cleanup of a single test file. It replaces a manual sequence of log-search calls with a single helper that waits for multiple expected log messages regardless of order. There is no change to production code, no user-facing behavior change, and no security relevance.
No action required. This is a test-only refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/test_currencyrate.py only. The test_invalid_currency test previously saved/restored logsearch_start around each individual wait_for_log call to handle log messages arriving in an unpredictable order. The patch removes the manual needle bookkeeping and instead calls wait_for_logs() with a list of expected substrings, which is the intended helper for unordered log expectations. This is a test-code refactor with no functional or security impact.
Changed components
tests/test_currencyrate.pyInspect captured patch +7 / −16
diff --git a/tests/test_currencyrate.py b/tests/test_currencyrate.py
index e4f1795b..ac51296c 100644
--- a/tests/test_currencyrate.py
+++ b/tests/test_currencyrate.py
@@ -202,8 +202,6 @@ def test_invalid_currency(node_factory):
opts = {}
l1 = node_factory.get_node(options=opts)
- needle = l1.daemon.logsearch_start
-
with pytest.raises(
RpcError,
match=r"no results for `XXX`, is the currency supported\? Check the logs!",
@@ -211,20 +209,13 @@ def test_invalid_currency(node_factory):
rates = l1.rpc.call("listcurrencyrates", ["XXX"])
LOGGER.info(rates)
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from bitstamp")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from coinbase")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from coingecko")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from kraken")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from blockchain.info")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from coindesk")
- l1.daemon.logsearch_start = needle
- l1.daemon.wait_for_log("failed to get `XXX` rate from binance")
+ l1.daemon.wait_for_logs(["failed to get `XXX` rate from bitstamp",
+ "failed to get `XXX` rate from coinbase",
+ "failed to get `XXX` rate from coingecko",
+ "failed to get `XXX` rate from kraken",
+ "failed to get `XXX` rate from blockchain.info",
+ "failed to get `XXX` rate from coindesk",
+ "failed to get `XXX` rate from binance"])
class _ServerThread(threading.Thread):
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.