Skip to content

Add test for rounded-zero protocol fee#945

Open
Killerjunior wants to merge 2 commits into
LabsCrypt:mainfrom
Killerjunior:test-794-fee-rounds-to-zero
Open

Add test for rounded-zero protocol fee#945
Killerjunior wants to merge 2 commits into
LabsCrypt:mainfrom
Killerjunior:test-794-fee-rounds-to-zero

Conversation

@Killerjunior

Copy link
Copy Markdown

Description
Add coverage for the untested collect_fee branch where fee_rate_bps > 0 but fee rounds down to zero for tiny amounts, ensuring behavior is explicitly verified.

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
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #794

Changes Made

  • Added a new unit test in contracts/stream_contract/src/test.rs:
    • test_no_fee_transfer_or_event_when_fee_rounds_to_zero
  • Test initializes protocol with non-zero fee rate (200 bps) and creates a stream with tiny amount (1) so fee calculation truncates to zero.
  • Added assertions to verify:
    • Treasury token balance remains 0
    • Stream deposited_amount remains full amount (1)
    • No fee_collected event is emitted
  • Updated collect_fee doc comment in contracts/stream_contract/src/lib.rs to explicitly describe the rounded-zero-fee behavior.

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

  1. Run:
    cargo test --manifest-path contracts/stream_contract/Cargo.toml test_no_fee_transfer_or_event_when_fee_rounds_to_zero
  2. Confirm the new test validates rounded-zero fee behavior (treasury unchanged, full deposit retained, no fee event).
  3. (Optional) Run full contract test suite from same manifest path.

Breaking Changes

Breaking Changes:

  • None.

Migration Guide:

  • No migration required.

Screenshots/Demo

N/A

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own 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
  • I have checked for breaking changes and documented them if applicable

Additional Notes

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.

[Testing] collect_fee fee-rounds-to-zero branch untested - positive fee rate but amount too small to charge

1 participant