diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index 82281a8f..0862bd22 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -107,6 +107,25 @@ class TestBigchainApi(object): response = b.get_transaction(tx_signed["id"]) assert util.serialize(tx_signed) == util.serialize(response) + @pytest.mark.usefixtures('inputs') + def test_read_transaction_invalid_block(self, b, user_vk, user_sk): + input_tx = b.get_owned_ids(user_vk).pop() + tx = b.create_transaction(user_vk, user_vk, input_tx, 'TRANSFER') + tx_signed = b.sign_transaction(tx, user_sk) + b.write_transaction(tx_signed) + + # create block + block = b.create_block([tx_signed]) + b.write_block(block, durability='hard') + + # vote the block invalid + vote = b.vote(block, b.get_last_voted_block()['id'], False) + b.write_vote(block, vote, 2) + response = b.get_transaction(tx_signed["id"]) + + # should be None, because invalid blocks are ignored + assert response is None + @pytest.mark.usefixtures('inputs') def test_assign_transaction_one_node(self, b, user_vk, user_sk): input_tx = b.get_owned_ids(user_vk).pop()