def test_count_votes():

    class TestVoting(Voting):

        @classmethod
        def verify_vote_schema(cls, vote):
            return (vote['node_pubkey'] != 'malformed')
    voters = (['says invalid', 'malformed'] + [('kosher' + str(i)) for i in range(10)])
    votes = [Bigchain(v).vote('block', 'a', True) for v in voters]
    votes[0]['vote']['is_block_valid'] = False
    votes[(- 1)]['vote']['previous_block'] = 'z'
    by_voter = dict(enumerate(votes))
    assert (TestVoting.count_votes(by_voter) == {'counts': {'n_valid': 9, 'n_invalid': 3}, 'malformed': [votes[1]], 'previous_block': 'a', 'other_previous_block': {'z': 1}})
def test_count_votes():

    class TestVoting(Voting):

        @classmethod
        def verify_vote_schema(cls, vote):
            return (vote['node_pubkey'] != 'malformed')
    voters = (['says invalid', 'malformed'] + [('kosher' + str(i)) for i in range(10)])
    votes = [Bigchain(v).vote('block', 'a', True) for v in voters]
    votes[0]['vote']['is_block_valid'] = False
    votes[(- 1)]['vote']['previous_block'] = 'z'
    by_voter = dict(enumerate(votes))
    assert (TestVoting.count_votes(by_voter) == {'counts': {'n_valid': 9, 'n_invalid': 3}, 'malformed': [votes[1]], 'previous_block': 'a', 'other_previous_block': {'z': 1}})