mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
fix test, log tx validation errors and document ValidationError
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user