mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Updates conftest fixtures so they do not autorun
The modules that need to run either bitcoind or the api do now reference to the fixture in the first test that needs it. Since the fixtures are definexd session-wise the rest of the modules will have access to them from that point on.
This commit is contained in:
@@ -9,10 +9,10 @@ from test.simulator.bitcoind_sim import run_simulator
|
||||
bitcoind_process = Process(target=run_simulator)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope='session')
|
||||
@pytest.fixture(scope='session')
|
||||
def run_bitcoind():
|
||||
global bitcoind_process
|
||||
|
||||
|
||||
bitcoind_process.daemon = True
|
||||
bitcoind_process.start()
|
||||
|
||||
@@ -20,7 +20,7 @@ def run_bitcoind():
|
||||
sleep(0.1)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope='session')
|
||||
@pytest.fixture(scope='session')
|
||||
def run_api():
|
||||
api_thread = Thread(target=start_api)
|
||||
api_thread.daemon = True
|
||||
|
||||
@@ -70,7 +70,7 @@ def add_appointment(appointment):
|
||||
return r
|
||||
|
||||
|
||||
def test_add_appointment(new_appointment):
|
||||
def test_add_appointment(run_api, run_bitcoind, new_appointment):
|
||||
# Properly formatted appointment
|
||||
r = add_appointment(new_appointment)
|
||||
assert (r.status_code == 200)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import logging
|
||||
from os import urandom
|
||||
from uuid import uuid4
|
||||
from hashlib import sha256
|
||||
@@ -6,6 +7,8 @@ from binascii import unhexlify
|
||||
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
logging.getLogger().disabled = True
|
||||
|
||||
APPOINTMENT_COUNT = 100
|
||||
TEST_SET_SIZE = 200
|
||||
|
||||
@@ -25,7 +28,7 @@ def best_block_hash():
|
||||
return BlockProcessor.get_best_block_hash()
|
||||
|
||||
|
||||
def test_get_best_block_hash(best_block_hash):
|
||||
def test_get_best_block_hash(run_bitcoind, best_block_hash):
|
||||
# As long as bitcoind is running (or mocked in this case) we should always a block hash
|
||||
assert best_block_hash is not None and isinstance(best_block_hash, str)
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import logging
|
||||
from os import urandom
|
||||
from time import sleep
|
||||
|
||||
@@ -6,6 +7,8 @@ from pisa.carrier import Carrier
|
||||
from pisa.rpc_errors import RPC_VERIFY_ALREADY_IN_CHAIN, RPC_DESERIALIZATION_ERROR
|
||||
from test.simulator.bitcoind_sim import TIME_BETWEEN_BLOCKS
|
||||
|
||||
logging.getLogger().disabled = True
|
||||
|
||||
# FIXME: This test do not fully cover the carrier since the simulator does not support every single error bitcoind may
|
||||
# return for RPC_VERIFY_REJECTED and RPC_VERIFY_ERROR. Further development of the simulator / mocks or simulation
|
||||
# with bitcoind is required
|
||||
@@ -19,7 +22,7 @@ def carrier():
|
||||
return Carrier()
|
||||
|
||||
|
||||
def test_send_transaction(carrier):
|
||||
def test_send_transaction(run_bitcoind, carrier):
|
||||
# We are mocking bitcoind and in our simulator txid == tx
|
||||
tx = urandom(32).hex()
|
||||
receipt = carrier.send_transaction(tx, tx)
|
||||
|
||||
@@ -188,7 +188,7 @@ def test_check_hash_function():
|
||||
assert (Inspector.check_hash_function(hash_function)[0] == APPOINTMENT_EMPTY_FIELD)
|
||||
|
||||
|
||||
def test_inspect():
|
||||
def test_inspect(run_bitcoind):
|
||||
# At this point every single check function has been already tested, let's test inspect with an invalid and a valid
|
||||
# appointments.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from pisa.tools import can_connect_to_bitcoind, in_correct_network
|
||||
logging.getLogger().disabled = True
|
||||
|
||||
|
||||
def test_in_correct_network():
|
||||
def test_in_correct_network(run_bitcoind):
|
||||
# The simulator runs as if it was regtest, so every other network should fail
|
||||
assert in_correct_network('mainnet') is False
|
||||
assert in_correct_network('testnet') is False
|
||||
|
||||
Reference in New Issue
Block a user