def test_get_missed_blocks_bitcoind_crash(block_processor, block_processor_wrong_connection): run_test_command_bitcoind_crash( lambda: block_processor_wrong_connection.get_missed_blocks(get_random_value_hex(32)) ) run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.get_missed_blocks(get_random_value_hex(32), blocking=True), )
def test_send_transaction_bitcoind_crash(carrier): # Trying to send a transaction if bitcoind is unreachable should block the thread until it becomes reachable again tx = create_commitment_tx() txid = bitcoin_cli.decoderawtransaction(tx).get("txid") run_test_blocking_command_bitcoind_crash( carrier.bitcoind_reachable, lambda: carrier.send_transaction(tx, txid), )
def test_fix_cache_bitcoind_crash(block_processor): # A real BlockProcessor is required to test blocking functionality, since the mock does not implement that stuff locator_cache = LocatorCache(config.get("LOCATOR_CACHE_SIZE")) run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: locator_cache.fix(block_processor.get_best_block_hash(), block_processor), )
def test_find_last_common_ancestor_bitcoind_crash(block_processor, block_processor_wrong_connection): run_test_command_bitcoind_crash( lambda: block_processor_wrong_connection.find_last_common_ancestor(get_random_value_hex(32)) ) best_block_hash = block_processor.get_best_block_hash() run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.find_last_common_ancestor(best_block_hash, blocking=True), )
def test_is_block_in_best_chain_bitcoind_crash(block_processor, block_processor_wrong_connection): run_test_command_bitcoind_crash( lambda: block_processor_wrong_connection.is_block_in_best_chain(get_random_value_hex(32)) ) best_block_hash = block_processor.get_best_block_hash() run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.is_block_in_best_chain(best_block_hash, blocking=True), )
def test_check_breach_bitcoind_crash(watcher, block_processor, generate_dummy_appointment_w_trigger, monkeypatch): uuid = uuid4().hex appointment, dispute_txid = generate_dummy_appointment_w_trigger() # A real BlockProcessor is required to test blocking functionality, since the mock does not implement that stuff # We also need to mock decoding the transaction given we're using dummy data watcher.block_processor = block_processor monkeypatch.setattr(block_processor, "decode_raw_transaction", lambda x, blocking: {}) run_test_blocking_command_bitcoind_crash( watcher.block_processor.bitcoind_reachable, lambda: watcher.check_breach(uuid, appointment, dispute_txid))
def test_decode_raw_transaction_bitcoind_crash(block_processor, block_processor_wrong_connection): run_test_command_bitcoind_crash(lambda: block_processor_wrong_connection.decode_raw_transaction(hex_tx)) run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.decode_raw_transaction(hex_tx, blocking=True) )
def test_get_block_count_bitcoind_crash(block_processor, block_processor_wrong_connection): run_test_command_bitcoind_crash(lambda: block_processor_wrong_connection.get_block_count()) run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.get_block_count(blocking=True) )
def test_get_block_bitcoind_crash(block_processor, block_processor_wrong_connection): block_id = get_random_value_hex(32) run_test_command_bitcoind_crash(lambda: block_processor_wrong_connection.get_block(block_id)) run_test_blocking_command_bitcoind_crash( block_processor.bitcoind_reachable, lambda: block_processor.get_block(block_id, blocking=True) )
def test_get_transaction_bitcoind_crash(carrier): # Trying to get a transaction if bitcoind is unreachable should block the thread until it becomes reachable again run_test_blocking_command_bitcoind_crash( carrier.bitcoind_reachable, lambda: carrier.get_transaction(get_random_value_hex(32)), )
def test_on_sync_bitcoind_crash(responder, block_processor): responder.block_processor = block_processor chain_tip = responder.block_processor.get_best_block_hash() run_test_blocking_command_bitcoind_crash( responder.block_processor.bitcoind_reachable, lambda: responder.on_sync(chain_tip))