Skip to content

test(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests - #24337

Merged
mverzilli merged 7 commits into
merge-train/fairies-v5from
mv/test-token-split
Jun 29, 2026
Merged

test(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests#24337
mverzilli merged 7 commits into
merge-train/fairies-v5from
mv/test-token-split

Conversation

@vezenovm

@vezenovm vezenovm commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

Splits the token used in e2e tests into two contracts:

  • canonical TokenContract (app/token_contract) is unchanged and remains the production / public-docs source of truth. Several of its paths (transfer_to_public, transfer_in_private, burn_private, finalize_transfer_to_private_from_private, ...) use constrained message delivery; plain transfer already uses unconstrained delivery.
  • TestTokenContract (contracts/test/test_token_contract) is its all-unconstrained-delivery sibling, generated from canonical Token at build time by scripts/gen_test_token.sh.

e2e suites where a token is just a unit-of-account vehicle now deploy TestToken. The benchmarks hand-enumerate the exact private calls a flow makes (expectedExecutionSteps); a constrained-delivery path's first send injects an extra handshake bootstrap that the hand-count doesn't include, which inflated the client_flows/amm step count (14 -> 17) once #23866 wired constrained delivery in. With TestToken the bench counts model the app flow again, with no expectedExecutionSteps changes.

Constrained delivery's own cost/behavior stays covered by the dedicated constrained_delivery_test_contract + e2e_constrained_delivery.test.ts.

How

  • scripts/gen_test_token.sh copies app/token_contract, drops the Noir TXE test module, flips all delivery sites to onchain_unconstrained, and renames the contract/package to TestToken / test_token_contract. The generated source is committed and marked generated.

TestToken is regenerated from canonical Token automatically, so the two can't drift:

When Action Why
Local build regenerate in place (bootstrap build) an edited canonical Token shows up in TestToken-based e2e tests before any commit
Commit (precommit hook) regenerate + re-stage keeps the committed source matching canonical Token (accurate diffs / IDE)
CI --check only a stale TestToken fails with a clear message

Regeneration is idempotent (an unchanged Token stays a cache hit), which keeps TestToken a faithful "canonical Token minus the handshake" -- the premise that makes it a valid bench vehicle.

  • token_utils.ts gains deployTestToken; its mint/balance helpers accept either token. getTokenAllowedSetupFunctions now keys the FPC allowlist on the deployed token's class (defaulting to canonical Token), so the benches' TestToken fee vehicle is allowlisted on the right class.

Repointed to TestToken (token is a vehicle)

bench/client_flows/* (the amm bench + its shared base), e2e_amm, forward-compatibility/e2e_amm, e2e_orderbook, e2e_partial_notes, e2e_multiple_accounts_1_enc_key. In the bridging bench only the FPC fee token is repointed; the bridged L2 asset (deployed by CrossChainTestHarness) stays canonical Token, which is harmless because its claim / mint_to_private path doesn't use constrained delivery.

Kept on canonical Token

  • Subject / discovery: e2e_token, the e2e_2_pxes cross-PXE section, e2e_constrained_delivery.
  • Gas / step sensitive (pass on constrained today): e2e_fees/*, e2e_kernelless_simulation.
  • Docs / deploy-mechanism: e2e_deploy_contract/* (the deploy_token docs snippet must show canonical Token).

Context / rationale: https://gist.github.com/AztecBot/ee4c54b9100e4925cde9b2d17e53cdca and the constrained-delivery wiring in #23866.

Follow-ups at the bottom of https://gist.github.com/AztecBot/d3537fa9e1aba8c2e0fe3a9d74698d5f.

… tests

Canonical Token (app/token_contract) uses constrained message delivery and is the production /
docs source of truth. This adds TestToken, its unconstrained-delivery sibling, generated from
canonical Token at build time by scripts/gen_test_token.sh (wired into bootstrap.sh, which fails the
build if the committed TestToken is out of sync). The test module is dropped and the
contract/package renamed; the generated source is committed and locked by a contract-snapshots
expand case.

e2e suites where a token is a unit-of-account vehicle rather than the subject now deploy TestToken
via the new deployTestToken helper (or import TestTokenContract directly): the client_flows benches
and the amm / orderbook / partial_notes / multiple_accounts suites. Constrained delivery's
first-send handshake inflated the client_flows/amm step count (14 -> 17); TestToken has no
handshake, so those counts match again with no expectedExecutionSteps changes. token_utils helpers
are widened to accept either token flavour, and getTokenAllowedSetupFunctions now keys the FPC
allowlist on the deployed token's class (defaulting to canonical Token) so the benches' TestToken
fee vehicle is allowlisted correctly.

Canonical Token stays constrained, kept by the subject/discovery suites (e2e_token,
e2e_blacklist_token, e2e_2_pxes cross-PXE, e2e_constrained_delivery), the gas-sensitive suites
(e2e_fees, e2e_kernelless_simulation), and the docs / deploy-mechanism suites (e2e_deploy_contract).
@vezenovm vezenovm added ci-full Run all master checks. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure labels Jun 26, 2026
@vezenovm vezenovm changed the title feat(noir-contracts): add codegen'd TestToken and repoint vehicle e2e tests feat(noir-contracts): TestToken and repoint vehicle e2e tests Jun 26, 2026
@vezenovm vezenovm changed the title feat(noir-contracts): TestToken and repoint vehicle e2e tests feat(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests Jun 26, 2026
@vezenovm vezenovm changed the title feat(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests chore(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests Jun 26, 2026
vezenovm added 4 commits June 26, 2026 14:39
…snapshot

TestToken is canonical Token with delivery flipped to unconstrained, kept in
sync by gen_test_token.sh --check (wired into noir-contracts bootstrap). Its
nargo expand output differs from canonical token_contract only by delivery mode
and name, so a dedicated expand snapshot adds review surface and double snapshot
churn on every canonical-Token edit without catching anything the --check guard
and the canonical token_contract snapshot don't already cover.
…o CI

TestToken stays committed, but the sync mechanism moves off the local build hot path: the
noir-projects precommit hook now regenerates test_token_contract from canonical Token (and re-stages
it) whenever a token_contract change is committed, matching the existing nargo-fmt precommit pattern.
The build-time gen_test_token.sh --check is gated to CI only, so local builds no longer fail
mid-iteration on an edited Token, while CI still rejects a stale TestToken that bypassed the hook
(e.g. a --no-verify commit). The benches only assert step counts, not gate profiles, so silent
TestToken drift wouldn't otherwise fail CI.
The precommit hook only fires on commit, so an edited canonical Token wasn't reflected in
TestToken-based e2e tests during the local edit-build-test loop -- the build compiled the stale
committed copy. Local builds now regenerate test_token_contract in place before compiling, so e2e
tests exercise the current Token. CI keeps using --check: regenerating mid-run would dirty the tree,
which cache_content_hash rejects in CI, and the committed copy is kept fresh by the precommit hook.
Regen is idempotent, so an unchanged Token stays a cache hit (only a real Token change recompiles it).
Drop the cache_content_hash internals from the comment above the generation step -- understanding how
noir-contracts build shouldn't require knowing CI caching. State the rationale plainly: local builds
regenerate so tests reflect Token edits, CI verifies rather than mutates checked-in files.
@vezenovm vezenovm changed the title chore(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests test(noir-contracts): TestToken with unconstrained delivery and repoint e2e tests Jun 26, 2026
@vezenovm vezenovm added the claudebox Owned by claudebox. it can push to this PR. label Jun 26, 2026
@AztecBot AztecBot added the ci-draft Run CI on draft PRs. label Jun 26, 2026
@mverzilli
mverzilli merged commit 0245dc7 into merge-train/fairies-v5 Jun 29, 2026
18 checks passed
@mverzilli
mverzilli deleted the mv/test-token-split branch June 29, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-draft Run CI on draft PRs. ci-full Run all master checks. ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants