Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
altergui committed Dec 18, 2024
1 parent 5609a3a commit 3102cc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions circuits/statetransition/circuit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ func TestCircuitBallotsCompile(t *testing.T) {
func TestCircuitBallotsProve(t *testing.T) {
s := newMockState(t)

if err := s.StartBatch(); err != nil {
t.Fatal(err)
}

if err := s.AddVote(newMockVote(1, 10)); err != nil { // new vote 1
t.Fatal(err)
}
Expand Down Expand Up @@ -204,6 +208,10 @@ func TestCircuitMerkleTransitionsCompile(t *testing.T) {
func TestCircuitMerkleTransitionsProve(t *testing.T) {
s := newMockState(t)

if err := s.StartBatch(); err != nil {
t.Fatal(err)
}

if err := s.AddVote(newMockVote(1, 10)); err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 3 additions & 0 deletions state/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ type Vote struct {
// AddVote adds a vote to the state
// - if nullifier exists, it counts as vote overwrite
func (o *State) AddVote(v *Vote) error {
if o.dbTx == nil {
return fmt.Errorf("need to StartBatch() first")
}
if len(o.votes) >= VoteBatchSize {
return fmt.Errorf("too many votes for this batch")
}
Expand Down

0 comments on commit 3102cc8

Please sign in to comment.