mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #1130 from bigchaindb/feat/519/fix-logic-validate-block
fix wrong logic in validate_block
This commit is contained in:
commit
2262914868
@ -202,11 +202,6 @@ class Block(object):
|
|||||||
OperationError: If a non-federation node signed the Block.
|
OperationError: If a non-federation node signed the Block.
|
||||||
InvalidSignature: If a Block's signature is invalid.
|
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
|
# Check if the block was created by a federation node
|
||||||
possible_voters = (bigchain.nodes_except_me + [bigchain.me])
|
possible_voters = (bigchain.nodes_except_me + [bigchain.me])
|
||||||
if self.node_pubkey not in possible_voters:
|
if self.node_pubkey not in possible_voters:
|
||||||
|
@ -163,16 +163,3 @@ class TestBlockModel(object):
|
|||||||
|
|
||||||
public_key = PublicKey(b.me)
|
public_key = PublicKey(b.me)
|
||||||
assert public_key.verify(expected_block_serialized, block.signature)
|
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user