Skip to content

test(cleanup_stream): add coverage for index cleanup, auth, and eligibility guards - #641

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
joshfatoye0011-bit:test/466-cleanup-stream-tests
Aug 27, 2026
Merged

test(cleanup_stream): add coverage for index cleanup, auth, and eligibility guards#641
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
joshfatoye0011-bit:test/466-cleanup-stream-tests

Conversation

@joshfatoye0011-bit

Copy link
Copy Markdown
Contributor

Summary Adds four tests to contracts/streaming/src/test.rs covering the previously untested cleanup_stream function (lines 1068-1108 of lib.rs). ## Tests added - ** est_cleanup_after_cancellation_removes_indexes** — calls cancel then cleanup_stream as the sender; asserts all four index slices (active sent/received + archive sent/received) no longer contain the stream ID. - ** est_cleanup_after_completion_removes_indexes** — advances past end_time, withdraws the full amount, calls cleanup_stream as the recipient; asserts all indexes are cleared and ry_get_stream returns StreamNotFound. - ** est_cleanup_rejected_by_third_party** — cancels the stream then calls cleanup_stream from a freshly generated outsider address; asserts Unauthorized is returned and stream data remains intact. - ** est_cleanup_rejected_when_stream_still_active** — attempts cleanup_stream on a running mid-stream; asserts StreamNotEligibleForCleanup and confirms funds are untouched. ## Coverage gaps closed | Guard / path | Test | |---|---| | caller != sender && caller != recipient → Unauthorized | est_cleanup_rejected_by_third_party | | !cancelled && !fully_drained → StreamNotEligibleForCleanup | est_cleanup_rejected_when_stream_still_active | | All four

emove_from_index calls (cancelled path) | est_cleanup_after_cancellation_removes_indexes | | All four
emove_from_index calls + storage delete (completion path) | est_cleanup_after_completion_removes_indexes | Closes #466

…bility guards - test_cleanup_after_cancellation_removes_indexes: verifies all four index slices (active + archive, sent + received) are wiped after a cancelled stream is cleaned up by the sender. - test_cleanup_after_completion_removes_indexes: verifies the same for a fully-drained stream (withdrawn >= deposited AND time >= end_time), called by the recipient; also asserts StreamNotFound on get_stream. - test_cleanup_rejected_by_third_party: asserts Unauthorized is returned when a caller who is neither sender nor recipient attempts cleanup on an otherwise-eligible (cancelled) stream. - test_cleanup_rejected_when_stream_still_active: asserts StreamNotEligibleForCleanup is returned mid-stream (no cancel, no full withdrawal), and confirms stream data is untouched. Closes FlowwStar#466
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@joshfatoye0011-bit 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

@Austinaminu2
Austinaminu2 merged commit ad4b410 into FlowwStar:main Aug 27, 2026
2 of 7 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.

Add test coverage for cleanup_stream()

2 participants