Skip to content

test: verify conversion arithmetic invariants - #154

Merged
hpmaxi merged 2 commits into
mainfrom
feat/79-pre-audit-arithmetic
Sep 25, 2026
Merged

hpmaxi merged 2 commits into
mainfrom
feat/79-pre-audit-arithmetic

Conversation

@hpmaxi

@hpmaxi hpmaxi commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ref #79

Before the audit, the conversion arithmetic should be checked by more than the example tests written alongside it. Property tests run the real rounding helper over wide ranges and check the wind-down accumulator across rounds.

Changes

  • Round trips never create value, in either direction.
  • The floor is tight, and conversions are monotonic in amount and price.
  • Wind-down payouts never exceed what the accumulator credited, across rounds and claim orders.
  • Negative control: ceiling division creates value.

Deviations

  • Kani was considered and dropped: on overflow the helper uses the host's I256, which Kani cannot model.

Acceptance criteria

#79 has none by design; this covers the conversion-arithmetic candidate with property tests instead of Kani.

Test plan

Automated tests

  1. nix develop -c cargo test -p async-vault — 213 passed.
  2. nix develop -c cargo clippy -p async-vault --all-targets -- -D warnings — clean.

Manual verification

None.

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Sep 25, 2026 3:31pm UTC

Request Review

@hpmaxi
hpmaxi requested a review from luchobonatti September 23, 2026 20:02
@hpmaxi
hpmaxi added this pull request to stack #158 September 23, 2026 20:20

@luchobonatti luchobonatti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proptests over checked_mul_div_floor are welcome and everything is green. My doubts are the Kani part: --features kani does not build, the harnesses sit inside mod test where cargo kani cannot see them, and they check a hand-written i128 formula rather than the helper. Was it run? Would you also fill in the PR template?

Comment thread contracts/async-vault/Cargo.toml Outdated
Comment thread contracts/async-vault/src/test/conversions.rs Outdated
Comment thread contracts/async-vault/src/test/conversions.rs Outdated
@hpmaxi

hpmaxi commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

It was not run: Kani is not in the devshell and --features kani did not build. Removed, template filled in.

@luchobonatti luchobonatti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kani removed rather than patched, and the reasoning is better than my suggestion. The wind-down property now follows the real accumulator. 213 tests, clippy and fmt clean.

Base automatically changed from feat/72-pricing-trait to main September 25, 2026 15:31
The wind-down property now follows the accumulator and earned - paid across rounds and claims. The Kani harnesses never ran and proved a hand-written formula; the helper's overflow path goes through the host's I256, which Kani cannot model.
@hpmaxi
hpmaxi force-pushed the feat/79-pre-audit-arithmetic branch from 7d7dae1 to 9d95e6c Compare September 25, 2026 15:31
@hpmaxi
hpmaxi merged commit 2cf4383 into main Sep 25, 2026
3 checks passed
@hpmaxi
hpmaxi deleted the feat/79-pre-audit-arithmetic branch September 25, 2026 17:50

This branch was successfully deployed

1 active deployment
Preview — 9d95e6c4 Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants