test(example): pin the buyer gate on register_with - #15
Merged
0dillon merged 1 commit intoAug 7, 2026
Merged
Conversation
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.
Closes #12
Summary
The existing
register_with_needs_the_buyers_authorizationtest removes allauthorizations (
env.set_auths(&[])) and asserts the call fails. That only proves someauthorization is required, not that it is the buyer's — it would pass unchanged if the gate
were
config.seller.require_auth()or any other address inEscrowConfig. Since the buyer gate iswhat stops an arbitrary caller from publishing a manifest under the escrow's address, this PR pins
it with tests that exercise specific addresses.
What changed
Two new tests in
examples/long_escrow/src/test.rs, using the SDK'smock_auths(which replacesthe fixture's blanket
mock_all_authswith a specific list of authorized addresses):register_with_rejects_non_buyer_authorizations— authorizes the seller and a whollyunrelated generated address, but not the buyer, and asserts
register_withstill fails andnever reaches the registry.
register_with_succeeds_with_only_the_buyers_authorization— authorizes only the buyer andasserts
register_withsucceeds and the registry records the escrow.The existing
set_auths(&[])test is untouched and still covers the no-auth case.Key design decisions
mock_authsrather than hand-builtset_authsXDR entries: it registers the no-opMockAuthContractat each address, which is howVoid-signature credentials are accepted inenforcing mode. It also disables the
mock_all_authsfrom the fixture, so a success result isgenuinely attributable to the authorized address alone.
register_with_invocationhelper builds the mockedMockAuthInvoke.buyer.require_auth()(no args) authorizes the current frame, so the entry must name the escrow, the function, and
exactly the arguments the call passes — using the same
.into_val()conversions the generatedclient uses, so the frames compare equal.
contract.require_auth()is satisfied by the invoker check (the escrow is the caller), not by asecond auth entry.
Acceptance criteria
register_withstill fails —register_with_rejects_non_buyer_authorizationsregister_with_succeeds_with_only_the_buyers_authorizationEscrowConfigaddress makes at least one test fail — verified locally by temporarily settingconfig.seller.require_auth(): both new tests failed; reverted before submittingset_auths(&[])test staysChecks
All four CI checks pass locally:
Follow-ups
None. The change is limited to test-only code in
examples/long_escrow.Security note
Test-only change; no production logic touched. No secrets or environment variables involved.