Fixes test to work with session fixtures

Test were running fine standalone but failing / having Address reuse issues when running all together. Fixing that.
This commit is contained in:
Sergi Delgado Segura
2019-10-14 13:00:21 +01:00
parent e5ab943f8c
commit abe359f7d1
5 changed files with 11 additions and 84 deletions

View File

@@ -1,34 +1,21 @@
import pytest
from time import sleep
from os import urandom
from uuid import uuid4
from hashlib import sha256
from threading import Thread
from binascii import unhexlify
from pisa.block_processor import BlockProcessor
from test.simulator.bitcoind_sim import run_simulator
APPOINTMENT_COUNT = 100
TEST_SET_SIZE = 200
@pytest.fixture(autouse=True, scope='session')
def run_bitcoind():
bitcoind_thread = Thread(target=run_simulator)
bitcoind_thread.daemon = True
bitcoind_thread.start()
# It takes a little bit of time to start the API (otherwise the requests are sent too early and they fail)
sleep(0.1)
@pytest.fixture(scope='session')
@pytest.fixture(scope='module')
def txids():
return [urandom(32).hex() for _ in range(APPOINTMENT_COUNT)]
@pytest.fixture(scope='session')
@pytest.fixture(scope='module')
def locator_uuid_map(txids):
return {sha256(unhexlify(txid)).hexdigest(): uuid4().hex for txid in txids}