Adds first test of dealing with pisa with a reboot in the middle

This commit is contained in:
Sergi Delgado Segura
2020-01-24 13:40:08 +01:00
parent d29568e2d7
commit 5d068f5ecc

View File

@@ -209,3 +209,44 @@ def test_two_appointment_same_locator_different_penalty(bitcoin_cli, create_txs)
assert len(appointment_info) == 1
assert appointment_info[0].get("status") == "dispute_responded"
assert appointment_info[0].get("penalty_rawtx") == penalty_tx1
def test_appointment_shutdown_pisa(create_txs, bitcoin_cli):
global pisad_process
pisa_pid = pisad_process.pid
commitment_tx, penalty_tx = create_txs
commitment_tx_id = bitcoin_cli.decoderawtransaction(commitment_tx).get("txid")
appointment_data = build_appointment_data(bitcoin_cli, commitment_tx_id, penalty_tx)
locator = compute_locator(commitment_tx_id)
assert pisa_cli.add_appointment([json.dumps(appointment_data)]) is True
sleep(2)
# Restart pisa
pisad_process.terminate()
pisad_process = run_pisad()
assert pisa_pid != pisad_process.pid
# Check that the appointment is still in the Watcher
appointment_info = get_appointment_info(locator)
assert appointment_info is not None
assert len(appointment_info) == 1
assert appointment_info[0].get("status") == "being_watched"
# Trigger appointment after restart
new_addr = bitcoin_cli.getnewaddress()
broadcast_transaction_and_mine_block(bitcoin_cli, commitment_tx, new_addr)
# The appointment should have been removed since the penalty_tx was malformed.
sleep(1)
appointment_info = get_appointment_info(locator)
assert appointment_info is not None
assert len(appointment_info) == 1
assert appointment_info[0].get("status") == "dispute_responded"
pisad_process.terminate()