Skip to content

feat(stream): support partial cancellation and escrow deadline tests - #291

Merged
techAlhaji merged 3 commits into
SorobanForge:mainfrom
Hamda-gbade:feat/reduce-stream-escrow-boundaries
Oct 24, 2026
Merged

techAlhaji merged 3 commits into
SorobanForge:mainfrom
Hamda-gbade:feat/reduce-stream-escrow-boundaries

Conversation

@Hamda-gbade

Copy link
Copy Markdown
Contributor

Summary

  • Adds a sender-authorized reduce_stream entry point that partially cancels a stream without terminating it: it lowers the streamed total, immediately refunds the difference, and keeps the reduced amount vesting on the existing schedule/rate.
  • Fills the remaining escrow deadline-boundary coverage requested in test(escrow): cover the deadline boundary second by second #75, including the exact deadline, one second before, and refund/finalization behaviour after the deadline.

Changes

Partial cancellation (#80)

  • Added reduce_stream(stream_id, new_total) to StreamContract.
  • Requires the stream sender's authorization.
  • Rejects cancelled streams, non-positive totals, non-reductions, and totals below the amount already vested with new errors:
    • ReductionBelowVested = 20
    • InvalidReduction = 21
  • Shrinks end_time proportionally so the stream keeps its current payment rate and already-vested tokens remain vested.
  • Refunds old_total - new_total to the sender immediately.
  • Persists the reduced schedule before the token transfer, then bumps persistent and instance TTLs.
  • Emits a new StreamReduced { id, sender, new_total, refunded } event.
  • Added tests for:
    • mid-stream reduction, refund, rate preservation, event data, and a final withdraw;
    • rejection below the vested amount;
    • sender authorization.

Escrow deadline boundaries (#75)

  • Added tests for:
    • cancelling at exactly deadline succeeds;
    • cancelling one second before deadline returns DeadlineNotReached;
    • after the deadline the payee can refund_escrow, and a second finalization returns AlreadyFinalized.

Test plan

  • cargo test --manifest-path contracts/Cargo.toml --lib — 99 passed, 0 failed.
  • cargo fmt --manifest-path contracts/Cargo.toml --all -- --check — passed.
  • cargo clippy --manifest-path contracts/Cargo.toml --workspace --lib -- -D warnings — passed.
  • The plain cargo test --manifest-path contracts/Cargo.toml command could not link the local Windows GNU cdylib targets (export ordinal too large), an environment-specific toolchain limitation; all unit-test targets pass.

Closes #75
Closes #80

@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown

@Adediwura-dev is attempting to deploy a commit to the techalhaji's projects Team on Vercel.

A member of the Team first needs to authorize it.

@techAlhaji
techAlhaji merged commit e279a00 into SorobanForge:main Oct 24, 2026
7 of 10 checks passed
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.

feat(stream): support partial cancellation test(escrow): cover the deadline boundary second by second

3 participants