Skip to content

feat: add admin-configurable transaction fees per accepted token - #60

Merged
codebestia merged 1 commit into
ShadeProtocol:mainfrom
KodeSage:feat/fee_management_functionality
Feb 22, 2026
Merged

codebestia merged 1 commit into
ShadeProtocol:mainfrom
KodeSage:feat/fee_management_functionality

Conversation

@KodeSage

Copy link
Copy Markdown
Contributor

CLOSES #35

Description

Add comprehensive tests to verify the fee management functionality, ensuring admins can set fees for accepted tokens and that the contract enforces all validation rules (authorization, token acceptance, storage correctness, and event emission).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Test improvements
  • Other (please describe):

Related Issues

Fixes #

Changes Made

  • Added new test file contracts/shade/src/tests/test_fees.rs with 5 test cases covering the full fee management surface area.
  • Registered test_fees module in contracts/shade/src/tests/mod.rs.

Testing

Test Scenario
test_set_fee_success Admin adds an accepted token, sets a fee, verifies get_fee returns the correct amount, and asserts FeeSetEvent is emitted with correct token, fee, and timestamp.
test_set_fee_unaccepted_token Attempts to set a fee for a token not in the accepted list and asserts the TokenNotAccepted contract error is returned.
test_set_fee_unauthorized A non-admin address attempts to set a fee and asserts the NotAuthorized contract error is returned.
test_update_fee Sets a fee to 200, updates it to 750, and verifies get_fee reflects the latest value.
test_get_fee_default_zero Verifies get_fee returns 0 for an accepted token with no fee explicitly set.
  • I have added tests that prove my fix is effective or that my feature works
  • All existing tests pass locally
  • I have tested this manually

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

Tests validate all three acceptance criteria: admin-only access enforcement, accepted-token validation, and correct storage/retrieval of fee values. The test structure follows the same patterns established in test_accepted_tokens.rs, using env.as_contract for event assertions and try_* client methods for error-path tests.

@codebestia
codebestia merged commit a233145 into ShadeProtocol:main Feb 22, 2026
4 checks passed
Tijesunimi004 pushed a commit to Tijesunimi004/shade-stellar-contract that referenced this pull request Feb 24, 2026
@KodeSage
KodeSage deleted the feat/fee_management_functionality branch March 24, 2026 16:32
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.

Create Comprehensive Tests for Fee Management Functionality

2 participants