Skip to content

feat: add investment share percentage calculator and tests - #240

Open
probablyABug wants to merge 1 commit into
StellarState:devfrom
probablyABug:fix/204-investment-share-calculator
Open

feat: add investment share percentage calculator and tests#240
probablyABug wants to merge 1 commit into
StellarState:devfrom
probablyABug:fix/204-investment-share-calculator

Conversation

@probablyABug

Copy link
Copy Markdown

Description

Closes #204

Adds unit test coverage for the investment share percentage calculator, verifying that percentage calculations use integer arithmetic and always produce a total of exactly 100%. The tests cover equal and unequal investment splits, single-investor cases, and correct allocation of rounding remainders to the largest investor.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 UI/UX improvement
  • ♻️ Code refactoring
  • ✅ Test addition or update
  • 🔧 Configuration change

Checklist

  • All GitHub Actions workflows are green on this PR (required for merge)
  • Commit messages follow Conventional Commits (feat:, fix:, chore:, etc.) — enforced by CI
  • No secrets, API keys, .env, or credentials committed (see CONTRIBUTING.md)
  • My code follows the code style of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Testing

Added unit tests for the investment share percentage calculator covering equal splits, unequal splits, single-investor calculations, and rounding remainder allocation.

How to Test

  1. Run the backend test suite.
  2. Verify the three-way 3000/3000/3000 split produces percentages totaling exactly 100%, with the rounding remainder assigned to the first/largest investor.
  3. Verify a 2500/7500 split produces exactly 25% and 75%.
  4. Verify a single investor receives exactly 100%.
  5. Verify all test cases sum to exactly 100% and do not rely on floating-point arithmetic.

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests added/updated (if applicable)
  • Manual testing completed

Screenshots (if applicable)

Not applicable — this PR adds backend unit test coverage only.

Additional Notes

The tests specifically guard against floating-point rounding drift in investment share calculations. They also verify that any percentage remainder is assigned consistently to the investor with the largest commitment.

For Reviewers

  • Code quality and readability
  • Test coverage
  • Security implications
  • Performance impact
  • Breaking changes

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

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

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 unit tests for the investment share percentage calculator handling floating point correctly using integer arithmetic

2 participants