From ac680cf5e98bd7160e927a8ea6aebd01579c1da9 Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Tue, 28 Jun 2016 14:19:07 +0200 Subject: [PATCH] Test consensus (#398) * Remove unused import * Simplify and group the imports * Add extra space (pep 8) * Remove NotImplementedError the class BaseConsensusRules implements verify_vote_signature * Add test module for consensus module --- bigchaindb/consensus.py | 7 ++----- tests/test_consensus.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 tests/test_consensus.py diff --git a/bigchaindb/consensus.py b/bigchaindb/consensus.py index 5317868a..1723b74c 100644 --- a/bigchaindb/consensus.py +++ b/bigchaindb/consensus.py @@ -1,9 +1,6 @@ -import copy from abc import ABCMeta, abstractmethod -import bigchaindb.exceptions as exceptions -from bigchaindb import util -from bigchaindb import crypto +from bigchaindb import crypto, exceptions, util class AbstractConsensusRules(metaclass=ABCMeta): @@ -101,7 +98,7 @@ class AbstractConsensusRules(metaclass=ABCMeta): bool: True if the votes's required signature data is present and correct, False otherwise. """ - raise NotImplementedError + class BaseConsensusRules(AbstractConsensusRules): """Base consensus rules for Bigchain. diff --git a/tests/test_consensus.py b/tests/test_consensus.py new file mode 100644 index 00000000..8f8f9bcd --- /dev/null +++ b/tests/test_consensus.py @@ -0,0 +1,15 @@ +import pytest + + +class TestBaseConsensusRules(object): + + def test_validate_transaction(self): + from bigchaindb.consensus import BaseConsensusRules + transaction = { + 'transaction': { + 'operation': None, + 'fulfillments': None, + }, + } + with pytest.raises(ValueError): + BaseConsensusRules.validate_transaction(None, transaction)