tests: query our_outputs in test_connection.py
What changed, and why it matters
This commit only updates test code to query a renamed database table (`our_outputs` instead of `outputs`) and adjusts column names/conditions. It does not change production wallet logic or fix a security bug. There is no security relevance.
No security action required. Treat as routine test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies tests/test_connection.py to replace raw SQL assertions that queried the legacy outputs table (using status codes) with equivalent queries against the new our_outputs table, using spendheight IS NULL/IS NOT NULL and reserved_til to determine unspent/spent/reserved state. This is a test-maintenance refactor matching the wallet’s live UTXO state migration. No production code is changed.
Changed components
tests/test_connection.pyInspect captured patch +7 / −7
diff --git a/tests/test_connection.py b/tests/test_connection.py
index f19fb88b..6d5d7368 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -1039,18 +1039,18 @@ def test_funding_change(node_factory, bitcoind):
bitcoind.generate_block(1)
sync_blockheight(bitcoind, [l1])
- outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;')
+ outputs = l1.db_query('SELECT satoshis AS value FROM our_outputs WHERE spendheight IS NULL AND reserved_til = 0;')
assert only_one(outputs)['value'] == 10000000
l1.rpc.fundchannel(l2.info['id'], 1000000)
bitcoind.generate_block(1, wait_for_mempool=1)
sync_blockheight(bitcoind, [l1])
- outputs = {r['status']: r['value'] for r in l1.db_query(
- 'SELECT status, SUM(value) AS value FROM outputs GROUP BY status;')}
# The 10m out is spent and we have a change output of 9m-fee
- assert outputs[0] > 8990000
- assert outputs[2] == 10000000
+ spent = l1.db_query('SELECT SUM(satoshis) AS value FROM our_outputs WHERE spendheight IS NOT NULL;')
+ unspent = l1.db_query('SELECT SUM(satoshis) AS value FROM our_outputs WHERE spendheight IS NULL;')
+ assert only_one(unspent)['value'] > 8990000
+ assert only_one(spent)['value'] == 10000000
@pytest.mark.openchannel('v1')
@@ -1064,13 +1064,13 @@ def test_funding_all(node_factory, bitcoind):
bitcoind.generate_block(1)
sync_blockheight(bitcoind, [l1])
- outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;')
+ outputs = l1.db_query('SELECT satoshis AS value FROM our_outputs WHERE spendheight IS NULL AND reserved_til = 0;')
assert only_one(outputs)['value'] == 10000000
l1.rpc.fundchannel(l2.info['id'], "all")
# Keeps emergency reserve!
- outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;')
+ outputs = l1.db_query('SELECT satoshis AS value FROM our_outputs WHERE spendheight IS NULL AND reserved_til = 0;')
if 'anchors/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']:
assert outputs == [{'value': 25000}]
else:
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.