Skip to content

Commit

Permalink
elections: require that is_human returns exactly one token
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Aug 16, 2023
1 parent f73a89d commit c2ab6b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Contract {
if tokens.is_empty() || tokens[0].1.is_empty() {
return Err(VoteError::NoSBTs);
}
if tokens.len() != 1 {
if !(tokens.len() == 1 && tokens[0].1.len() == 1) {
// in current version we support only one proof of personhood issuer: Fractal, so here
// we simplify by requiring that the result contains tokens only from one issuer.
return Err(VoteError::WrongIssuer);
Expand Down Expand Up @@ -449,7 +449,7 @@ mod unit_tests {
assert_eq!(p.result, vec![1, 0, 0], "vote result should not change");

// attempt to double vote with few tokens
match ctr.on_vote_verified(mk_human_sbts(vec![2, 4]), prop_id, vote.clone()) {
match ctr.on_vote_verified(mk_human_sbts(vec![4]), prop_id, vote.clone()) {
Err(VoteError::DoubleVote(4)) => (),
x => panic!("expected DoubleVote(4), got: {:?}", x),
};
Expand Down

0 comments on commit c2ab6b9

Please sign in to comment.