Adds flake8 and fixes style issues

This commit is contained in:
Sergi Delgado Segura
2020-03-31 11:57:25 +02:00
parent 03c8ad8c87
commit b56123055d
21 changed files with 103 additions and 401 deletions

View File

@@ -9,16 +9,9 @@ from teos.watcher import Watcher
from teos.inspector import Inspector
from teos.db_manager import DBManager
from teos.gatekeeper import Gatekeeper
from teos.chain_monitor import ChainMonitor
from teos.responder import Responder, TransactionTracker
from test.teos.unit.conftest import (
get_random_value_hex,
generate_dummy_appointment,
generate_keypair,
get_config,
bitcoind_feed_params,
)
from test.teos.unit.conftest import get_random_value_hex, generate_dummy_appointment, generate_keypair, get_config
from common.cryptographer import Cryptographer, hash_160
from common.constants import (

View File

@@ -1,6 +1,4 @@
import pytest
from test.teos.unit.conftest import get_random_value_hex, generate_block, generate_blocks, fork, bitcoind_connect_params
from test.teos.unit.conftest import get_random_value_hex, generate_block, generate_blocks, fork
hex_tx = (

View File

@@ -5,7 +5,7 @@ from threading import Thread, Event, Condition
from teos.chain_monitor import ChainMonitor
from test.teos.unit.conftest import get_random_value_hex, generate_block, bitcoind_connect_params, bitcoind_feed_params
from test.teos.unit.conftest import get_random_value_hex, generate_block, bitcoind_feed_params
def test_init(run_bitcoind, block_processor):
@@ -64,8 +64,8 @@ def test_update_state(block_processor):
def test_monitor_chain_polling(db_manager, block_processor):
# Try polling with the Watcher
wq = Queue()
chain_monitor = ChainMonitor(Queue(), Queue(), block_processor, bitcoind_feed_params)
watcher_queue = Queue()
chain_monitor = ChainMonitor(watcher_queue, Queue(), block_processor, bitcoind_feed_params)
chain_monitor.best_tip = block_processor.get_best_block_hash()
chain_monitor.polling_delta = 0.1

View File

@@ -1,7 +1,7 @@
import pytest
from binascii import unhexlify
from teos.errors import *
import teos.errors as errors
from teos import LOG_PREFIX
from teos.block_processor import BlockProcessor
from teos.inspector import Inspector, InspectionFailed
@@ -11,7 +11,7 @@ from common.logger import Logger
from common.appointment import Appointment
from common.constants import LOCATOR_LEN_BYTES, LOCATOR_LEN_HEX
from test.teos.unit.conftest import get_random_value_hex, generate_keypair, bitcoind_connect_params, get_config
from test.teos.unit.conftest import get_random_value_hex, bitcoind_connect_params, get_config
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
@@ -53,7 +53,7 @@ def test_check_locator():
inspector.check_locator(locator)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_SIZE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_SIZE
raise e
# Wrong size (too small)
@@ -63,7 +63,7 @@ def test_check_locator():
inspector.check_locator(locator)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_SIZE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_SIZE
raise e
# Empty
@@ -73,7 +73,7 @@ def test_check_locator():
inspector.check_locator(locator)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e
# Wrong type (several types tested, it should do for anything that is not a string)
@@ -85,7 +85,7 @@ def test_check_locator():
inspector.check_locator(locator)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_TYPE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_TYPE
raise e
# Wrong format (no hex)
@@ -96,7 +96,7 @@ def test_check_locator():
inspector.check_locator(locator)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_FORMAT
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_FORMAT
raise e
@@ -116,7 +116,7 @@ def test_check_start_time():
inspector.check_start_time(start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_FIELD_TOO_SMALL
assert e.erno == errors.APPOINTMENT_FIELD_TOO_SMALL
raise e
# Empty field
@@ -126,7 +126,7 @@ def test_check_start_time():
inspector.check_start_time(start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e
# Wrong data type
@@ -137,7 +137,7 @@ def test_check_start_time():
inspector.check_start_time(start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_TYPE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_TYPE
raise e
@@ -158,7 +158,7 @@ def test_check_end_time():
inspector.check_end_time(end_time, start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_FIELD_TOO_SMALL
assert e.erno == errors.APPOINTMENT_FIELD_TOO_SMALL
raise e
# End time too small (either same height as current block or in the past)
@@ -170,7 +170,7 @@ def test_check_end_time():
inspector.check_end_time(end_time, start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_FIELD_TOO_SMALL
assert e.erno == errors.APPOINTMENT_FIELD_TOO_SMALL
raise e
# Empty field
@@ -180,7 +180,7 @@ def test_check_end_time():
inspector.check_end_time(end_time, start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e
# Wrong data type
@@ -191,7 +191,7 @@ def test_check_end_time():
inspector.check_end_time(end_time, start_time, current_time)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_TYPE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_TYPE
raise e
@@ -209,7 +209,7 @@ def test_check_to_self_delay():
inspector.check_to_self_delay(to_self_delay)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_FIELD_TOO_SMALL
assert e.erno == errors.APPOINTMENT_FIELD_TOO_SMALL
raise e
# Empty field
@@ -219,7 +219,7 @@ def test_check_to_self_delay():
inspector.check_to_self_delay(to_self_delay)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e
# Wrong data type
@@ -230,7 +230,7 @@ def test_check_to_self_delay():
inspector.check_to_self_delay(to_self_delay)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_TYPE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_TYPE
raise e
@@ -251,7 +251,7 @@ def test_check_blob():
inspector.check_blob(encrypted_blob)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_TYPE
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_TYPE
raise e
# Empty field
@@ -261,7 +261,7 @@ def test_check_blob():
inspector.check_blob(encrypted_blob)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e
# Wrong format (no hex)
@@ -272,7 +272,7 @@ def test_check_blob():
inspector.check_blob(encrypted_blob)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_WRONG_FIELD_FORMAT
assert e.erno == errors.APPOINTMENT_WRONG_FIELD_FORMAT
raise e
@@ -313,7 +313,7 @@ def test_inspect_wrong(run_bitcoind):
inspector.inspect(data)
except InspectionFailed as e:
print(data)
assert e.erno == APPOINTMENT_WRONG_FIELD
assert e.erno == errors.APPOINTMENT_WRONG_FIELD
raise e
# None data
@@ -321,5 +321,5 @@ def test_inspect_wrong(run_bitcoind):
try:
inspector.inspect(None)
except InspectionFailed as e:
assert e.erno == APPOINTMENT_EMPTY_FIELD
assert e.erno == errors.APPOINTMENT_EMPTY_FIELD
raise e