Skip to content

[Testing] calculate_claimable underflow guard (withdrawn > deposited -> 0) is never exercised #795

Description

@grantfox-oss

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

Why this matters

calculate_claimable uses checked_sub(...).unwrap_or_default() at lib.rs:347-350 to defend against withdrawn_amount > deposited_amount. The fuzz test that calls calculate_claimable directly only generates withdrawn = seed % (deposited+1), so withdrawn never exceeds deposited and the underflow-to-0 fallback is dead in tests.

Acceptance criteria

  • Construct a Stream with withdrawn_amount > deposited_amount and call calculate_claimable, asserting it returns 0 (no panic/underflow)

Files to touch

  • contracts/stream_contract/src/test.rs
  • contracts/stream_contract/src/lib.rs

Out of scope

  • The rate*elapsed overflow cap (already covered)

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractsSmart contract related tasksrustPull requests that update rust codetestingTesting related tasks

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions