Suggested area: Rust, TypeScript
Summary
is_consistent(ballot_id_hash) is the most operationally valuable
function in the contract — it returns true only when
tokens_issued == votes_cast, giving anyone a single on-chain call
to confirm no votes were dropped or duplicated. Despite this, it is
never called from sorobanService.ts, never called from core, and
has no test in cargo test. It exists in lib.rs but has zero
coverage and zero callers.
Scope
- Add a unit test in
contracts/anonvote/src/lib.rs covering
is_consistent — test the true case where tokens and votes match,
the false case where they differ, and the case where the ballot
does not exist
- Add a
sorobanIsConsistent(ballotIdHash: string): Promise<boolean>
function to service/sorobanService.ts following the same pattern
as the existing view call wrappers
- Document in the README that
is_consistent is the recommended
integrity check after tally — explain what a false return means
and what a maintainer should do if it fires
- Add a note in the wiring table in the README mapping
sorobanIsConsistent to services/resultEngine.ts in core as
the recommended call site after sorobanRecordResult
Relevant files
contracts/anonvote/src/lib.rs
service/sorobanService.ts
README.md
Acceptance Criteria
Out of scope
- Wiring
sorobanIsConsistent into core — that belongs in an
AnonVote/core issue
- Changes to other contract functions
Suggested area: Rust, TypeScript
Summary
is_consistent(ballot_id_hash)is the most operationally valuablefunction in the contract — it returns
trueonly whentokens_issued == votes_cast, giving anyone a single on-chain callto confirm no votes were dropped or duplicated. Despite this, it is
never called from
sorobanService.ts, never called from core, andhas no test in
cargo test. It exists inlib.rsbut has zerocoverage and zero callers.
Scope
contracts/anonvote/src/lib.rscoveringis_consistent— test the true case where tokens and votes match,the false case where they differ, and the case where the ballot
does not exist
sorobanIsConsistent(ballotIdHash: string): Promise<boolean>function to
service/sorobanService.tsfollowing the same patternas the existing view call wrappers
is_consistentis the recommendedintegrity check after tally — explain what a
falsereturn meansand what a maintainer should do if it fires
sorobanIsConsistenttoservices/resultEngine.tsin core asthe recommended call site after
sorobanRecordResultRelevant files
contracts/anonvote/src/lib.rsservice/sorobanService.tsREADME.mdAcceptance Criteria
is_consistenthas unit tests covering true, false, andballot-not-found cases
sorobanIsConsistentadded tosorobanService.tswithcorrect TypeScript types
cargo testpasses with the new tests includedis_consistentas the post-tally integritycheck with guidance on what a false return means
sorobanIsConsistentand
resultEngine.tsOut of scope
sorobanIsConsistentinto core — that belongs in anAnonVote/core issue