Skip to content

Add tests for withdraw functionality in StreamContract#114

Merged
ogazboiz merged 3 commits intoLabsCrypt:mainfrom
Obiajulu-gif:access_control
Feb 22, 2026
Merged

Add tests for withdraw functionality in StreamContract#114
ogazboiz merged 3 commits intoLabsCrypt:mainfrom
Obiajulu-gif:access_control

Conversation

@Obiajulu-gif
Copy link
Copy Markdown
Contributor

This pull request enhances the test coverage #82 the StreamContract by adding tests for the withdraw function, specifically focusing on authorization scenarios. The new tests ensure that only authorized recipients can successfully withdraw from a stream, and that unauthorized attempts are properly rejected.

Authorization testing:

  • Added withdraw_succeeds_for_authorized_recipient test to verify that a recipient with proper authorization can successfully withdraw from a stream and that the authorization is correctly recorded. (contracts/stream_contract/src/test.rs)
  • Added withdraw_fails_for_non_recipient_and_authorized_call_still_succeeds test to confirm that unauthorized users cannot withdraw, and that an authorized recipient can still withdraw after a failed unauthorized attempt. (contracts/stream_contract/src/test.rs)

Test utility improvements:

  • Utilized MockAuth and MockAuthInvoke for simulating contract authorization in tests, improving the realism and robustness of test scenarios. (contracts/stream_contract/src/test.rs)

Closes #82

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition of tests for the withdraw functionality. This is much needed. Approving and merging.

@Obiajulu-gif
Copy link
Copy Markdown
Contributor Author

@ogazboiz merge it

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. This seems to be identical to #117 and only adds 'extern crate std;'. I'll leave this for now until we decide if that addition is globally necessary or if it was part of a larger change.

@Obiajulu-gif
Copy link
Copy Markdown
Contributor Author

i have fix the issue @ogazboiz

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two test lines are a very small addition. To make this PR merge-worthy, please consider: 1) Adding at least a few more test cases for the withdraw flow (e.g. unauthorized withdraw, withdraw more than deposited), and 2) Rebasing on latest main which has seen significant changes since this PR was opened.

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test lines are a small but good start. To make this ready for merge, please consider adding a few more test cases for the withdraw flow (e.g., edge cases like unauthorized access or over-withdrawal) and rebasing on the latest main branch.

@ogazboiz ogazboiz merged commit 6bd65a0 into LabsCrypt:main Feb 22, 2026
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.

Contract: Access Control & Authorization

2 participants