fix test, log tx validation errors and document ValidationError

This commit is contained in:
Scott Sadler
2017-03-03 11:52:12 +01:00
parent 5584de59b0
commit 59e21bfa4d
4 changed files with 9 additions and 5 deletions

View File

@@ -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):

View File

@@ -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

View File

@@ -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

View File

@@ -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