Skip to content

Add test coverage for the token allowance flow (approve -> transfer_from)#673

Open
wheval wants to merge 2 commits into
benelabs:mainfrom
wheval:fix/issue-632-allowance-flow-mock
Open

Add test coverage for the token allowance flow (approve -> transfer_from)#673
wheval wants to merge 2 commits into
benelabs:mainfrom
wheval:fix/issue-632-allowance-flow-mock

Conversation

@wheval

@wheval wheval commented Jul 5, 2026

Copy link
Copy Markdown

Summary

MockToken already wrapped approve/allowance/transfer_from around the real Stellar Asset Contract, but only the approve+allowance-read half of the flow was tested — transfer_from itself had zero coverage.

  • test_transfer_from_uses_allowance: approve, have the spender move part of the allowance, verify both balances and the remaining allowance.
  • test_transfer_from_fails_without_sufficient_allowance: spender attempting to move more than approved reverts (via assert_reverts!), and state is unchanged.

This branch is independent of #672 (the assert_approx_eq! PR), so it also carries the same two tiny pre-existing-bug fixes (unterminated string literal in account.rs, Address Display/Debug formatting in assert_emitted!) needed to get the crate building at all — whichever of the two PRs merges first, the other will just show a trivial conflict on those two lines.

Closes #632

Test plan

  • cargo test -p crucible — 37 tests pass including the 2 new allowance-flow tests

wheval added 2 commits July 5, 2026 17:26
… revert)

MockToken already wrapped approve/allowance/transfer_from around the
Stellar Asset Contract, but transfer_from itself had no test coverage:
only the approve+allowance-read half of the flow was verified.

Adds:
- test_transfer_from_uses_allowance: approve, then have the spender
  move part of the allowance, and verify balances and the remaining
  allowance are all correct.
- test_transfer_from_fails_without_sufficient_allowance: spender
  attempting to move more than approved reverts, and state is
  unchanged.
Same unterminated string literal (account.rs) and Address Display/Debug
formatting bug (macros.rs assert_emitted!) as in benelabs#631 - needed here too
since this branch is based on main directly and won't build without them.
Also commits the ledger snapshot fixtures generated by the two new tests.
@drips-wave

drips-wave Bot commented Jul 5, 2026

Copy link
Copy Markdown

@wheval 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.

Create a mock for the Soroban token contract's allowance flow

1 participant