Skip to content

Commit

Permalink
Merge pull request #14 from c4dt/fix/removes-check-on-ballot-size
Browse files Browse the repository at this point in the history
Fix: removes check on ballot size
  • Loading branch information
lanterno committed Oct 3, 2023
2 parents 2f27c4f + 19e4089 commit a73ff85
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
6 changes: 0 additions & 6 deletions contracts/evoting/types/ballots.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ type Ballot struct {
// Unmarshal decodes the given string according to the format described in
// "state of smart contract.md"
func (b *Ballot) Unmarshal(marshalledBallot string, form Form) error {
if len(marshalledBallot) > form.BallotSize {
b.invalidate()
return fmt.Errorf("ballot has an unexpected size %d, expected <= %d",
len(marshalledBallot), form.BallotSize)
}

lines := strings.Split(marshalledBallot, "\n")

b.SelectResultIDs = make([]ID, 0)
Expand Down
4 changes: 0 additions & 4 deletions contracts/evoting/types/ballots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ func TestBallot_Unmarshal(t *testing.T) {
require.Equal(t, expected.TextResultIDs, b.TextResultIDs)
require.Equal(t, expected.TextResult, b.TextResult)

// with ballot too long
err = b.Unmarshal(ballot1+"x", form)
require.EqualError(t, err, "ballot has an unexpected size 102, expected <= 101")

// with line wrongly formatted
err = b.Unmarshal("x", form)
require.EqualError(t, err, "a line in the ballot has length != 3: x")
Expand Down

0 comments on commit a73ff85

Please sign in to comment.