Merge pull request #765 from bigchaindb/clarify-code-from-pr-629

Rename FulfillmentNotInValidBlock to TransactionNotInValidBlock
This commit is contained in:
Troy McConaghy 2016-11-14 18:53:50 +01:00 committed by GitHub
commit 16fbb47f02
6 changed files with 13 additions and 9 deletions

View File

@ -14,5 +14,6 @@ def generate_key_pair():
private_key, public_key = crypto.ed25519_generate_key_pair() private_key, public_key = crypto.ed25519_generate_key_pair()
return private_key.decode(), public_key.decode() return private_key.decode(), public_key.decode()
SigningKey = crypto.Ed25519SigningKey SigningKey = crypto.Ed25519SigningKey
VerifyingKey = crypto.Ed25519VerifyingKey VerifyingKey = crypto.Ed25519VerifyingKey

View File

@ -69,9 +69,9 @@ class CyclicBlockchainError(Exception):
"""Raised when there is a cycle in the blockchain""" """Raised when there is a cycle in the blockchain"""
class FulfillmentNotInValidBlock(Exception): class TransactionNotInValidBlock(Exception):
"""Raised when a transaction depends on an invalid or undecided """Raised when a transfer transaction is attempting to fulfill the
fulfillment""" conditions of a transaction that is in an invalid or undecided block"""
class AssetIdMismatch(Exception): class AssetIdMismatch(Exception):

View File

@ -186,7 +186,7 @@ class Bigchain(object):
exceptions.TransactionDoesNotExist, exceptions.TransactionDoesNotExist,
exceptions.TransactionOwnerError, exceptions.DoubleSpend, exceptions.TransactionOwnerError, exceptions.DoubleSpend,
exceptions.InvalidHash, exceptions.InvalidSignature, exceptions.InvalidHash, exceptions.InvalidSignature,
exceptions.FulfillmentNotInValidBlock, exceptions.AmountError): exceptions.TransactionNotInValidBlock, exceptions.AmountError):
return False return False
def get_block(self, block_id, include_status=False): def get_block(self, block_id, include_status=False):

View File

@ -2,7 +2,7 @@ from bigchaindb.common.crypto import hash_data, VerifyingKey, SigningKey
from bigchaindb.common.exceptions import (InvalidHash, InvalidSignature, from bigchaindb.common.exceptions import (InvalidHash, InvalidSignature,
OperationError, DoubleSpend, OperationError, DoubleSpend,
TransactionDoesNotExist, TransactionDoesNotExist,
FulfillmentNotInValidBlock, TransactionNotInValidBlock,
AssetIdMismatch, AmountError) AssetIdMismatch, AmountError)
from bigchaindb.common.transaction import Transaction, Asset from bigchaindb.common.transaction import Transaction, Asset
from bigchaindb.common.util import gen_timestamp, serialize from bigchaindb.common.util import gen_timestamp, serialize
@ -24,6 +24,8 @@ class Transaction(Transaction):
OperationError: if the transaction operation is not supported OperationError: if the transaction operation is not supported
TransactionDoesNotExist: if the input of the transaction is not TransactionDoesNotExist: if the input of the transaction is not
found found
TransactionNotInValidBlock: if the input of the transaction is not
in a valid block
TransactionOwnerError: if the new transaction is using an input it TransactionOwnerError: if the new transaction is using an input it
doesn't own doesn't own
DoubleSpend: if the transaction is a double spend DoubleSpend: if the transaction is a double spend
@ -62,7 +64,7 @@ class Transaction(Transaction):
.format(input_txid)) .format(input_txid))
if status != bigchain.TX_VALID: if status != bigchain.TX_VALID:
raise FulfillmentNotInValidBlock( raise TransactionNotInValidBlock(
'input `{}` does not exist in a valid block'.format( 'input `{}` does not exist in a valid block'.format(
input_txid)) input_txid))

View File

@ -111,6 +111,7 @@ class TransactionListApi(Resource):
return tx return tx
transaction_api.add_resource(TransactionApi, transaction_api.add_resource(TransactionApi,
'/transactions/<string:tx_id>', '/transactions/<string:tx_id>',
strict_slashes=False) strict_slashes=False)

View File

@ -701,9 +701,9 @@ class TestTransactionValidation(object):
assert transfer_tx == b.validate_transaction(transfer_tx) assert transfer_tx == b.validate_transaction(transfer_tx)
@pytest.mark.usefixtures('inputs') @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.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_owned_ids(user_vk).pop()
input_tx = b.get_transaction(input_tx.txid) input_tx = b.get_transaction(input_tx.txid)
@ -726,7 +726,7 @@ class TestTransactionValidation(object):
transfer_tx.asset) transfer_tx.asset)
tx_invalid = tx_invalid.sign([user_sk]) tx_invalid = tx_invalid.sign([user_sk])
with pytest.raises(FulfillmentNotInValidBlock): with pytest.raises(TransactionNotInValidBlock):
b.validate_transaction(tx_invalid) b.validate_transaction(tx_invalid)