diff --git a/pisa/appointment.py b/pisa/appointment.py index d4e3c38..9cf7b5f 100644 --- a/pisa/appointment.py +++ b/pisa/appointment.py @@ -28,13 +28,13 @@ class Appointment: hash_function = appointment_data.get("hash_function") triggered = appointment_data.get("triggered") - if all(v is not None for v in [locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, - hash_function, triggered]): - appointment = cls(locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, - hash_function, triggered) + if any(v is None for v in [locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, + hash_function, triggered]): + raise ValueError("Wrong appointment data, some fields are missing") else: - raise ValueError("Wrong appointment data, some fields are missing") + appointment = cls(locator, start_time, end_time, dispute_delta, encrypted_blob_data, cipher, hash_function, + triggered) return appointment diff --git a/pisa/db_manager.py b/pisa/db_manager.py index 500756b..1fddebd 100644 --- a/pisa/db_manager.py +++ b/pisa/db_manager.py @@ -2,11 +2,15 @@ import json import plyvel from pisa.logger import Logger -from pisa.conf import WATCHER_PREFIX, RESPONDER_PREFIX, WATCHER_LAST_BLOCK_KEY, RESPONDER_LAST_BLOCK_KEY, \ - LOCATOR_MAP_PREFIX logger = Logger("DBManager") +WATCHER_PREFIX = "w" +WATCHER_LAST_BLOCK_KEY = "bw" +RESPONDER_PREFIX = "r" +RESPONDER_LAST_BLOCK_KEY = "br" +LOCATOR_MAP_PREFIX = 'm' + class DBManager: def __init__(self, db_path): diff --git a/pisa/responder.py b/pisa/responder.py index d0efbb9..aa8524e 100644 --- a/pisa/responder.py +++ b/pisa/responder.py @@ -35,11 +35,11 @@ class Job: justice_rawtx = job_data.get("justice_rawtx") appointment_end = job_data.get("appointment_end") - if all(v is not None for v in [dispute_txid, justice_txid, justice_rawtx, appointment_end]): - job = cls(dispute_txid, justice_txid, justice_rawtx, appointment_end) + if any(v is None for v in [dispute_txid, justice_txid, justice_rawtx, appointment_end]): + raise ValueError("Wrong job data, some fields are missing") else: - raise ValueError("Wrong job data, some fields are missing") + job = cls(dispute_txid, justice_txid, justice_rawtx, appointment_end) return job diff --git a/pisa/sample_conf.py b/pisa/sample_conf.py index c1d14c4..61bfa59 100644 --- a/pisa/sample_conf.py +++ b/pisa/sample_conf.py @@ -29,8 +29,3 @@ SUPPORTED_CIPHERS = ["AES-GCM-128"] # LEVELDB DB_PATH = "appointments" -WATCHER_PREFIX = "w" -WATCHER_LAST_BLOCK_KEY = "bw" -RESPONDER_PREFIX = "r" -RESPONDER_LAST_BLOCK_KEY = "br" -LOCATOR_MAP_PREFIX = 'm' diff --git a/test/unit/test_db_manager.py b/test/unit/test_db_manager.py index 35cf6ed..54f37cc 100644 --- a/test/unit/test_db_manager.py +++ b/test/unit/test_db_manager.py @@ -6,7 +6,7 @@ from uuid import uuid4 from pisa.db_manager import DBManager from test.unit.conftest import get_random_value_hex, generate_dummy_appointment -from pisa.conf import WATCHER_LAST_BLOCK_KEY, RESPONDER_LAST_BLOCK_KEY, LOCATOR_MAP_PREFIX +from pisa.db_manager import WATCHER_LAST_BLOCK_KEY, RESPONDER_LAST_BLOCK_KEY, LOCATOR_MAP_PREFIX @pytest.fixture(scope='module') @@ -255,25 +255,3 @@ def test_store_load_last_block_hash_responder(db_manager): - - - - - - - - - - - - - - - - - - - - - -