diff --git a/electrumx/server/db.py b/electrumx/server/db.py index 6f55a2a..3ee5103 100644 --- a/electrumx/server/db.py +++ b/electrumx/server/db.py @@ -96,7 +96,7 @@ class DB(object): os.mkdir('meta') with util.open_file('COIN', create=True) as f: f.write(f'ElectrumX databases and metadata for ' - f'{self.coin.NAME} {self.coin.NET}') + f'{self.coin.NAME} {self.coin.NET}'.encode()) if not self.coin.STATIC_BLOCK_HEADERS: self.headers_offsets_file.write(0, bytes(8)) else: diff --git a/tests/server/test_compaction.py b/tests/server/test_compaction.py index 2d051d1..f9c9eb6 100644 --- a/tests/server/test_compaction.py +++ b/tests/server/test_compaction.py @@ -1,6 +1,7 @@ # Test of compaction code in server/history.py import array +import asyncio from collections import defaultdict from os import environ, urandom from struct import pack @@ -109,13 +110,15 @@ def compact_history(history): write_size += history._compact_history(limit) assert write_size != 0 -def run_test(db_dir): +async def run_test(db_dir): environ.clear() environ['DB_DIRECTORY'] = db_dir environ['DAEMON_URL'] = '' environ['COIN'] = 'BitcoinCash' - env = Env() - history = DB(env).history + db = DB(Env()) + await db.open_for_serving() + history = db.history + # Test abstract compaction check_hashX_compaction(history) # Now test in with random data @@ -127,4 +130,5 @@ def run_test(db_dir): def test_compaction(tmpdir): db_dir = str(tmpdir) print('Temp dir: {}'.format(db_dir)) - run_test(db_dir) + loop = asyncio.get_event_loop() + loop.run_until_complete(run_test(db_dir))