Fix failing test
This commit is contained in:
parent
0c28136739
commit
f7c95986bf
@ -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:
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user