Skip to content

Commit

Permalink
added tests for randomness fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Oct 5, 2011
1 parent 69683a6 commit 50d26c1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helios/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,11 @@ def _cast_ballot(self, election_id, username, password, need_login=True, check_u
response = self.app.post("/helios/elections/%s/encrypt-ballot" % election_id, {
'answers_json': utils.to_json([[1]])})
self.assertContains(response, "answers")

# parse it as an encrypted vote with randomness, and make sure randomness is there
the_ballot = utils.from_json(response.testbody)
assert the_ballot['answers'][0].has_key('randomness'), "no randomness"
assert len(the_ballot['answers'][0]['randomness']) == 2, "not enough randomness"

# parse it as an encrypted vote, and re-serialize it
ballot = datatypes.LDObject.fromDict(utils.from_json(response.testbody), type_hint='legacy/EncryptedVote')
Expand Down

0 comments on commit 50d26c1

Please sign in to comment.