diff --git a/bigchaindb/common/exceptions.py b/bigchaindb/common/exceptions.py index 4b95f84b..76513010 100644 --- a/bigchaindb/common/exceptions.py +++ b/bigchaindb/common/exceptions.py @@ -42,6 +42,11 @@ class OperationError(BigchainDBError): ################################################################################ # Validation errors +# +# All validation errors (which are handleable errors, not faults) should +# subclass ValidationError. However, where possible they should also have their +# own distinct type to differentiate them from other validation errors, +# especially for the purposes of testing. class ValidationError(BigchainDBError): diff --git a/bigchaindb/pipelines/block.py b/bigchaindb/pipelines/block.py index 2a43686a..b1d6cdee 100644 --- a/bigchaindb/pipelines/block.py +++ b/bigchaindb/pipelines/block.py @@ -76,7 +76,7 @@ class BlockPipeline: tx.validate(self.bigchain) return tx except ValidationError as e: - # todo: log + logger.warning('Invalid tx: %s' % e) self.bigchain.delete_transaction(tx.id) return None diff --git a/bigchaindb/pipelines/vote.py b/bigchaindb/pipelines/vote.py index 088c4eac..0431e20b 100644 --- a/bigchaindb/pipelines/vote.py +++ b/bigchaindb/pipelines/vote.py @@ -108,8 +108,8 @@ class Vote: try: tx.validate(self.bigchain) valid = True - except exceptions.ValidationError: - # TODO: log + except exceptions.ValidationError as e: + logger.warning('Invalid tx: %s' % e) valid = False return valid, block_id, num_tx diff --git a/tests/pipelines/test_vote.py b/tests/pipelines/test_vote.py index aaa184f0..fa167d17 100644 --- a/tests/pipelines/test_vote.py +++ b/tests/pipelines/test_vote.py @@ -128,7 +128,7 @@ def test_validate_block_with_invalid_signature(b): @pytest.mark.genesis def test_vote_validate_transaction(b): from bigchaindb.pipelines import vote - from bigchaindb.models import Transaction + from bigchaindb.common.exceptions import ValidationError tx = dummy_tx(b) vote_obj = vote.Vote() @@ -147,7 +147,6 @@ def test_vote_validate_transaction(b): validation = vote_obj.validate_tx(tx, 456, 10) - @pytest.mark.genesis def test_vote_accumulates_transactions(b): from bigchaindb.pipelines import vote