diff --git a/bigchaindb/common/exceptions.py b/bigchaindb/common/exceptions.py index 2e1dc670..72e300fd 100644 --- a/bigchaindb/common/exceptions.py +++ b/bigchaindb/common/exceptions.py @@ -69,9 +69,9 @@ class CyclicBlockchainError(Exception): """Raised when there is a cycle in the blockchain""" -class FulfillmentNotInValidBlock(Exception): - """Raised when a transaction depends on an invalid or undecided - fulfillment""" +class TransactionNotInValidBlock(Exception): + """Raised when a transfer transaction is attempting to fulfill the + conditions of a transaction that is in an invalid or undecided block""" class AssetIdMismatch(Exception): diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 83b85652..a5ec25e0 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -183,7 +183,7 @@ class Bigchain(object): except (ValueError, exceptions.OperationError, exceptions.TransactionDoesNotExist, exceptions.TransactionOwnerError, exceptions.DoubleSpend, exceptions.InvalidHash, exceptions.InvalidSignature, - exceptions.FulfillmentNotInValidBlock): + exceptions.TransactionNotInValidBlock): return False def get_transaction(self, txid, include_status=False): diff --git a/bigchaindb/models.py b/bigchaindb/models.py index 1334b2de..87ea57bb 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -2,7 +2,7 @@ from bigchaindb.common.crypto import hash_data, VerifyingKey, SigningKey from bigchaindb.common.exceptions import (InvalidHash, InvalidSignature, OperationError, DoubleSpend, TransactionDoesNotExist, - FulfillmentNotInValidBlock, + TransactionNotInValidBlock, AssetIdMismatch) from bigchaindb.common.transaction import Transaction, Asset from bigchaindb.common.util import gen_timestamp, serialize @@ -54,6 +54,8 @@ class Transaction(Transaction): OperationError: if the transaction operation is not supported TransactionDoesNotExist: if the input of the transaction is not found + TransactionNotInValidBlock: if the input of the transaction is not + in a valid block TransactionOwnerError: if the new transaction is using an input it doesn't own DoubleSpend: if the transaction is a double spend @@ -90,7 +92,7 @@ class Transaction(Transaction): .format(input_txid)) if status != bigchain.TX_VALID: - raise FulfillmentNotInValidBlock( + raise TransactionNotInValidBlock( 'input `{}` does not exist in a valid block'.format( input_txid)) diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index f0a88c44..b52dd3a7 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -650,9 +650,9 @@ class TestTransactionValidation(object): assert transfer_tx == b.validate_transaction(transfer_tx) @pytest.mark.usefixtures('inputs') - def test_fulfillment_not_in_valid_block(self, b, user_vk, user_sk): + def test_transaction_not_in_valid_block(self, b, user_vk, user_sk): from bigchaindb.models import Transaction - from bigchaindb.common.exceptions import FulfillmentNotInValidBlock + from bigchaindb.common.exceptions import TransactionNotInValidBlock input_tx = b.get_owned_ids(user_vk).pop() input_tx = b.get_transaction(input_tx.txid) @@ -673,7 +673,7 @@ class TestTransactionValidation(object): transfer_tx.asset) tx_invalid = tx_invalid.sign([user_sk]) - with pytest.raises(FulfillmentNotInValidBlock): + with pytest.raises(TransactionNotInValidBlock): b.validate_transaction(tx_invalid)