test: add test for utxo-to-sqlite conversion using named pipe
What changed, and why it matters
This commit only adds a new automated test. It checks that a Bitcoin Core utility can convert the live UTXO set to an SQLite database when the data is fed through a named pipe (FIFO), without first writing a disk dump. There is no change to production code, no bug fix, and no security-relevant behavior.
No security action needed. This is a routine test-only addition and can be reviewed as normal QA.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a test case in test/functional/tool_utxo_to_sqlite.py. It creates a FIFO with os.mkfifo, launches the utxo_to_sqlite conversion tool reading from the FIFO, calls node.dumptxoutset to write the UTXO set into the FIFO, and verifies the resulting SQLite database has the same muhash as a previous conversion. The test is skipped on Windows because FIFOs are unavailable there. No source code is modified.
Changed components
test/functional/tool_utxo_to_sqlite.pyInspect captured patch +15 / −1
diff --git a/test/functional/tool_utxo_to_sqlite.py b/test/functional/tool_utxo_to_sqlite.py
index d1f3e7e1..d3b3fc43 100755
--- a/test/functional/tool_utxo_to_sqlite.py
+++ b/test/functional/tool_utxo_to_sqlite.py
@@ -4,7 +4,8 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test utxo-to-sqlite conversion tool"""
from itertools import product
-import os.path
+import os
+import platform
try:
import sqlite3
except ImportError:
@@ -135,6 +136,19 @@ class UtxoToSqliteTest(BitcoinTestFramework):
assert_equal(muhash_sqlite, muhash_compact_serialized)
self.log.info('')
+ if platform.system() != "Windows": # FIFOs are not available on Windows
+ self.log.info('Convert UTXO set directly (without intermediate dump) via named pipe')
+ fifo_filename = os.path.join(self.options.tmpdir, "utxos.fifo")
+ os.mkfifo(fifo_filename)
+ output_direct_filename = os.path.join(self.options.tmpdir, "utxos_direct.sqlite")
+ p = subprocess.Popen([sys.executable, utxo_to_sqlite_path, fifo_filename, output_direct_filename],
+ stderr=subprocess.STDOUT)
+ node.dumptxoutset(fifo_filename, "latest")
+ p.wait(timeout=10)
+ muhash_direct_sqlite = calculate_muhash_from_sqlite_utxos(output_direct_filename, "hex", "hex")
+ assert_equal(muhash_sqlite, muhash_direct_sqlite)
+ os.remove(fifo_filename)
+
if __name__ == "__main__":
UtxoToSqliteTest(__file__).main()
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.