diff --git a/test/unit/test_watcher.py b/test/unit/test_watcher.py index 2c1e11f..ce693fb 100644 --- a/test/unit/test_watcher.py +++ b/test/unit/test_watcher.py @@ -81,6 +81,15 @@ def test_init(watcher): assert type(watcher.responder) is Responder +def test_init_no_key(db_manager): + try: + Watcher(db_manager, pisa_sk_file=None) + assert False + + except ValueError: + assert True + + def test_add_appointment(run_bitcoind, watcher): # The watcher automatically fires do_watch and do_subscribe on adding an appointment if it is asleep (initial state) # Avoid this by setting the state to awake. @@ -96,6 +105,12 @@ def test_add_appointment(run_bitcoind, watcher): assert added_appointment is True assert is_signature_valid(appointment, sig, public_key) + # Check that we can also add an already added appointment (same locator) + added_appointment, sig = watcher.add_appointment(appointment) + + assert added_appointment is True + assert is_signature_valid(appointment, sig, public_key) + def test_sign_appointment(watcher): appointment, _ = generate_dummy_appointment(start_time_offset=START_TIME_OFFSET, end_time_offset=END_TIME_OFFSET)