Skip to content

test(creator-earnings): add unauthorized caller revert tests#1275

Merged
aji70 merged 2 commits into
MyFanss:mainfrom
Xaxxoo:fix/941-creator-earnings-unauthorized-revert-tests
May 31, 2026
Merged

test(creator-earnings): add unauthorized caller revert tests#1275
aji70 merged 2 commits into
MyFanss:mainfrom
Xaxxoo:fix/941-creator-earnings-unauthorized-revert-tests

Conversation

@Xaxxoo

@Xaxxoo Xaxxoo commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Add comprehensive unauthorized-caller revert tests to the creator-earnings contract, covering all protected entry points:

  • Non-admin cannot call add_authorized (auth guard)
  • Double initialize reverts with AlreadyInitialized before auth check
  • An impersonator cannot withdraw another creator's funds (auth guard)
  • Zero-amount deposit reverts with InvalidAmount (pre-auth guard)
  • Zero-amount withdraw reverts with InvalidAmount (pre-auth guard)

Test plan

  • test_unauthorized_add_authorized_reverts — passes
  • test_double_initialize_reverts — passes
  • test_non_creator_cannot_withdraw_other_creators_funds — passes
  • test_deposit_zero_amount_reverts — passes
  • test_withdraw_zero_amount_reverts — passes
  • All existing tests continue to pass (no regressions)

Closes #941

@drips-wave

drips-wave Bot commented May 31, 2026

Copy link
Copy Markdown

@Xaxxoo 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

@Xaxxoo Xaxxoo force-pushed the fix/941-creator-earnings-unauthorized-revert-tests branch from ff63a93 to 6500d79 Compare May 31, 2026 17:12
Add five targeted revert tests:
- test_unauthorized_add_authorized_reverts: non-admin cannot add depositors
- test_double_initialize_reverts: second initialize reverts with AlreadyInitialized
- test_non_creator_cannot_withdraw_other_creators_funds: impersonator cannot withdraw
- test_deposit_zero_amount_reverts: zero-amount deposit reverts with InvalidAmount
- test_withdraw_zero_amount_reverts: zero-amount withdrawal reverts with InvalidAmount

Also fixes a pre-existing compile error in content-likes: missing
`contracttype` import and invalid `panic_with_error!` string literal
(replaced with `Error::AlreadyInitialized`).

Applies cargo fmt to pre-existing formatting violations across
content-access, content-likes, subscription, test-consumer, and treasury.

Closes MyFanss#941
@Xaxxoo Xaxxoo force-pushed the fix/941-creator-earnings-unauthorized-revert-tests branch from 6500d79 to 6cea981 Compare May 31, 2026 17:23
@aji70 aji70 merged commit 437672d into MyFanss:main May 31, 2026
4 of 16 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.

Contract creator-earnings: Add unauthorized caller revert tests

2 participants