test: pin the u64::MAX amount convention for confidential transfers - #1410
Open
pwsaragossy wants to merge 1 commit into
Open
test: pin the u64::MAX amount convention for confidential transfers#1410pwsaragossy wants to merge 1 commit into
pwsaragossy wants to merge 1 commit into
Conversation
Token-2022 cannot know the amount of a confidential transfer, so it hands the transfer hook `u64::MAX` as a convention. Nothing currently tests that from the hook's side: `success_confidential_transfer` asserts balances, and never what the hook was handed. Adds a test hook program that succeeds only on the sentinel, and uses it from both directions so the convention is pinned rather than described: the confidential path lands, and the public path is rejected because there the hook is handed the real amount. The program is a standalone crate built to a committed .so fixture, like the transfer-hook test programs beside it. 14 passed; 0 failed
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.
Token-2022 cannot know the amount of a confidential transfer, so it hands the transfer hook
u64::MAXas a convention:https://github.com/solana-program/token-2022/blob/main/program/src/extension/confidential_transfer/processor.rs#L826-L836
Nothing currently tests that from the hook's side.
success_confidential_transferasserts balances and thetransferringflag, and never what the hook was actually handed — so the convention is enforced by a source comment rather than by the suite.This adds a test hook program that succeeds only when the amount is
u64::MAX, and uses it from both directions so the convention is pinned rather than described:success_confidential_transfer_hook_receives_sentinel_amount— the confidential transfer lands, which it can only do if the hook was handed the sentinel.fail_transfer_hook_receives_real_amount_on_public_path— the same hook on the public path is rejected, because there it is handed the real amount.The pair fails if either half of the convention changes, in either direction.
The program is a standalone crate under
transfer-hook-test-programs/built to a committed.sofixture, like the test programs beside it. It carries its own empty[workspace]table — without one,cargo-build-sbfrefuses on the grounds that the crate believes it is in the root workspace but is not a member. Note the existing test programs hit the same error today, so they cannot currently be rebuilt from the repo; happy to fold a fix for those into this PR or leave it separate, whichever you prefer.Related documentation fix on the interface side: solana-program/transfer-hook#156