Skip to content

Latest commit

 

History

History
100 lines (78 loc) · 2.33 KB

File metadata and controls

100 lines (78 loc) · 2.33 KB

Quick Reference - Withdraw Authorization Tests

Run Tests

Run only authorization tests

cargo test -p fluxora_stream withdraw_as

Run all tests

cargo test -p fluxora_stream

Run with detailed output

cargo test -p fluxora_stream withdraw_as -- --nocapture

View Changes

See what changed

git diff main..test/withdraw-recipient-only-auth

View commit history

git log --oneline test/withdraw-recipient-only-auth

View specific test file changes

git diff main..test/withdraw-recipient-only-auth contracts/stream/src/test.rs

Test Details

Test Functions

  1. test_withdraw_as_sender_fails - Line ~1334
  2. test_withdraw_as_admin_fails - Line ~1370
  3. test_withdraw_as_recipient_succeeds - Line ~1406

Key Assertions

  • Sender withdrawal panics with Error(Auth, InvalidAction)
  • Admin withdrawal panics with Error(Auth, InvalidAction)
  • Recipient withdrawal succeeds with correct token transfer
  • State updates correctly after successful withdrawal

Documentation

  • Full summary: WITHDRAW_AUTH_TESTS.md
  • Test output: test_output.txt
  • Test code: contracts/stream/src/test.rs

Next Steps

Create Pull Request

# Push branch to remote
git push origin test/withdraw-recipient-only-auth

# Then create PR on GitHub comparing:
# base: main
# compare: test/withdraw-recipient-only-auth

PR Title

test: add withdraw recipient-only authorization tests

PR Description Template

## Description
Adds comprehensive authorization tests for the `withdraw` function to ensure only the stream recipient can withdraw funds.

## Tests Added
-`test_withdraw_as_sender_fails` - Verifies sender cannot withdraw
-`test_withdraw_as_admin_fails` - Verifies admin cannot withdraw
-`test_withdraw_as_recipient_succeeds` - Verifies recipient can withdraw

## Security
All tests verify that `stream.recipient.require_auth()` correctly enforces recipient-only access.

## Test Results

running 68 tests test result: ok. 68 passed; 0 failed; 0 ignored


## Documentation
See `WITHDRAW_AUTH_TESTS.md` for comprehensive test documentation.

## Checklist
- [x] Tests pass locally
- [x] Authorization enforced correctly
- [x] Different invoker addresses tested
- [x] Documentation included
- [x] 95%+ test coverage maintained