Add test coverage for the token allowance flow (approve -> transfer_from)#673
Open
wheval wants to merge 2 commits into
Open
Add test coverage for the token allowance flow (approve -> transfer_from)#673wheval wants to merge 2 commits into
wheval wants to merge 2 commits into
Conversation
… 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.
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MockTokenalready wrappedapprove/allowance/transfer_fromaround the real Stellar Asset Contract, but only the approve+allowance-read half of the flow was tested —transfer_fromitself 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 (viaassert_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 inaccount.rs,AddressDisplay/Debug formatting inassert_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