From b7f70befe6cd6d8647aa2eaa3e9505348be8cf0e Mon Sep 17 00:00:00 2001 From: Rodolphe Marques Date: Wed, 1 Feb 2017 15:10:17 +0100 Subject: [PATCH] fix wrong logic in validate_block --- bigchaindb/models.py | 5 ----- tests/test_models.py | 13 ------------- 2 files changed, 18 deletions(-) diff --git a/bigchaindb/models.py b/bigchaindb/models.py index c6e81956..c3683a03 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -202,11 +202,6 @@ class Block(object): OperationError: If a non-federation node signed the Block. InvalidSignature: If a Block's signature is invalid. """ - - # First, make sure this node hasn't already voted on this block - if bigchain.has_previous_vote(self.id, self.voters): - return self - # Check if the block was created by a federation node possible_voters = (bigchain.nodes_except_me + [bigchain.me]) if self.node_pubkey not in possible_voters: diff --git a/tests/test_models.py b/tests/test_models.py index 7ab97e9e..58aa64fd 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -163,16 +163,3 @@ class TestBlockModel(object): public_key = PublicKey(b.me) assert public_key.verify(expected_block_serialized, block.signature) - - def test_validate_already_voted_on_block(self, b, monkeypatch): - from unittest.mock import Mock - from bigchaindb.models import Transaction - - tx = Transaction.create([b.me], [([b.me], 1)]) - block = b.create_block([tx]) - - has_previous_vote = Mock() - has_previous_vote.return_value = True - monkeypatch.setattr(b, 'has_previous_vote', has_previous_vote) - assert block == block.validate(b) - assert has_previous_vote.called is True