Skip to content

Commit cfda1d1

Browse files
committed
test: add test for utxo-to-sqlite conversion using named pipe
1 parent 790a98a commit cfda1d1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/functional/tool_utxo_to_sqlite.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test utxo-to-sqlite conversion tool"""
6-
import os.path
6+
import os
77
try:
88
import sqlite3
99
except ImportError:
1010
pass
11+
import platform
1112
import subprocess
1213
import sys
1314

@@ -112,6 +113,19 @@ def run_test(self):
112113
muhash_compact_serialized = node.gettxoutsetinfo('muhash')['muhash']
113114
assert_equal(muhash_sqlite, muhash_compact_serialized)
114115

116+
if platform.system() != "Windows": # FIFOs are not available on Windows
117+
self.log.info('Convert UTXO set directly (without intermediate dump) via named pipe')
118+
fifo_filename = os.path.join(self.options.tmpdir, "utxos.fifo")
119+
os.mkfifo(fifo_filename)
120+
output_direct_filename = os.path.join(self.options.tmpdir, "utxos_direct.sqlite")
121+
p = subprocess.Popen([sys.executable, utxo_to_sqlite_path, fifo_filename, output_direct_filename],
122+
stderr=subprocess.STDOUT)
123+
node.dumptxoutset(fifo_filename, "latest")
124+
p.wait(timeout=10)
125+
muhash_direct_sqlite = calculate_muhash_from_sqlite_utxos(output_direct_filename)
126+
assert_equal(muhash_sqlite, muhash_direct_sqlite)
127+
os.remove(fifo_filename)
128+
115129

116130
if __name__ == "__main__":
117131
UtxoToSqliteTest(__file__).main()

0 commit comments

Comments
 (0)