Skip to content

test(invoice-token): write unit tests for token allowance expiration … - #422

Open
neyij wants to merge 1 commit into
StellarState:devfrom
neyij:test/invoice-token-allowance-expiration-2
Open

test(invoice-token): write unit tests for token allowance expiration …#422
neyij wants to merge 1 commit into
StellarState:devfrom
neyij:test/invoice-token-allowance-expiration-2

Conversation

@neyij

@neyij neyij commented Aug 26, 2026

Copy link
Copy Markdown

…edge cases (#141)

Description

Added comprehensive unit tests for the InvoiceToken allowance expiration mechanism.

The tests cover expired allowance behavior, expiration checks taking precedence over balance validation, partial allowance usage followed by expiration, valid approvals, re-approval after expiration, and the zero-expiry edge case.

These tests ensure that expired allowances cannot be used for transfer_from and that allowance expiration is handled correctly across different ledger timestamps.

Closes #361

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an existing 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
  • 🎨 UI/UX improvement
  • ♻️ Code refactoring
  • ✅ Test addition or update
  • 🔧 Configuration change

Checklist

  • My code follows the code style of this project
  • 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 the allowance expiration behavior is correct
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Testing

Added unit tests covering the InvoiceToken allowance expiration edge cases using the Soroban test environment and mock ledger timestamp advancement.

How to Test

  1. Run the invoice token test suite:
    cargo test -p invoice-token
  2. Verify that an expired allowance prevents transfer_from from succeeding.
  3. Verify that allowance expiration is checked before balance validation.
  4. Verify partial allowance usage followed by expiration, valid approvals, re-approval after expiration, and zero-expiry behavior.

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • E2E tests added/updated (if applicable)
  • Manual testing completed

Screenshots (if applicable)

Not applicable — this change adds contract unit tests and does not affect the user interface.

Additional Notes

The tests use mock ledger timestamp advancement to exercise allowance expiration at different points in time.

The test suite specifically verifies that an expired allowance is rejected even when the spender would otherwise have sufficient balance, ensuring expiration validation takes precedence over balance validation.

For Reviewers

Please focus on:

  • Code quality and readability
  • Test coverage
  • Security implications
  • Performance impact
  • Breaking changes

In particular, review the expiration boundary conditions, timestamp manipulation in the Soroban test environment, zero-expiry behavior, and the ordering of expiration versus balance validation.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

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

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.

test(invoice-token): write unit tests for token allowance expiration edge cases (#141)

2 participants