Beispiel #1
0
 def verify_vote_schema(cls, vote):
     # I'm not sure this is the correct approach. Maybe we should allow
     # duck typing w/r/t votes.
     try:
         validate_vote_schema(vote)
         return True
     except SchemaValidationError as e:
         return False
Beispiel #2
0
    def verify_vote(voters, signed_vote):
        """Verify the signature of a vote.

        Refer to the documentation of
        :func:`bigchaindb.util.verify_signature`.
        """
        if verify_vote_signature(voters, signed_vote):
            try:
                validate_vote_schema(signed_vote)
                return True
            except SchemaValidationError as exc:
                logger.warning(exc)
        else:
            logger.warning("Vote failed signature verification: "
                           "%s with voters: %s", signed_vote, voters)
        return False
Beispiel #3
0
    def verify_vote(voters, signed_vote):
        """Verify the signature of a vote.

        Refer to the documentation of
        :func:`bigchaindb.utils.verify_signature`.
        """
        if verify_vote_signature(voters, signed_vote):
            try:
                validate_vote_schema(signed_vote)
                return True
            except SchemaValidationError as exc:
                logger.warning(exc)
        else:
            logger.warning(
                "Vote failed signature verification: "
                "%s with voters: %s", signed_vote, voters)
        return False
Beispiel #4
0
def test_validate_vote_fails():
    with raises(SchemaValidationError):
        validate_vote_schema({})
Beispiel #5
0
def test_validate_vote(structurally_valid_vote):
    validate_vote_schema(structurally_valid_vote)