Apply requested changes

- Adds a PRG based on a hardcoded seed to make the tests reproducible (get_random_value_hex)
- Updates all the tests replacing urandom for get_random_value_hex
- Properly places misplaced bitcoin_cli in bitcoin_sim_tests
- Typos
This commit is contained in:
Sergi Delgado Segura
2019-10-23 12:40:25 +01:00
parent af0e9c81b5
commit 52f52f57f8
12 changed files with 71 additions and 60 deletions

View File

@@ -1,4 +1,5 @@
import pytest
import random
import requests
from time import sleep
from threading import Thread
@@ -27,6 +28,17 @@ def run_api():
sleep(0.1)
@pytest.fixture(scope='session', autouse=True)
def prng_seed():
random.seed(0)
def get_random_value_hex(nbytes):
pseudo_random_value = random.getrandbits(8*nbytes)
prv_hex = '{:x}'.format(pseudo_random_value)
return prv_hex.zfill(2*nbytes)
def generate_block():
requests.post(url="http://{}:{}/generate".format(HOST, PORT), timeout=5)
sleep(0.5)