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
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
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
def test_validate_vote_fails(): with raises(SchemaValidationError): validate_vote_schema({})
def test_validate_vote(structurally_valid_vote): validate_vote_schema(structurally_valid_vote)