What changed, and why it matters
This commit only adds a new automated test to the project's test suite. It checks that the experimental SQL query feature correctly notices when invoices are added, deleted, or expire. There is no change to production code, no bug fix, and no security-relevant behavior in the diff itself.
No action required. Review as ordinary test coverage.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds test_sql_during_change in tests/test_plugin.py and fixes an unrelated argument bug in test_autoclean_batch (node_factory.get_node(1) -> node_factory.get_node()). The new test exercises the sql RPC against the invoices table during invoice creation, deletion, and expiration. It is a regression/behavioral test, not a patch for a vulnerability.
Changed components
tests/test_plugin.pyInspect captured patch +25 / −1
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 84b53f72..097e600a 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -4539,7 +4539,7 @@ def test_plugin_startdir_lol(node_factory):
def test_autoclean_batch(node_factory):
- l1 = node_factory.get_node(1)
+ l1 = node_factory.get_node()
# Many expired invoices
for i in range(100):
@@ -4603,6 +4603,30 @@ def test_sql_parallel(node_factory, executor):
f.result(TIMEOUT)
+def test_sql_during_change(node_factory):
+ l1 = node_factory.get_node()
+
+ labels = [f"test_sql_during_delete{i:02}" for i in range(10)]
+ for l in labels:
+ l1.rpc.invoice(100, l, l)
+ assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]}
+
+ # Should notice extra one (note shorter expiry)
+ l = f"test_sql_during_delete{11}"
+ l1.rpc.invoice(100, l, l, expiry=10)
+ labels.append(l)
+ assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]}
+
+ # Should notice delete.
+ l1.rpc.delinvoice(labels[0], 'unpaid')
+ del labels[0]
+ assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]}
+
+ # Should notice change once invoice has expired.
+ wait_for(lambda: only_one(l1.rpc.listinvoices(label=labels[-1])['invoices'])['status'] != 'unpaid', timeout=10 + TIMEOUT)
+ assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels[:-1]] + [[100, labels[-1], 'expired']]}
+
+
def test_listchannels_broken_message(node_factory):
"""This gave a bogus BROKEN message with deprecated-apis enabled"""
l1 = node_factory.get_node(options={'allow-deprecated-apis': True})
Why this scored 12/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.