Applies fixes after PR review

This commit is contained in:
Sergi Delgado Segura
2019-11-07 10:31:44 +00:00
parent 00a27b68e6
commit 99bda73eff
5 changed files with 15 additions and 38 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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

View File

@@ -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'

View File

@@ -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):