Skip to content

feat: enforce and test aggregate holder share bps invariant - #863

Merged
thlpkee20-wq merged 3 commits into
RevoraOrg:masterfrom
kosisochukwu1234:feat/holder-share-sum-invariant
Aug 31, 2026
Merged

feat: enforce and test aggregate holder share bps invariant#863
thlpkee20-wq merged 3 commits into
RevoraOrg:masterfrom
kosisochukwu1234:feat/holder-share-sum-invariant

Conversation

@kosisochukwu1234

Copy link
Copy Markdown
Contributor

Closes #848

Implementation Approach

  • Fixed old_share scoping in src/lib.rs: The definition for old_share was previously restricted inside the if max_shares > 0 block, which caused compilation errors because the variable was accessed later in set_holder_share_internal to correctly compute the aggregate share differences. It has been moved outside this block to properly update the HolderShareTotal delta.
  • Added Regression Coverage: Implemented test_holder_share_sum_invariant.rs to guarantee that the set_holder_share running total enforces sum(share_bps) <= 10_000 per offering. The test asserts happy paths (summing to exactly 10,000) and negative edge cases (sum exceeding 10,000). It also asserts the correctness of capacity reuse when an existing holder's bps is reduced.
  • Updated README.md: Added sum(share_bps) validation semantics, bounded to 0-10000 per offering, mirroring the existing per-holder share_bps checks.

Acceptance Criteria Covered

  • Aggregate Guard & Tests: Included focused tests in test_holder_share_sum_invariant.rs verifying that multiple holders within an offering correctly evaluate to a bounded capacity of 10,000 bps.
  • Security & Integrity Requirements: A RevoraError::InvalidShareBps is immediately raised before persistence if any new configuration causes the offering's allocated shares to exceed 100%. No backward compatibility issues are expected because the invariant aligns with preexisting system constraints, providing an extra safety boundary.

Failure-Mode Handling

If an issuer issues >10,000 bps by accident, the invocation will fail gracefully with InvalidShareBps.

Files Affected

  • README.md
  • src/lib.rs
  • src/test_holder_share_sum_invariant.rs

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@kosisochukwu1234 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thlpkee20-wq
thlpkee20-wq merged commit 6280792 into RevoraOrg:master Aug 31, 2026
2 of 3 checks passed
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.

Add holder-share-summation invariant test asserting set_holder_share total stays within 10000 bps per offering

2 participants