Skip to content

is_consistent is unused and untested — wire it into the post-tally integrity check #65

Description

@grantfox-oss

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

  • is_consistent has unit tests covering true, false, and
    ballot-not-found cases
  • sorobanIsConsistent added to sorobanService.ts with
    correct TypeScript types
  • cargo test passes with the new tests included
  • README documents is_consistent as the post-tally integrity
    check with guidance on what a false return means
  • Wiring table updated to reference sorobanIsConsistent
    and resultEngine.ts

Out of scope

  • Wiring sorobanIsConsistent into core — that belongs in an
    AnonVote/core issue
  • Changes to other contract functions

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions