Skip to content

feature/token-decimal-safety-invariant-tests#406

Merged
Cedarich merged 4 commits intoPulsefy:mainfrom
oreoluwa648:feature/token-decimal-safety-invariant-tests
Apr 30, 2026
Merged

feature/token-decimal-safety-invariant-tests#406
Cedarich merged 4 commits intoPulsefy:mainfrom
oreoluwa648:feature/token-decimal-safety-invariant-tests

Conversation

@oreoluwa648
Copy link
Copy Markdown
Contributor

Consolidated PR: Invariant Assertions & Token Decimal Safety

Summary

This PR introduces two critical enhancements to the Soter contract suite:

  • Invariant assertion test suite ensuring core accounting integrity across all lifecycle transitions.
  • Token decimal safety and amount normalization for robust cross-token integration.

Changes

1. Invariant Assertion Test Suite (#315)

  • Added tests asserting that locked totals, claim totals, and surplus accounting remain consistent
  • Covered mixed flows: create, claim, revoke, reissue, and partial-claim scenarios
  • Tests fail loudly when any storage counter diverges from expected balances

2. Token Decimal Safety and Amount Normalization (#316)

  • Defined and documented how token amounts are normalized/validated before storage
  • Reject invalid inputs: zero, negative-equivalent, or precision-breaking amounts
  • Added tests for tokens with different decimal conventions (e.g., 6, 8, 18 decimals) and boundary values (min/max, edge precision)

Testing & Quality

  • All invariant tests pass across full lifecycle scenarios
  • Decimal safety tests cover token varieties and boundary conditions
  • No regressions in existing claim flow

Documentation

  • Updated contract specification with invariant accounting rules
  • Added token decimal handling guidelines for integrators

Closes #315
Closes #316

@oreoluwa648 oreoluwa648 marked this pull request as draft April 28, 2026 15:57
@oreoluwa648 oreoluwa648 changed the title feat: initialized new branch for features implementation feature/token-decimal-safety-invariant-tests Apr 29, 2026
…nd package creation

- Enforce amount normalization only for the token’s actual decimal precision (e.g., 6 decimals for Stellar assets)
- Fixes over-strict check that required multiples of both 1_000_000 and 100_000_000
- Updates tests to use valid normalized values for the configured token decimals
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 30, 2026

@oreoluwa648 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

…nting

- Adds KEY_TOTAL_CLAIMED to track cumulative disbursements in KEY_TOTAL_CLAIMED Map
- Updates claim logic to maintain global accounting counters across lifecycle transitions
- Implements get_total_locked and get_total_claimed getters for state verification
- Adds tests/invariant_tests.rs to assert balance solvency and conservation of value
@oreoluwa648 oreoluwa648 marked this pull request as ready for review April 30, 2026 21:15
@oreoluwa648
Copy link
Copy Markdown
Contributor Author

@Cedarich please, approve workflow to run.

@Cedarich Cedarich merged commit fe8c928 into Pulsefy:main Apr 30, 2026
1 check 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.

Token Decimal Safety and Amount Normalization Invariant Assertion Test Suite

2 participants