flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Add unit tests verifying behavior when stream end_time equals start_time

Open blurbeast opened this issue 2 months ago • 3 comments

Overview

Edge case validation: What happens if a caller attempts to create a stream where start_time == end_time or duration == 0?

Problem

  • Division by zero in rate calculation or instant 100% vesting behavior must be strictly asserted to prevent contract panics.

Proposed Changes

  1. In contracts/stream_contract/src/test.rs, add test cases for:
    • start_time == end_time: Verify it reverts with StreamError::InvalidTimeRange.
    • start_time > end_time: Verify revert.
  2. Ensure duration is validated as end_time > start_time before rate arithmetic.

Acceptance Criteria

  • [ ] Stream creation with zero duration strictly reverts.
  • [ ] Clear error code returned without host panic.
  • [ ] Tests pass in cargo test.

blurbeast avatar Sep 27 '26 05:09 blurbeast

@Oluwasuyi-Oluwatimilehin-Daniel has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hello @maintainer, I’d like to work on this issue. I have experience handling similar tasks and can start immediately. And I will deliver at the shortest possible time.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Oluwasuyi-Oluwatimilehin-Daniel to this issue.

timiturn3r avatar Sep 27 '26 15:09 timiturn3r

Congratulations, @Oluwasuyi-Oluwatimilehin-Daniel! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @Oluwasuyi-Oluwatimilehin-Daniel: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 27 '26 15:09 drips-wave[bot]

This issue has been marked as completed by a Drips Wave moderator for @timiturn3r as part of the Stellar Wave Program's 9th Wave 🥳

Moderator's reason: [Auto-assessed] The PR has been merged (mergedAt: 2026-10-08T06:08:40Z), and the changes directly implement unit tests and error definitions covering start_time equal to or greater than end_time as requested in issue #1518.

😎 @timiturn3r: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

drips-wave[bot] avatar Oct 13 '26 07:10 drips-wave[bot]