diff --git a/pisa-btc/pisa/inspector.py b/pisa-btc/pisa/inspector.py index 6388a89..f541dd2 100644 --- a/pisa-btc/pisa/inspector.py +++ b/pisa-btc/pisa/inspector.py @@ -31,7 +31,7 @@ class Inspector: if rcode == 0: rcode, message = self.check_end_time(end_time, start_time, block_height) if rcode == 0: - rcode, message = self.check_delta(dispute_delta, start_time, end_time) + rcode, message = self.check_delta(dispute_delta) if rcode == 0: rcode, message = self.check_blob(encrypted_blob) if rcode == 0: @@ -40,8 +40,7 @@ class Inspector: rcode, message = self.check_hash_function(hash_function) if rcode == 0: - r = Appointment(locator, start_time, end_time, dispute_delta, encrypted_blob, cipher, - hash_function) + r = Appointment(locator, start_time, end_time, dispute_delta, encrypted_blob, cipher, hash_function) else: r = (rcode, message) @@ -124,12 +123,11 @@ class Inspector: return rcode, message - def check_delta(self, dispute_delta, start_time, end_time): + def check_delta(self, dispute_delta): message = None rcode = 0 t = type(dispute_delta) - delta = end_time - start_time if dispute_delta is None: rcode = errors.APPOINTMENT_EMPTY_FIELD @@ -137,15 +135,10 @@ class Inspector: elif t != int: rcode = errors.APPOINTMENT_WRONG_FIELD_TYPE message = "wrong dispute_delta data type ({})".format(t) - elif end_time - start_time < dispute_delta: - rcode = errors.APPOINTMENT_FIELD_TOO_BIG - message = "wrong dispute_delta provided ({} > {})".format(dispute_delta, delta) - elif end_time - start_time > dispute_delta: - rcode = errors.APPOINTMENT_FIELD_TOO_SMALL - message = "wrong dispute_delta provided ({} < {})".format(dispute_delta, delta) elif dispute_delta < MIN_DISPUTE_DELTA: rcode = errors.APPOINTMENT_FIELD_TOO_SMALL - message = "dispute delta too small ({} < {})".format(dispute_delta, MIN_DISPUTE_DELTA) + message = "dispute delta too small. The dispute delta should be at least {} (current: {})".format( + MIN_DISPUTE_DELTA, dispute_delta) if self.debug and message: self.logging.error("[Inspector] {}".format(message)) diff --git a/pisa-btc/tests/appointment_tests.py b/pisa-btc/tests/appointment_tests.py index a643de5..43eb520 100644 --- a/pisa-btc/tests/appointment_tests.py +++ b/pisa-btc/tests/appointment_tests.py @@ -25,7 +25,7 @@ except JSONRPCException as e: locators = [None, 0, 'A' * 31, "A" * 63 + "_"] start_times = [None, 0, '', 15.0, block_height - 10] end_times = [None, 0, '', 26.123, block_height - 11] -dispute_deltas = [None, 0, '', 1.2, 30, -3] +dispute_deltas = [None, 0, '', 1.2, -3, 30] encrypted_blobs = [None, 0, ''] ciphers = [None, 0, '', 'foo'] hash_functions = [None, 0, '', 'foo'] @@ -43,7 +43,7 @@ end_time_rets = [errors.APPOINTMENT_EMPTY_FIELD, errors.APPOINTMENT_FIELD_TOO_SM dispute_delta_rets = [errors.APPOINTMENT_EMPTY_FIELD, errors.APPOINTMENT_FIELD_TOO_SMALL, errors.APPOINTMENT_WRONG_FIELD_TYPE, errors.APPOINTMENT_WRONG_FIELD_TYPE, - errors.APPOINTMENT_FIELD_TOO_BIG, errors.APPOINTMENT_FIELD_TOO_SMALL] + errors.APPOINTMENT_FIELD_TOO_SMALL] encrypted_blob_rets = [errors.APPOINTMENT_EMPTY_FIELD, errors.APPOINTMENT_WRONG_FIELD_TYPE, errors.APPOINTMENT_WRONG_FIELD]