Fix failing test
This commit is contained in:
parent
0c28136739
commit
f7c95986bf
@ -96,7 +96,7 @@ class DB(object):
|
|||||||
os.mkdir('meta')
|
os.mkdir('meta')
|
||||||
with util.open_file('COIN', create=True) as f:
|
with util.open_file('COIN', create=True) as f:
|
||||||
f.write(f'ElectrumX databases and metadata for '
|
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:
|
if not self.coin.STATIC_BLOCK_HEADERS:
|
||||||
self.headers_offsets_file.write(0, bytes(8))
|
self.headers_offsets_file.write(0, bytes(8))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# Test of compaction code in server/history.py
|
# Test of compaction code in server/history.py
|
||||||
|
|
||||||
import array
|
import array
|
||||||
|
import asyncio
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from os import environ, urandom
|
from os import environ, urandom
|
||||||
from struct import pack
|
from struct import pack
|
||||||
@ -109,13 +110,15 @@ def compact_history(history):
|
|||||||
write_size += history._compact_history(limit)
|
write_size += history._compact_history(limit)
|
||||||
assert write_size != 0
|
assert write_size != 0
|
||||||
|
|
||||||
def run_test(db_dir):
|
async def run_test(db_dir):
|
||||||
environ.clear()
|
environ.clear()
|
||||||
environ['DB_DIRECTORY'] = db_dir
|
environ['DB_DIRECTORY'] = db_dir
|
||||||
environ['DAEMON_URL'] = ''
|
environ['DAEMON_URL'] = ''
|
||||||
environ['COIN'] = 'BitcoinCash'
|
environ['COIN'] = 'BitcoinCash'
|
||||||
env = Env()
|
db = DB(Env())
|
||||||
history = DB(env).history
|
await db.open_for_serving()
|
||||||
|
history = db.history
|
||||||
|
|
||||||
# Test abstract compaction
|
# Test abstract compaction
|
||||||
check_hashX_compaction(history)
|
check_hashX_compaction(history)
|
||||||
# Now test in with random data
|
# Now test in with random data
|
||||||
@ -127,4 +130,5 @@ def run_test(db_dir):
|
|||||||
def test_compaction(tmpdir):
|
def test_compaction(tmpdir):
|
||||||
db_dir = str(tmpdir)
|
db_dir = str(tmpdir)
|
||||||
print('Temp dir: {}'.format(db_dir))
|
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