mirror of
https://github.com/aljazceru/python-teos.git
synced 2026-02-01 12:44:25 +01:00
Fixes and tests updates
Updates tests so they run with the db_manager and fixes some bugs introduced in d7d42c9.
This commit is contained in:
@@ -5,7 +5,6 @@ from binascii import hexlify
|
||||
|
||||
from pisa import HOST, PORT, logging
|
||||
from pisa.logger import Logger
|
||||
from pisa.watcher import Watcher
|
||||
from pisa.inspector import Inspector
|
||||
from pisa.appointment import Appointment
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
@@ -14,6 +14,7 @@ class Appointment:
|
||||
self.encrypted_blob = EncryptedBlob(encrypted_blob)
|
||||
self.cipher = cipher
|
||||
self.hash_function = hash_function
|
||||
self.triggered = False
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, appointment_data):
|
||||
|
||||
@@ -44,5 +44,5 @@ class Cleaner:
|
||||
tx_job_map[justice_txid].remove(uuid)
|
||||
|
||||
# Delete appointment from the db (both watchers's and responder's)
|
||||
db_manager.ddelete_watcher_appointment(uuid)
|
||||
db_manager.delete_watcher_appointment(uuid)
|
||||
db_manager.delete_responder_job(uuid)
|
||||
|
||||
@@ -108,7 +108,7 @@ class Responder:
|
||||
if confirmations == 0:
|
||||
self.unconfirmed_txs.append(justice_txid)
|
||||
|
||||
self.db_manager.store_responder_job(uuid.encode, job.to_json())
|
||||
self.db_manager.store_responder_job(uuid, job.to_json())
|
||||
|
||||
logger.info("New job added.", dispute_txid=dispute_txid, justice_txid=justice_txid,
|
||||
appointment_end=appointment_end)
|
||||
@@ -151,7 +151,7 @@ class Responder:
|
||||
completed_jobs = self.get_completed_jobs(height)
|
||||
|
||||
Cleaner.delete_completed_jobs(self.jobs, self.tx_job_map, completed_jobs, height, self.db_manager)
|
||||
self.rebroadcast(txs_to_rebroadcast)
|
||||
self.rebroadcast(txs_to_rebroadcast, block_hash)
|
||||
|
||||
# NOTCOVERED
|
||||
else:
|
||||
@@ -199,7 +199,7 @@ class Responder:
|
||||
|
||||
return completed_jobs
|
||||
|
||||
def rebroadcast(self, txs_to_rebroadcast):
|
||||
def rebroadcast(self, txs_to_rebroadcast, block_hash):
|
||||
# DISCUSS: #22-discuss-confirmations-before-retry
|
||||
# ToDo: #23-define-behaviour-approaching-end
|
||||
|
||||
@@ -211,7 +211,7 @@ class Responder:
|
||||
for uuid in self.tx_job_map[txid]:
|
||||
job = self.jobs[uuid]
|
||||
receipt = self.add_response(uuid, job.dispute_txid, job.justice_txid, job.justice_rawtx,
|
||||
job.appointment_end, retry=True)
|
||||
job.appointment_end, block_hash, retry=True)
|
||||
|
||||
logger.warning("Transaction has missed many confirmations. Rebroadcasting.",
|
||||
justice_txid=job.justice_txid, confirmations_missed=CONFIRMATIONS_BEFORE_RETRY)
|
||||
|
||||
@@ -137,7 +137,7 @@ class Watcher:
|
||||
# DISCUSS: instead of deleting the appointment, we will mark it as triggered and delete it from both
|
||||
# the watcher's and responder's db after fulfilled
|
||||
# Update appointment in the db
|
||||
appointment["triggered"] = True
|
||||
appointment.triggered = True
|
||||
self.db_manager.store_watcher_appointment(uuid, appointment.to_json())
|
||||
|
||||
# Register the last processed block for the watcher
|
||||
|
||||
Reference in New Issue
Block a user