Skip to content

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

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Labels: contracts, testing, Stellar Wave, rust

There's no test for the case where a positive fee rate rounds down to a zero fee.

collect_fee guards with if fee > 0 at lib.rs:669. When fee_rate_bps > 0 but amount * bps / 10_000 truncates to 0 (e.g. amount=1 at 200 bps), no transfer and no FeeCollectedEvent happen and the full amount is credited. The only zero-fee test sets fee_rate_bps=0, which is a different code path. We should cover the rounds-to-zero branch so the behavior is pinned down.

What the fix has to hold to

  • Test the rounds-to-zero path specifically, not the fee_rate_bps==0 path (already covered)

Done when

  • Test initializes with a nonzero fee rate and creates a stream with a tiny amount where the fee rounds to 0
  • Asserts treasury balance is 0, deposited_amount equals the full amount, and no fee_collected event fired
  • Tests + fmt pass, CI green

Where to start
Mainly a test in contracts/stream_contract/src/test.rs; lib.rs is listed in case the assertion surfaces something worth adjusting. Small test addition.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave programcontractsSmart contract related tasksrustPull requests that update rust codetestingTesting related tasks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions