Skip to content

test: add test for withdraw() at same timestamp as resume() - #278

Open
GazzyLee wants to merge 1 commit into
conduit-protocol:mainfrom
GazzyLee:test-withdraw-at-resume-timestamp
Open

test: add test for withdraw() at same timestamp as resume()#278
GazzyLee wants to merge 1 commit into
conduit-protocol:mainfrom
GazzyLee:test-withdraw-at-resume-timestamp

Conversation

@GazzyLee

Copy link
Copy Markdown

Summary

Add a dedicated withdraw_at_same_timestamp_as_resume() test to tests/stream_pause_resume.rs.

This test covers calling withdraw() at the exact same ledger timestamp as resume(), with zero elapsed seconds since the stream was resumed.

It verifies that the withdrawable amount correctly reflects zero newly streamed tokens at that instant.

Motivation

None of the existing tests in stream_pause_resume.rs covered the edge case of calling withdraw() at the exact same timestamp as resume().

This dedicated test guards against potential off-by-one errors in the elapsed-time calculation by ensuring that when a withdrawal occurs immediately after resuming, with no time elapsed, only the tokens accumulated before the pause are withdrawable.

Test Details

The new test:

  • Creates a stream and allows it to run for 300 seconds, resulting in 300,000 tokens streamed.
  • Pauses the stream for 1,000 seconds. This paused duration should not contribute to the streamed amount.
  • Resumes the stream.
  • Immediately calls withdraw() at the exact same ledger timestamp as resume(), without calling advance().
  • Asserts that only the 300,000 tokens accumulated before the pause are withdrawable.
  • Verifies that zero newly streamed tokens are included at that instant.

Test Results

All 8 tests in stream_pause_resume.rs pass, including the new test:

running 8 tests
test withdraw_at_same_timestamp_as_resume ... ok
test resume_on_running_stream_is_rejected ... ok
test pause_freezes_withdrawable_amount ... ok
test double_pause_is_rejected ... ok
test paused_time_excluded_from_streamed_total ... ok
test multiple_pause_resume_cycles_accumulate_correctly ... ok
test resume_after_pause_continues_stream_correctly ... ok
test recipient_can_withdraw_accumulated_balance_while_paused ... ok

test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


## Closes #228 

Add a dedicated test that calls withdraw() in the exact same ledger timestamp as resume() to guard against off-by-one errors in elapsed-time math. The test asserts that the withdrawable amount correctly reflects zero newly-streamed tokens at that instant.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@GazzyLee
GazzyLee requested a review from Jaydbrown as a code owner July 30, 2026 23:14
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@GazzyLee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

1 participant