Skip to content

[Testing] Add contract tests for cancelling and withdrawing paused streams #462

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

The on-chain withdraw and cancel_stream flows differ in an important way that is not directly tested: cancel_stream (contracts/stream_contract/src/lib.rs) settles the recipient's accrued amount even when the stream is paused, whereas withdraw explicitly rejects when stream.paused is true. Today the contract test suite covers pause stopping accrual (test_pause_stops_accrual) and resume adjusting end time, but there is no test that cancels a currently-paused stream and asserts the settlement/refund split is computed from paused_at (frozen accrual) rather than now. This is exactly the kind of edge case where a regression would silently misallocate user funds.

Acceptance criteria

  • Add a test in contracts/stream_contract/src/test.rs that: creates a stream, advances time, pauses it, advances time further while paused, then cancels — and asserts the recipient receives only the amount accrued up to paused_at and the sender is refunded the rest.
  • Add a test asserting withdraw on a paused stream returns StreamInactive (locking in current behavior).
  • Add a test that resuming then cancelling settles correctly across the pause boundary.

Files to touch

  • contracts/stream_contract/src/test.rs

Out of scope

  • Property-based / fuzz invariants (covered by existing open issues).
  • Changing contract behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractsSmart contract related taskstestingTesting related tasks

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions