Addapts tests to match 7031b552f7. Improves DBManager tests.

This commit is contained in:
Sergi Delgado Segura
2020-04-01 17:19:41 +02:00
parent 7031b552f7
commit 4a3f4bc522
8 changed files with 449 additions and 425 deletions

View File

@@ -9,8 +9,8 @@ from threading import Thread
from teos.carrier import Carrier
from teos.tools import bitcoin_cli
from teos.db_manager import DBManager
from teos.chain_monitor import ChainMonitor
from teos.appointments_dbm import AppointmentsDBM
from teos.responder import Responder, TransactionTracker
from common.constants import LOCATOR_LEN_HEX
@@ -36,7 +36,7 @@ def responder(db_manager, carrier, block_processor):
@pytest.fixture(scope="session")
def temp_db_manager():
db_name = get_random_value_hex(8)
db_manager = DBManager(db_name)
db_manager = AppointmentsDBM(db_name)
yield db_manager
@@ -120,17 +120,6 @@ def test_tracker_to_dict():
)
def test_tracker_to_json():
tracker = create_dummy_tracker()
tracker_dict = json.loads(tracker.to_json())
assert (
tracker.locator == tracker_dict["locator"]
and tracker.penalty_rawtx == tracker_dict["penalty_rawtx"]
and tracker.appointment_end == tracker_dict["appointment_end"]
)
def test_tracker_from_dict():
tracker_dict = create_dummy_tracker().to_dict()
new_tracker = TransactionTracker.from_dict(tracker_dict)
@@ -295,7 +284,7 @@ def test_do_watch(temp_db_manager, carrier, block_processor):
# We also need to store the info in the db
responder.db_manager.create_triggered_appointment_flag(uuid)
responder.db_manager.store_responder_tracker(uuid, tracker.to_json())
responder.db_manager.store_responder_tracker(uuid, tracker.to_dict())
# Let's start to watch
Thread(target=responder.do_watch, daemon=True).start()
@@ -472,7 +461,7 @@ def test_rebroadcast(db_manager, carrier, block_processor):
# We need to add it to the db too
responder.db_manager.create_triggered_appointment_flag(uuid)
responder.db_manager.store_responder_tracker(uuid, tracker.to_json())
responder.db_manager.store_responder_tracker(uuid, tracker.to_dict())
responder.tx_tracker_map[penalty_txid] = [uuid]
responder.unconfirmed_txs.append(penalty_txid)