diff --git a/bigchaindb/voting.py b/bigchaindb/voting.py index 21ce8195..f8511644 100644 --- a/bigchaindb/voting.py +++ b/bigchaindb/voting.py @@ -1,4 +1,5 @@ import collections +from bigchaindb.backend.exceptions import BigchainDBCritical from bigchaindb.common.schema import SchemaValidationError, validate_vote_schema from bigchaindb.common.utils import serialize from bigchaindb.common.crypto import PublicKey @@ -126,7 +127,7 @@ class Voting: # Check insane cases. This is basic, not exhaustive. if n_valid + n_invalid > n_voters or n_agree_prev_block > n_voters: - raise ValueError('Arguments not sane: %s' % { + raise BigchainDBCritical('Arguments not sane: %s' % { 'n_voters': n_voters, 'n_valid': n_valid, 'n_invalid': n_invalid, diff --git a/tests/test_voting.py b/tests/test_voting.py index cea34de0..13822d6d 100644 --- a/tests/test_voting.py +++ b/tests/test_voting.py @@ -1,6 +1,6 @@ import pytest -from unittest.mock import patch +from bigchaindb.backend.exceptions import BigchainDBCritical from bigchaindb.core import Bigchain from bigchaindb.voting import Voting, INVALID, VALID, UNDECIDED @@ -95,13 +95,13 @@ def test_decide_votes_invalid(kwargs): def test_decide_votes_checks_arguments(): - with pytest.raises(ValueError): + with pytest.raises(BigchainDBCritical): Voting.decide_votes(n_voters=1, n_valid=2, n_invalid=0, n_agree_prev_block=0) - with pytest.raises(ValueError): + with pytest.raises(BigchainDBCritical): Voting.decide_votes(n_voters=1, n_valid=0, n_invalid=2, n_agree_prev_block=0) - with pytest.raises(ValueError): + with pytest.raises(BigchainDBCritical): Voting.decide_votes(n_voters=1, n_valid=0, n_invalid=0, n_agree_prev_block=2)