diff --git a/.test_patterns.yml b/.test_patterns.yml index 156f528c2975..682557f971f1 100644 --- a/.test_patterns.yml +++ b/.test_patterns.yml @@ -111,15 +111,15 @@ tests: - regex: "src/single-node/fees/private_payments" owners: - *phil - - regex: "src/e2e_token_contract/access_control" + - regex: "src/automine/token/access_control" error_regex: "HttpRequestError: HTTP request failed." owners: - *charlie - - regex: "src/e2e_lending_contract" + - regex: "src/automine/token/lending" error_regex: "✕ Depositing" owners: - *lasse - - regex: "src/e2e_lending_contract" + - regex: "src/automine/token/lending" error_regex: "✕ Repay" owners: - *lasse @@ -301,6 +301,11 @@ tests: owners: - *palla + - regex: "src/automine/.*\\.test\\.ts" + flake_group_id: e2e-p2p-epoch-flakes + owners: + - *palla + - regex: "p2p/src/client/test/.*\\.test\\.ts" flake_group_id: e2e-p2p-epoch-flakes owners: @@ -396,7 +401,7 @@ tests: - *palla # http://ci.aztec-labs.com/153f5dcbb0f3799c - - regex: "src/e2e_offchain_payment.test.ts" + - regex: "src/automine/effects/offchain_payment.parallel.test.ts" error_regex: "✕ reprocesses an offchain-delivered payment after an L1 reorg" owners: - *martin diff --git a/docs/docs-developers/docs/aztec-js/how_to_deploy_contract.md b/docs/docs-developers/docs/aztec-js/how_to_deploy_contract.md index 4075eb4d3d1d..21d59dd8474b 100644 --- a/docs/docs-developers/docs/aztec-js/how_to_deploy_contract.md +++ b/docs/docs-developers/docs/aztec-js/how_to_deploy_contract.md @@ -59,7 +59,7 @@ On testnet, your account likely won't have Fee Juice. Instead, pay fees using th Here's a complete example from the test suite: -#include_code deploy_basic yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code deploy_basic yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript ## Use deployment options @@ -73,7 +73,7 @@ By default, the deployment's salt is random, but you can specify it (for example Deploy to the same address across networks by setting `universalDeploy: true`: -#include_code deploy_universal yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code deploy_universal yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript :::info Universal deployment excludes the sender from address computation, allowing the same address on any network with the same salt. @@ -89,7 +89,7 @@ Deploy without running the constructor: Some contracts have multiple initializer functions (e.g., both a private `constructor` and a `public_constructor`). By default, the generated `deploy()` method uses the default initializer (typically named `constructor`). To deploy using a different initializer, use `deployWithOpts`: -#include_code deploy_with_opts yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code deploy_with_opts yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript The `deployWithOpts` method accepts an options object as its first argument: @@ -131,7 +131,7 @@ For most use cases, simply await the deployment to get the contract directly: Here's an example deploying a `TokenContract` with constructor arguments for admin, name, symbol, and decimals: -#include_code deploy_token yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code deploy_token yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript ### Deploy contracts with dependencies @@ -155,7 +155,7 @@ Parallel deployment is faster, but transactions from the same account share a no Use `BatchCall` to bundle a deployment with other calls into a single transaction. This is useful when you need to deploy a contract and immediately call methods on it: -#include_code deploy_batch yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code deploy_batch yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript ## Verify deployment @@ -177,7 +177,7 @@ For a complete overview of what these states mean and when functions become call Here's a complete example: -#include_code verify_deployment yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts typescript +#include_code verify_deployment yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts typescript ### What the PXE checks automatically diff --git a/docs/docs-developers/docs/aztec-js/how_to_read_data.md b/docs/docs-developers/docs/aztec-js/how_to_read_data.md index 30152a46b50d..9e7927ef844b 100644 --- a/docs/docs-developers/docs/aztec-js/how_to_read_data.md +++ b/docs/docs-developers/docs/aztec-js/how_to_read_data.md @@ -90,7 +90,7 @@ Use the `getPublicEvents` helper to retrieve typed public events: #include_code import_get_public_events /docs/examples/ts/aztecjs_advanced/index.ts typescript -#include_code get_public_events yarn-project/end-to-end/src/e2e_event_logs.test.ts typescript +#include_code get_public_events yarn-project/end-to-end/src/automine/effects/event_logs.test.ts typescript The function parameters are: @@ -112,7 +112,7 @@ Private events are stored in the PXE with privacy scoping. Use `wallet.getPrivat The `BlockNumber` type is a branded type that wraps raw numbers for type safety. Use it when setting `fromBlock` and `toBlock` in filters. -#include_code get_private_events yarn-project/end-to-end/src/e2e_event_logs.test.ts typescript +#include_code get_private_events yarn-project/end-to-end/src/automine/effects/event_logs.test.ts typescript The `PrivateEventFilter` includes: diff --git a/docs/docs-developers/docs/foundational-topics/call_types.md b/docs/docs-developers/docs/foundational-topics/call_types.md index 3e82185874b1..563f438e9c08 100644 --- a/docs/docs-developers/docs/foundational-topics/call_types.md +++ b/docs/docs-developers/docs/foundational-topics/call_types.md @@ -3,7 +3,7 @@ title: Call Types sidebar_position: 6 tags: [calls, contracts, execution] description: Understand the different types of contract calls in Aztec, including private and public execution modes, and how they compare to Ethereum's call types. -references: ["noir-projects/noir-contracts/contracts/app/auth_contract/src/main.nr", "noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr", "noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr", "noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr", "yarn-project/end-to-end/src/e2e_card_game.test.ts", "yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts"] +references: ["noir-projects/noir-contracts/contracts/app/auth_contract/src/main.nr", "noir-projects/noir-contracts/contracts/app/crowdfunding_contract/src/main.nr", "noir-projects/noir-contracts/contracts/app/lending_contract/src/main.nr", "noir-projects/noir-contracts/contracts/fees/fpc_contract/src/main.nr", "yarn-project/end-to-end/src/automine/card_game.test.ts", "yarn-project/end-to-end/src/automine/token/crowdfunding_and_claim.test.ts"] --- @@ -212,11 +212,11 @@ No correctness is guaranteed on the result of `simulate`! Correct execution is e This creates a transaction, generates proofs for private execution, broadcasts the transaction to the network, and returns a receipt. This is how transactions are sent, getting them to be included in blocks and spending gas. It is similar to [`eth_sendTransaction`](#eth_sendtransaction), except it also performs work on the user's device, namely the production of the proof for the private part of the transaction. -#include_code send_tx yarn-project/end-to-end/src/e2e_card_game.test.ts typescript +#include_code send_tx yarn-project/end-to-end/src/automine/card_game.test.ts typescript You can also use `send` to check for execution failures in testing contexts by expecting the transaction to throw: -#include_code local-tx-fails /yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts typescript +#include_code local-tx-fails /yarn-project/end-to-end/src/automine/token/crowdfunding_and_claim.test.ts typescript ## Next Steps diff --git a/yarn-project/end-to-end/README.md b/yarn-project/end-to-end/README.md index 26248361e2fd..085fac046e10 100644 --- a/yarn-project/end-to-end/README.md +++ b/yarn-project/end-to-end/README.md @@ -1,47 +1,223 @@ -# End to End +# End-to-end tests -This package includes end-to-end tests that cover Aztec's main milestones. -These can be run locally either by starting anvil on a different terminal. +This package holds Aztec's end-to-end (e2e) tests: full-stack scenarios that spin up an Aztec node (or +several), a PXE, and an L1 (anvil) and exercise the system the way a real deployment would. It is the +integration layer above the per-package unit tests. -``` -anvil -p 8545 --host 0.0.0.0 --chain-id 31337 -``` +> **Two audiences.** The top of this document is a quick orientation for humans. The +> [Reference for agents](#reference-for-agents) section at the bottom is the detailed, exhaustive +> version — read that when you are placing, moving, or wiring up a test. -and then running +## Quick start -``` -yarn test +Run a single test (spawns its own in-process anvil): + +```bash +yarn test:e2e src/automine/token/access_control.parallel.test.ts +yarn test:e2e src/single-node/block-building/block_building.test.ts -t 'rejects double spend' ``` -Or by running +Turn up logging with `LOG_LEVEL` (`verbose` is the useful default; `debug:sequencer,archiver` scopes it): +```bash +LOG_LEVEL=verbose yarn test:e2e src/single-node/proving/empty_blocks.test.ts ``` -yarn test:integration -``` -which will spawn the two processes. +Compose-based tests (those under `src/composed/`) need a running local network — see +[Compose / HA / web3signer tests](#compose--ha--web3signer-tests). + +## Test categories + +Tests are grouped by **node topology** — the shape of the network a test needs. The top-level folder is +the category; the second level names the behavior under test. Each category owns a base class that builds +its environment, so a test file only describes the scenario, not the wiring. + +| Category | Topology | A test belongs here when… | README | +|---|---|---|---| +| [`automine/`](src/automine/README.md) | One node, deterministic `AutomineSequencer` — one block per tx, no committee/prover/validator. Fast. | it exercises contract or protocol behavior that doesn't depend on real block-building or consensus (transfers, nested calls, note discovery, tx semantics). | yes | +| [`single-node/`](src/single-node/README.md) | One node, production sequencer (interval block production), optional prover. | it asserts on sequencer, proving, partial-proof, L1-reorg, recovery, fee, or cross-chain behavior on a single sequencer. | yes | +| [`multi-node/`](src/multi-node/README.md) | N validators on an in-memory mock-gossip bus. | it needs a committee: consensus, attestations, slashing, governance, or multi-validator block production. | yes | +| `p2p/` | Real libp2p transport between nodes. | the networking transport itself is under test (gossip, rediscovery, req/resp). | — | +| [`infra/`](src/infra/README.md) | Targets a deployed/external network (local anvil or a public testnet). | its concern is deployment or network targeting, not a specific protocol behavior. | yes | + +A handful of tests live **outside** this package, next to the code they test — see +[Tests that live elsewhere](#tests-that-live-elsewhere). Other non-category test groups (`composed/`, +`guides/`, `bench/`) are described in the reference section. + +## Where does my test go? + +1. **Does it need real networking transport?** → `p2p/`. +2. **Does it need a validator committee (consensus/slashing/governance)?** → `multi-node/`. +3. **Does it assert on the production sequencer, proving, reorgs, fees, or cross-chain flows?** → + `single-node/`. +4. **Is it pure contract/protocol behavior that's happy with one-block-per-tx?** → `automine/` (the + default home for most contract tests). +5. **Is it really a unit/integration test of one package with no Aztec node?** → it probably belongs in + that package, not here (see [Tests that live elsewhere](#tests-that-live-elsewhere)). + +When in doubt, prefer `automine/` for contract behavior and `single-node/` for anything that watches the +chain advance. + +--- + +## Reference for agents + +This section is the detailed contract for adding, moving, and wiring tests. It assumes you've read the +overview above. + +### Category base classes + +Each category centralizes its environment in a base class. The hierarchy: + +- `single-node/single_node_test_context.ts` → **`SingleNodeTestContext`**. Owns the environment + (in-process anvil + L1 deploy), node spawning (`createNonValidatorNode`, `createProverNode`), the + `ChainMonitor`, and the epoch/checkpoint/proof-window/reorg waiters. +- `multi-node/multi_node_test_context.ts` → **`MultiNodeTestContext extends SingleNodeTestContext`**. + Adds the N-validator topology over a mock-gossip bus, inheriting the base environment and waiters. +- `automine/automine_test_context.ts` → **`AutomineTestContext`**. A sibling of `SingleNodeTestContext` + (both wrap `fixtures/setup.ts:setup()`), but fixes the automine topology and makes `AUTOMINE_E2E_OPTS` + the default. Exposes `markProvenAndWarp`, `registerContract`, `applyManualParentChild`. +- `p2p/p2p_network.ts` → **`P2PNetworkTest`**. Real libp2p; node creation goes through + `setup_p2p_test.ts`. +- `infra/` has no shared base — its tests target a network selected by `L1_CHAIN_ID` (local anvil in CI, + a public testnet with credentials). + +All of the above ultimately wrap `fixtures/setup.ts:setup(numberOfAccounts, opts)`, the single entry point +that deploys L1 contracts, starts the node(s), and provisions a PXE and accounts. + +### Setup factories + +Categories expose thin factories over their base's static `setup`, named by what the test wants, so a test +calls the factory instead of spreading option presets: + +- `single-node/setup.ts`: `setupWithProver` (fake in-process prover — the single-node default) and + `setupBlockProducer` (no prover; raises `aztecProofSubmissionEpochs` to `1024` so unproven blocks + aren't pruned, and points the PXE at `syncChainTip: 'proposed'`). +- `automine` tests call `AutomineTestContext.setup({ numberOfAccounts })` directly. + +### The harness pattern (domain setup on top of a category) + +A test suite with bespoke domain setup does **not** fork `setup()`. It subclasses the category base and +overrides a `protected hydrateFromContext(context)` split out of `setup`, so it reuses the base's +rollup/epoch-cache/chain-monitor/waiter/teardown machinery while adding its own domain state. Examples: + +- `single-node/prover/` → `FullProverTest` (real Barretenberg env) extends `SingleNodeTestContext`. +- `single-node/fees/` → `FeesTest`; `single-node/cross-chain/` → `CrossChainMessagingTest`. +- `automine/token/` → `TokenContractTest` and `BlacklistTokenContractTest` extend `AutomineTestContext` + and run their `TokenSimulator`/snapshot setup after `super.setup()`. + +When two suites share behavior: if their public APIs are nearly identical, use inheritance; if behavior +overlaps but APIs differ, compose. Don't duplicate a category's environment wiring. + +### The `.parallel` suffix -You can also run this by `docker-compose up` which will spawn 2 different containers for Anvil and the test runner. +CI splits each `it` in a `.parallel.test.ts` file into its own docker job, running it in isolation via +`jest --testNamePattern` (the names come from `extract_test_names` in `bootstrap.sh`, which matches +`it`/`test` at **any** nesting depth, not just top level). When an `it` runs alone its enclosing +`beforeAll`/`beforeEach` hooks still run, but sibling `it`s do not. Rules: -You can run a single test by running `yarn test:compose `. +- The `.parallel` suffix is for files whose `it`s are **independent**: every `it` must pass when run + entirely on its own. That holds only when all shared state is built in `beforeAll`/`beforeEach` and no + `it` reads or asserts on state produced by a sibling `it`. +- A file with sequential or stateful `it`s (progressive mutation across `it`s, a describe-scope variable + assigned in one `it` and read in another, a note/token created in an earlier `it` and used later) stays + a plain `.test.ts` **even if it has many top-level `it`s** — it runs as one ordered job. Adding + `.parallel` to such a file breaks CI, because each `it` then runs without its predecessors. +- A file with a single top-level `it` is a plain `.test.ts`. +- `it`/`test` names in a `.parallel` file must avoid regex/shell-special characters — + `"` `(` `)` `[` `]` `{` `}` `$` `\` and backtick. The split passes each name to + `run_test.sh ... ""` as a shell-quoted `--testNamePattern` regex: an embedded `"` closes the + quote early and hard-fails the job, while regex metacharacters (`(` `)` `[` `]` `+` `*` `?` `|` `{` `}`) + silently match zero tests so the shard runs nothing and passes green — a coverage gap that hides the + test. Plain `.test.ts` files run as one job and are unaffected, so any name is fine there. + (`.` `!` `#` `-` `:` `,` are safe in `.parallel` names.) +- Each file has exactly one top-level `describe`, named to match its path + (e.g. `describe('automine/token/transfer', …)`). + +### CI test discovery — `bootstrap.sh` -## Running tests against legacy contract artifacts +`end-to-end/bootstrap.sh` enumerates tests in two arrays, and a test must appear in the relevant one or it +**won't run in CI**: + +- `test_cmds` (~line 37) — the standard run. +- `compat_test_cmds` (~line 290) — the forward/legacy-compat run (a subset). + +Each leaf folder needs its own single-level glob line (e.g. `src/automine/token/*.test.ts`) in each array; +globs are not recursive, so every sub-folder is listed explicitly. Folders that organize by behavior get +one line per leaf. Bespoke handling to be aware of: + +- **`avm_simulator`** (`automine/simulation/avm_simulator.test.ts`) has a dedicated line in `test_cmds` + that sets `DUMP_AVM_INPUTS_TO_DIR` (feeds the downstream `avm_check_circuit` job) and is therefore + excluded from the generic `simulation/` glob there (`!(avm_simulator)`). In `compat_test_cmds` it runs + as a regular test (no dump line), so it is **not** excluded there. +- **`kernelless_simulation`** is excluded from `compat_test_cmds` only. + +After editing the arrays, confirm every `*.test.ts` resolves through exactly one line (no duplicate, no +omission). Per-test bash `TIMEOUT` overrides live in the `case` block in `test_cmds` and must stay in sync +with the test's `jest.setTimeout`. + +### Flaky tests — `.test_patterns.yml` + +Flaky/owner entries live in `.test_patterns.yml` at the **git root** (not in this package), keyed on the +test path. A bare entry flags the test as flaky whenever it fails; add `error_regex` to flag only on a +matching message; `skip: true` disables it. Blanket regex entries (e.g. `src/automine/.*\.test\.ts`) are +depth-agnostic and survive folder renames; path-specific entries must be updated when a file moves. + +### Compose / HA / web3signer tests + +`src/composed/` tests run against a **running local network** rather than an in-process stack, via +`scripts/run_test.sh` in different modes: + +- `src/composed/*.test.ts` → `compose` mode (e.g. `e2e_persistence`, `uniswap_trade_on_l1_from_l2`, + `e2e_cheat_codes` — the compose variant, distinct from the relocated unit-style one). +- `src/composed/web3signer/*.test.ts` → `web3signer` mode (remote-signer scenarios). +- `src/composed/ha/*.test.ts` → `ha` mode (high-availability multi-process scenarios). +- `src/guides/*.test.ts` → tutorial/guide flows; `src/bench/` → benchmarks (see `bench_cmds`). + +Run one compose test locally with `yarn test:compose ` (anvil + the test runner are spawned for +you), or `docker-compose up` for separate containers. + +### Tests that live elsewhere + +Tests with **no Aztec node** that exercise one package belong in that package, not here: + +- L1 cheat-code behavior (`EthCheatCodes`/`RollupCheatCodes` against raw anvil) → `@aztec/ethereum` + (`ethereum/src/test/eth_cheat_codes.test.ts`). +- The `SequencerPublisher` integration test (anvil + L1 deploy, no node) → `@aztec/sequencer-client` + (`sequencer-client/src/publisher/`). + +These run in their own package's test lane (both packages already run anvil-backed integration tests). + +### Support directories (not test categories) + +- `fixtures/` — the shared `setup()`, option presets (`fixtures.ts`), `CrossChainTestHarness`, + `l1_to_l2_messaging`, and common utils. +- `shared/` — shared test bodies and `timing_env.mjs`, a **custom jest `testEnvironment`** referenced from + this package's `package.json`. `yarn prepare` / the package-json check will try to revert it to the + default — don't let it. +- `simulators/` — in-TS reference models (`TokenSimulator`, `LendingSimulator`) used to assert contract + behavior. +- `test-wallet/`, `bench/`, `spartan/`, `quality_of_service/`, `forward-compatibility/` — helpers, + benchmarks, and network/ops tests outside the topology categories. + +### Running tests against legacy contract artifacts To verify that contracts deployed from a previous release still work against the current stack, set -`CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` / `@aztec/noir-test-contracts.js`: +`CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` / +`@aztec/noir-test-contracts.js`: -``` -CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/e2e_amm.test.ts +```bash +CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/automine/token/access_control.parallel.test.ts ``` Only the JSON artifact files (`.../artifacts/*.json`) are redirected. The TypeScript wrapper classes -(e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` — so this -exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client, not whether the -legacy wrapper code still imports cleanly. +(e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` — +so this exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client, +not whether the legacy wrapper code still imports cleanly. -The first run downloads the pinned packages into `.legacy-contracts//node_modules/` (cached across runs). A -startup banner and a per-redirect line are printed to stderr so you can confirm the legacy artifacts were actually -loaded: +The first run downloads the pinned packages into `.legacy-contracts//node_modules/` (cached across +runs). A startup banner and a per-redirect line are printed to stderr so you can confirm the legacy +artifacts were actually loaded: ``` [legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=4.1.3 @@ -49,5 +225,5 @@ loaded: [legacy-contracts][jest] redirected token_contract-Token.json -> /abs/.../.legacy-contracts/4.1.3/.../token_contract-Token.json ``` -When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The cache is -populated automatically on first use. +When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The +cache is populated automatically on first use. diff --git a/yarn-project/end-to-end/bootstrap.sh b/yarn-project/end-to-end/bootstrap.sh index a266ebac13fb..66c67cbde687 100755 --- a/yarn-project/end-to-end/bootstrap.sh +++ b/yarn-project/end-to-end/bootstrap.sh @@ -32,11 +32,19 @@ function test_cmds { else echo "$prefix:NAME=e2e_prover_full_fake FAKE_PROOFS=1 $run_test_script simple single-node/prover/full" fi - echo "$prefix:TIMEOUT=30m:NAME=e2e_avm_simulator $(set_dump_avm e2e_avm_simulator) $run_test_script simple src/e2e_avm_simulator.test.ts" + echo "$prefix:TIMEOUT=30m:NAME=automine/simulation/avm_simulator $(set_dump_avm e2e_avm_simulator) $run_test_script simple src/automine/simulation/avm_simulator.test.ts" local tests=( # List all standalone and nested tests, except for the ones listed above. src/e2e_*/*.test.ts + src/automine/*.test.ts + src/automine/contracts/*.test.ts + src/automine/contracts/deploy/*.test.ts + src/automine/contracts/nested/*.test.ts + src/automine/token/*.test.ts + src/automine/accounts/*.test.ts + src/automine/effects/*.test.ts + src/automine/simulation/!(avm_simulator).test.ts src/single-node/block-building/*.test.ts src/single-node/proving/*.test.ts src/single-node/l1-reorgs/*.test.ts @@ -296,6 +304,14 @@ function compat_test_cmds { local tests=( src/e2e_*/*.test.ts + src/automine/*.test.ts + src/automine/contracts/*.test.ts + src/automine/contracts/deploy/*.test.ts + src/automine/contracts/nested/*.test.ts + src/automine/token/*.test.ts + src/automine/accounts/*.test.ts + src/automine/effects/*.test.ts + src/automine/simulation/!(kernelless_simulation).test.ts src/single-node/fees/*.test.ts src/single-node/cross-chain/*.test.ts src/single-node/bot/*.test.ts @@ -306,9 +322,10 @@ function compat_test_cmds { ) for test in "${tests[@]}"; do local name - if [[ "$test" == src/p2p/* ]]; then - # The p2p/ folder has no `e2e_` prefix to strip; flatten its path into an e2e_p2p_ name - # (matching the historical e2e_p2p/ names) by dropping "src/", ".test.ts", and slashes. + if [[ "$test" == src/p2p/* || "$test" == src/automine/* ]]; then + # The p2p/ and automine/ folders have no `e2e_` prefix to strip; flatten their path into an + # e2e_ name (matching the historical e2e_p2p/ names) by dropping "src/", ".test.ts", + # and slashes. name=${test#src/} name=e2e_${name%.test.ts} name=${name//\//_} diff --git a/yarn-project/end-to-end/eslint.config.js b/yarn-project/end-to-end/eslint.config.js index 44e11c1365c6..47c0640f3663 100644 --- a/yarn-project/end-to-end/eslint.config.js +++ b/yarn-project/end-to-end/eslint.config.js @@ -21,7 +21,7 @@ export default [ }, }, { - files: ['src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts'], + files: ['src/automine/contracts/fixtures/storage_proof_fetcher.ts'], rules: { camelcase: 'off', 'no-console': 'off', diff --git a/yarn-project/end-to-end/src/automine/README.md b/yarn-project/end-to-end/src/automine/README.md new file mode 100644 index 000000000000..1a48533aba10 --- /dev/null +++ b/yarn-project/end-to-end/src/automine/README.md @@ -0,0 +1,60 @@ +# `automine` e2e test category + +Automine tests run a single Aztec node driving the deterministic `AutomineSequencer`: one block per +submitted transaction, synchronous L1 publish, no committee, no prover, and no validator client. The +node opts into this topology through the `AUTOMINE_E2E_OPTS` preset (`fixtures/fixtures.ts`), which the +base context applies by default. This is the fast, deterministic counterpart to the `single-node` +category, whose node runs the production sequencer with interval block production. A test belongs here +when it exercises contract or protocol behavior that does not depend on real block-building or consensus +(token transfers, nested calls, note discovery, tx semantics); it belongs in `single-node` when it +asserts on sequencer, proving, or reorg behavior. + +## Base class + +All tests use `AutomineTestContext` (`automine_test_context.ts`), which owns: + +- The environment: an in-process anvil in automine mode plus the L1 contract deploy, wrapping + `fixtures/setup.ts:setup()` with `AUTOMINE_E2E_OPTS` and `fundSponsoredFPC` as defaults. +- The common handles: `context`, `wallet`, `aztecNode`, `aztecNodeAdmin`, `cheatCodes`, `sequencer`, + `accounts`, `defaultAccountAddress`, `logger`. +- `markProvenAndWarp(seconds)`: marks pending checkpoints proven before warping the L2 clock, so a long + warp does not trip the rollup's pruning window (see the method's doc comment). +- `registerContract(...)`: computes and registers a contract instance without an on-chain deploy. +- `applyManualParentChild()`: deploys a Parent and Child contract for the nested-call tests. + +Tests call the static `AutomineTestContext.setup({ numberOfAccounts })` factory (or `new` plus `setup()` +for the harness subclasses), passing `numberOfAccounts` rather than spreading `AUTOMINE_E2E_OPTS`. + +## Harnesses + +Two domain harnesses extend `AutomineTestContext` and run their domain setup after `super.setup()`: + +- `token/token_contract_test.ts` — a `TokenSimulator` plus opt-in base/mint snapshots for the Token + contract tests. +- `token/blacklist_token_contract_test.ts` — a `TokenSimulator`, the `Role` helper, and the + role-change-delay warp (via `markProvenAndWarp`) for the TokenBlacklist tests. + +## Organizing principle + +The top level groups tests by node topology (automine); the second level names the primary behavior +under test rather than the shared setup. Each file has a single top-level `describe` named to match its +path. A `.parallel` suffix marks files with more than one top-level `it`; CI splits each `it` into its +own job. + +## Subfolders + +A second-level folder is created only when it earns its keep: a shared harness, an existing sub-hierarchy, +or a coherent domain of several files. The remaining miscellaneous protocol/execution behaviors live as flat +files directly under `automine/` — smoke, tx ordering/double-spend/phase checks, mempool limits, the app demos +(card game, private voting), and the timestamp/PXE tests. + +| Path | Contents | +|---|---| +| `token/` | Token-economics tests on the two token harnesses plus the `TokenSimulator`/`LendingSimulator`-adjacent DeFi tests: token transfers/minting/burning/access-control, the blacklist token suite, AMM, lending, NFT, orderbook, crowdfunding, and escrow. | +| `contracts/` | Contract lifecycle and cross-contract behavior. `deploy/` (class registration, deploy method, legacy deploy, private initialization), `nested/` (importer and the manual private/public nested-call patterns), plus contract updates, storage proofs, static calls, nested utility calls, and the ABI/storage-surface tests (ABI types, option params, state variables). | +| `accounts/` | Account and key behavior: account contracts, keys, multiple accounts sharing an encryption key, two-PXE interop, authwit, and scope isolation. | +| `effects/` | Note discovery, events, and offchain effects: note getters, pending note hashes, partial notes, event logs, event-only notes, offchain effects and payments, large public events, custom messages, the tx-effect oracle, and note rediscovery after pruned blocks. | +| `simulation/` | Circuit simulation surface: the AVM simulator, kernelless simulation, and the circuit recorder. | + +The `simulation/avm_simulator` file is a genuine outlier: it dumps AVM circuit inputs for the downstream +`avm_check_circuit` CI job, so it has a bespoke CI line and is excluded from the generic `simulation/` glob. diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/automine/accounts/2_pxes.parallel.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_2_pxes.test.ts rename to yarn-project/end-to-end/src/automine/accounts/2_pxes.parallel.test.ts index 08a5bd43db6d..65e2531f02dc 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/2_pxes.parallel.test.ts @@ -10,10 +10,10 @@ import type { AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; import { expect, jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, expectTokenBalance, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup, setupPXEAndGetWallet } from './fixtures/utils.js'; -import { TestWallet } from './test-wallet/test_wallet.js'; +import { deployToken, expectTokenBalance, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import { setupPXEAndGetWallet } from '../../fixtures/utils.js'; +import { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -21,7 +21,7 @@ const TIMEOUT = 300_000; // account keys. Exercises note decryption scoping, contract registration ordering, and deferred-note // reprocessing when a contract is registered late. setup(1, AUTOMINE_E2E_OPTS) provides one node with // automine sequencer; a second PXE is attached via setupPXEAndGetWallet. -describe('e2e_2_pxes', () => { +describe('automine/accounts/2_pxes', () => { jest.setTimeout(TIMEOUT); let aztecNode: AztecNode & AztecNodeDebug; @@ -59,10 +59,12 @@ describe('e2e_2_pxes', () => { logger, teardown: teardownA, // accountA is the default initializerless account; accountB/C are created+deployed from these. - } = await setup(1, { - ...AUTOMINE_E2E_OPTS, - additionallyFundedAccounts: await generateSchnorrAccounts(3, 'schnorr'), - })); + } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 1, + additionallyFundedAccounts: await generateSchnorrAccounts(3, 'schnorr'), + }) + ).context); ({ wallet: walletB, @@ -153,7 +155,7 @@ describe('e2e_2_pxes', () => { // Mints private balances for two accounts, each on their own PXE. Verifies that querying // the balance for account A from PXE B returns 0 (key not registered), and vice versa. - it('private state is "zero" when PXE does not have the account secret key', async () => { + it('private state is zero when PXE does not have the account secret key', async () => { const userABalance = 100n; const userBBalance = 150n; diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/automine/accounts/account_contracts.test.ts similarity index 92% rename from yarn-project/end-to-end/src/e2e_account_contracts.test.ts rename to yarn-project/end-to-end/src/automine/accounts/account_contracts.test.ts index a082d3dfb8da..2395232b287c 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/account_contracts.test.ts @@ -17,10 +17,9 @@ import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; import { createPXE, getPXEConfig } from '@aztec/pxe/server'; import { deriveSigningKey } from '@aztec/stdlib/keys'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import { TestWallet } from './test-wallet/test_wallet.js'; -import { AztecNodeProxy } from './test-wallet/utils.js'; +import { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AztecNodeProxy } from '../../test-wallet/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; export class TestWalletInternals extends TestWallet { static override async create(node: AztecNode): Promise { @@ -64,10 +63,12 @@ const itShouldBehaveLikeAnAccountContract = ( address, }; - ({ logger, teardown, aztecNode } = await setup(0, { - ...AUTOMINE_E2E_OPTS, - additionallyFundedAccounts: [accountData], - })); + ({ logger, teardown, aztecNode } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 0, + additionallyFundedAccounts: [accountData], + }) + ).context); wallet = await TestWalletInternals.create(aztecNode); const accountManager = await wallet.createAccount({ secret, contract, salt }); @@ -120,7 +121,7 @@ const itShouldBehaveLikeAnAccountContract = ( // setup(0, AUTOMINE_E2E_OPTS) with an additionallyFundedAccounts override, one node, automine sequencer, // no extra nodes. (v5: added the initializerless variant and renamed initialFundedAccounts → // additionallyFundedAccounts.) -describe('e2e_account_contracts', () => { +describe('automine/accounts/account_contracts', () => { describe('schnorr account', () => { itShouldBehaveLikeAnAccountContract(() => new SchnorrAccountContract(GrumpkinScalar.random())); }); diff --git a/yarn-project/end-to-end/src/e2e_authwit.test.ts b/yarn-project/end-to-end/src/automine/accounts/authwit.test.ts similarity index 93% rename from yarn-project/end-to-end/src/e2e_authwit.test.ts rename to yarn-project/end-to-end/src/automine/accounts/authwit.test.ts index fadf558e9b19..cf3f624d972e 100644 --- a/yarn-project/end-to-end/src/e2e_authwit.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/authwit.test.ts @@ -8,17 +8,18 @@ import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-r import { jest } from '@jest/globals'; -import { sendThroughAuthwitProxy } from './fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from './fixtures/fixtures.js'; -import { type EndToEndContext, ensureAuthRegistryPublished, setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { sendThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../fixtures/fixtures.js'; +import { type EndToEndContext, ensureAuthRegistryPublished } from '../../fixtures/utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Tests the authorization witness (authwit) system in both private and public contexts. // Uses setup(2, AUTOMINE_E2E_OPTS) providing one node with automine sequencer and two accounts. // Accounts are publicly deployed and the AuthRegistry is published before any test runs. -describe('e2e_authwit_tests', () => { +describe('automine/accounts/authwit', () => { jest.setTimeout(TIMEOUT); let wallet: TestWallet; @@ -34,7 +35,7 @@ describe('e2e_authwit_tests', () => { teardown, wallet, accounts: [account1Address, account2Address], - } = await setup(2, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 2 })).context); await ensureAuthRegistryPublished(wallet, account1Address); ({ contract: auth } = await AuthWitTestContract.deploy(wallet).send({ from: account1Address })); diff --git a/yarn-project/end-to-end/src/e2e_keys.test.ts b/yarn-project/end-to-end/src/automine/accounts/keys.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_keys.test.ts rename to yarn-project/end-to-end/src/automine/accounts/keys.test.ts index 249c3e8a283b..84741d202d5f 100644 --- a/yarn-project/end-to-end/src/e2e_keys.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/keys.test.ts @@ -18,16 +18,15 @@ import { import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Covers cryptographic key derivation and usage: nhk_app-based nullification detection and // ovsk_app retrieval via the TestContract. Single automine node, one funded Schnorr account, // TestContract deployed in beforeAll. -describe('Keys', () => { +describe('automine/accounts/keys', () => { jest.setTimeout(TIMEOUT); let aztecNode: AztecNode; @@ -42,7 +41,9 @@ describe('Keys', () => { beforeAll(async () => { // This test needs the account's secret, so we provide and create the account ourselves. const [account] = await generateSchnorrAccounts(1); - ({ aztecNode, teardown, wallet } = await setup(0, { ...AUTOMINE_E2E_OPTS, additionallyFundedAccounts: [account] })); + ({ aztecNode, teardown, wallet } = ( + await AutomineTestContext.setup({ numberOfAccounts: 0, additionallyFundedAccounts: [account] }) + ).context); await wallet.createSchnorrInitializerlessAccount(account.secret, account.salt, account.signingKey); defaultAccountAddress = account.address; secret = account.secret; diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/automine/accounts/multiple_accounts_1_enc_key.test.ts similarity index 90% rename from yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts rename to yarn-project/end-to-end/src/automine/accounts/multiple_accounts_1_enc_key.test.ts index d5467db40532..e882ca1ed254 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/multiple_accounts_1_enc_key.test.ts @@ -4,15 +4,14 @@ import { Fr, GrumpkinScalar } from '@aztec/aztec.js/fields'; import type { Logger } from '@aztec/aztec.js/log'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, expectTokenBalance } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { deployToken, expectTokenBalance } from '../../fixtures/token_utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Verifies that the PXE correctly handles multiple Schnorr accounts sharing the same encryption // key (different signing keys). Checks that note discovery and balance tracking remain accurate // across three accounts. Uses AUTOMINE_E2E_OPTS with 3 custom accounts sharing one secret. -describe('e2e_multiple_accounts_1_enc_key', () => { +describe('automine/accounts/multiple_accounts_1_enc_key', () => { let wallet: TestWallet; let accounts: AztecAddress[] = []; let logger: Logger; @@ -45,10 +44,12 @@ describe('e2e_multiple_accounts_1_enc_key', () => { }), ); - ({ teardown, logger, wallet } = await setup(0, { - ...AUTOMINE_E2E_OPTS, - additionallyFundedAccounts: accountsData, - })); + ({ teardown, logger, wallet } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 0, + additionallyFundedAccounts: accountsData, + }) + ).context); for (const a of accountsData) { await wallet.createSchnorrInitializerlessAccount(a.secret, a.salt, a.signingKey); } diff --git a/yarn-project/end-to-end/src/e2e_scope_isolation.test.ts b/yarn-project/end-to-end/src/automine/accounts/scope_isolation.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_scope_isolation.test.ts rename to yarn-project/end-to-end/src/automine/accounts/scope_isolation.test.ts index 3fe04430785a..67bc78be7aa5 100644 --- a/yarn-project/end-to-end/src/e2e_scope_isolation.test.ts +++ b/yarn-project/end-to-end/src/automine/accounts/scope_isolation.test.ts @@ -2,13 +2,12 @@ import type { AztecAddress } from '@aztec/aztec.js/addresses'; import type { Wallet } from '@aztec/aztec.js/wallet'; import { ScopeTestContract } from '@aztec/noir-test-contracts.js/ScopeTest'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Verifies that PXE note access and key-derivation are scoped per account: a different account // cannot read another's notes or derive their nullifier hiding key. Uses a single node with // AutomineSequencer and three accounts (alice, bob, charlie). -describe('e2e scope isolation', () => { +describe('automine/accounts/scope_isolation', () => { let wallet: Wallet; let accounts: AztecAddress[]; let teardown: () => Promise; @@ -22,7 +21,7 @@ describe('e2e scope isolation', () => { const BOB_NOTE_VALUE = 100n; beforeAll(async () => { - ({ teardown, wallet, accounts } = await setup(3, { ...AUTOMINE_E2E_OPTS })); + ({ teardown, wallet, accounts } = (await AutomineTestContext.setup({ numberOfAccounts: 3 })).context); [alice, bob, charlie] = accounts; ({ contract } = await ScopeTestContract.deploy(wallet).send({ from: alice })); diff --git a/yarn-project/end-to-end/src/automine/automine_test_context.ts b/yarn-project/end-to-end/src/automine/automine_test_context.ts new file mode 100644 index 000000000000..135b77220b65 --- /dev/null +++ b/yarn-project/end-to-end/src/automine/automine_test_context.ts @@ -0,0 +1,153 @@ +import type { ContractArtifact } from '@aztec/aztec.js/abi'; +import type { AztecAddress } from '@aztec/aztec.js/addresses'; +import { type ContractBase, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts'; +import { Fr } from '@aztec/aztec.js/fields'; +import type { PublicKeys } from '@aztec/aztec.js/keys'; +import type { Logger } from '@aztec/aztec.js/log'; +import type { AztecNode } from '@aztec/aztec.js/node'; +import type { Wallet } from '@aztec/aztec.js/wallet'; +import type { CheatCodes } from '@aztec/aztec/testing'; +import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; +import { ParentContract } from '@aztec/noir-test-contracts.js/Parent'; +import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest'; +import type { PXEConfig } from '@aztec/pxe/config'; +import type { SequencerClient } from '@aztec/sequencer-client'; +import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; + +import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; +import { type EndToEndContext, type SetupOptions, setup, teardown } from '../fixtures/setup.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; + +export type AutomineTestOpts = Partial & { + /** Number of accounts to create and deploy during setup. */ + numberOfAccounts?: number; + /** Options forwarded to PXE creation. */ + pxeOpts?: Partial; +}; + +/** + * Base class for the automine-sequencer test topology: a single in-process node running the + * deterministic {@link AUTOMINE_E2E_OPTS} preset (one block per submitted tx, synchronous L1 publish, + * no committee, no prover, no validator client). Owns the environment (in-proc anvil in automine mode + * plus the L1 deploy) and exposes the handles every automine test uses (`wallet`, `aztecNode`, + * `cheatCodes`, `sequencer`, `accounts`, `logger`). + * + * The sibling of {@link SingleNodeTestContext}: both wrap the same underlying `fixtures/setup.ts:setup()` + * but fix opposite sequencer topologies. Making {@link AUTOMINE_E2E_OPTS} the base default removes the + * per-test-file spread every automine test would otherwise repeat. + * + * Domain harnesses (the token simulators) compose on top by extending this base and overriding + * {@link setup} to run their domain steps after `super.setup()`. + */ +export class AutomineTestContext { + public context!: EndToEndContext; + public logger!: Logger; + public wallet!: TestWallet; + public aztecNode!: AztecNode & AztecNodeDebug; + public aztecNodeAdmin!: AztecNodeAdmin; + public cheatCodes!: CheatCodes; + public sequencer!: SequencerClient; + public accounts!: AztecAddress[]; + public defaultAccountAddress!: AztecAddress; + + public parentContract!: ParentContract; + public childContract!: ChildContract; + + public static async setup(this: new () => T, opts: AutomineTestOpts = {}): Promise { + const test = new this(); + await test.setup(opts); + return test; + } + + public async setup(opts: AutomineTestOpts = {}): Promise { + const { numberOfAccounts = 1, pxeOpts, ...setupOpts } = opts; + const context = await setup( + numberOfAccounts, + { + ...AUTOMINE_E2E_OPTS, + fundSponsoredFPC: true, + ...setupOpts, + }, + pxeOpts, + ); + await this.hydrateFromContext(context); + } + + /** + * Populates the context-derived handles from an already-built {@link EndToEndContext}. Split out of + * {@link setup} so domain harnesses that build the environment with their own bespoke `setup(...)` + * opts can still reuse the shared handle wiring. + */ + protected hydrateFromContext(context: EndToEndContext): Promise { + this.context = context; + this.logger = context.logger; + this.wallet = context.wallet; + this.aztecNode = context.aztecNodeService; + this.aztecNodeAdmin = context.aztecNodeService; + this.cheatCodes = context.cheatCodes; + this.sequencer = context.sequencer!; + this.accounts = context.accounts; + this.defaultAccountAddress = context.accounts[0]; + return Promise.resolve(); + } + + public async teardown(): Promise { + await teardown(this.context); + } + + /** + * Marks the current pending checkpoints as proven, then warps the L2 clock forward by `seconds`. + * + * Under {@link AUTOMINE_E2E_OPTS} a long warp crosses many epochs with no proofs being submitted, so + * without a prior `markAsProven()` the rollup contract's pruning window resets the chain tip to genesis + * and the warp's own empty-checkpoint propose fails with `Rollup__InvalidArchive`. Marking proven before + * warping keeps the pending chain alive. Composes the existing `cheatCodes.rollup.markAsProven` and + * `warpL2TimeAtLeastBy` with that required ordering. + */ + public async markProvenAndWarp(seconds: number | bigint): Promise { + await this.cheatCodes.rollup.markAsProven(); + await this.cheatCodes.warpL2TimeAtLeastBy(this.aztecNode, seconds); + } + + /** Computes and registers a contract instance in the wallet without deploying it on-chain. */ + public async registerContract( + wallet: Wallet, + contractArtifact: ContractArtifactClass, + opts: { + salt?: Fr; + publicKeys?: PublicKeys; + initArgs?: any[]; + constructorName?: string; + deployer?: AztecAddress; + } = {}, + ): Promise { + const { salt, publicKeys, initArgs, constructorName, deployer } = opts; + const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, { + constructorArgs: initArgs ?? [], + constructorArtifact: constructorName, + salt: salt ?? Fr.random(), + publicKeys, + deployer, + }); + await wallet.registerContract(instance, contractArtifact.artifact); + return contractArtifact.at(instance.address, wallet); + } + + /** Deploys a Parent and a Child contract from the default account for the nested-call tests. */ + public async applyManualParentChild(): Promise { + this.logger.info('Deploying parent and child contracts'); + ({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({ + from: this.defaultAccountAddress, + })); + ({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({ + from: this.defaultAccountAddress, + })); + } +} + +export type StatefulContractCtorArgs = Parameters; + +export type ContractArtifactClass = { + at(address: AztecAddress, wallet: Wallet): T; + artifact: ContractArtifact; +}; diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/automine/card_game.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_card_game.test.ts rename to yarn-project/end-to-end/src/automine/card_game.test.ts index c24c74a07988..59f1e0449cc8 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/automine/card_game.test.ts @@ -10,9 +10,8 @@ import { CardGameContract } from '@aztec/noir-contracts.js/CardGame'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { AutomineTestContext } from './automine_test_context.js'; /* eslint-disable camelcase */ @@ -62,7 +61,7 @@ const TIMEOUT = 600_000; // initializerless accounts — it derives nullifier-hiding keys from the players' secrets, so it owns the // keys. (v5: was setup(3, …); the explicit account provisioning is a setup-mechanics change, not a // category change.) jest.setTimeout(600s). -describe('e2e_card_game', () => { +describe('automine/card_game', () => { jest.setTimeout(TIMEOUT); let logger: Logger; @@ -98,7 +97,8 @@ describe('e2e_card_game', () => { // This test derives nullifier-hiding keys from the players' secrets, so we provide and create the // accounts ourselves. const players = await generateSchnorrAccounts(3); - const context = await setup(0, { ...AUTOMINE_E2E_OPTS, additionallyFundedAccounts: players }); + const context = (await AutomineTestContext.setup({ numberOfAccounts: 0, additionallyFundedAccounts: players })) + .context; ({ logger, teardown, wallet } = context); for (const player of players) { diff --git a/yarn-project/end-to-end/src/e2e_abi_types.test.ts b/yarn-project/end-to-end/src/automine/contracts/abi_types.parallel.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_abi_types.test.ts rename to yarn-project/end-to-end/src/automine/contracts/abi_types.parallel.test.ts index dc2b700811d8..f63cc1cb2b95 100644 --- a/yarn-project/end-to-end/src/e2e_abi_types.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/abi_types.parallel.test.ts @@ -7,8 +7,7 @@ import { AbiTypesContract } from '@aztec/noir-test-contracts.js/AbiTypes'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -19,7 +18,7 @@ const I64_MIN = -(2n ** 63n); // Tests that different ABI types are correctly encoded when passed to contract functions and decoded from // return values in TypeScript. Mirrors Noir-side AbiTypes unit tests. Uses setup(1, AUTOMINE_E2E_OPTS) // providing one node, automine sequencer, and one deployed account. -describe('AbiTypes', () => { +describe('automine/contracts/abi_types', () => { let abiTypesContract: AbiTypesContract; jest.setTimeout(TIMEOUT); @@ -32,7 +31,7 @@ describe('AbiTypes', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract: abiTypesContract } = await AbiTypesContract.deploy(wallet).send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_contract_updates.test.ts b/yarn-project/end-to-end/src/automine/contracts/contract_updates.parallel.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_contract_updates.test.ts rename to yarn-project/end-to-end/src/automine/contracts/contract_updates.parallel.test.ts index 4092c1fce247..527a695c3366 100644 --- a/yarn-project/end-to-end/src/e2e_contract_updates.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/contract_updates.parallel.test.ts @@ -20,9 +20,8 @@ import type { AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; import { deriveSigningKey } from '@aztec/stdlib/keys'; import { PublicDataTreeLeaf } from '@aztec/stdlib/trees'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Set the update delay in genesis data so it's feasible to test in an e2e test. // The protocol enforces `MINIMUM_UPDATE_DELAY` (600 seconds, see constants.gen.ts), so we use that @@ -40,7 +39,7 @@ const UPDATED_CONTRACT_PUBLIC_VALUE = 27n; // in additionallyFundedAccounts (whose address is known before setup so the delay can be seeded in // genesis for it). (v5: was setup(1, …) with initialFundedAccounts; the renamed option and // initializerless account are setup-mechanics changes, not category changes.) -describe('e2e_contract_updates', () => { +describe('automine/contracts/contract_updates', () => { let wallet: TestWallet; let defaultAccountAddress: AztecAddress; let teardown: () => Promise; @@ -100,11 +99,13 @@ describe('e2e_contract_updates', () => { const constructorArgs = [INITIAL_UPDATABLE_CONTRACT_VALUE]; const genesisPublicData = await setupScheduledDelay(constructorArgs, salt, account.address); - ({ aztecNode, teardown, wallet, cheatCodes } = await setup(0, { - ...AUTOMINE_E2E_OPTS, - genesisPublicData, - additionallyFundedAccounts: [account], - })); + ({ aztecNode, teardown, wallet, cheatCodes } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 0, + genesisPublicData, + additionallyFundedAccounts: [account], + }) + ).context); await wallet.createSchnorrInitializerlessAccount(account.secret, account.salt, account.signingKey); ({ contract, instance } = await UpdatableContract.deploy(wallet, constructorArgs[0], { salt }).send({ diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts b/yarn-project/end-to-end/src/automine/contracts/deploy/contract_class_registration.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts rename to yarn-project/end-to-end/src/automine/contracts/deploy/contract_class_registration.test.ts index b5d637a3219c..13b8e26c29a3 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/deploy/contract_class_registration.test.ts @@ -21,19 +21,18 @@ import { PublicKeys } from '@aztec/stdlib/keys'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; -import { DeployTest, type StatefulContractCtorArgs } from './deploy_test.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../../fixtures/fixtures.js'; +import { AutomineTestContext, type StatefulContractCtorArgs } from '../../automine_test_context.js'; // Tests low-level contract class and instance registration: publishing class bytecode, deploying -// instances via wallet or a contract deployer, and init-check enforcement. DeployTest wraps -// setup(0, { ...AUTOMINE_E2E_OPTS, fundSponsoredFPC, skipAccountDeployment }) with 1 account. +// instances via wallet or a contract deployer, and init-check enforcement. Runs on a single account. // jest.setTimeout is 900s because serial publish/deploy chains exceed the default 5 min hook budget. -describe('e2e_deploy_contract contract class registration', () => { +describe('automine/contracts/deploy/contract_class_registration', () => { // Pipelined cadence (~24s/dependent-tx) inflates the chained deploy/publish setup beyond the default 5 min // hook window. Many of the publishInstance helpers serially register multiple contracts/instances per case. jest.setTimeout(900_000); - const t = new DeployTest('contract class'); + const t = new AutomineTestContext(); let logger: Logger; let wallet: Wallet; @@ -45,7 +44,8 @@ describe('e2e_deploy_contract contract class registration', () => { let publicationTxReceipt: TxReceipt; beforeAll(async () => { - ({ logger, wallet, aztecNode, defaultAccountAddress } = await t.setup({ ...AUTOMINE_E2E_OPTS })); + await t.setup(); + ({ logger, wallet, aztecNode, defaultAccountAddress } = t); artifact = StatefulTestContract.artifact; publicationTxReceipt = await publishContractClass(wallet, artifact).then(c => c.send({ from: defaultAccountAddress }).then(({ receipt }) => receipt), diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts rename to yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts index fb52792edfbd..8c109ec687ae 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/deploy/deploy_method.parallel.test.ts @@ -11,16 +11,14 @@ import { NoConstructorContract } from '@aztec/noir-test-contracts.js/NoConstruct import { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest'; import { GasFees } from '@aztec/stdlib/gas'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { TestWallet } from '../test-wallet/test_wallet.js'; -import { DeployTest } from './deploy_test.js'; +import { TestWallet } from '../../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests the high-level DeployMethod API: deploying contracts publicly, privately, with -// batching, and verifying deployment metadata. DeployTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, -// fundSponsoredFPC, skipAccountDeployment }) with 1 account. Includes a minTxsPerBlock=2 sub-test -// that verifies two txs land in the same block. -describe('e2e_deploy_contract deploy method', () => { - const t = new DeployTest('deploy method'); +// batching, and verifying deployment metadata. Runs on a single account. Includes a minTxsPerBlock=2 +// sub-test that verifies two txs land in the same block. +describe('automine/contracts/deploy/deploy_method', () => { + const t = new AutomineTestContext(); let logger: Logger; let wallet: Wallet; @@ -28,7 +26,8 @@ describe('e2e_deploy_contract deploy method', () => { let defaultAccountAddress: AztecAddress; beforeAll(async () => { - ({ logger, wallet, aztecNode, defaultAccountAddress } = await t.setup({ ...AUTOMINE_E2E_OPTS })); + await t.setup(); + ({ logger, wallet, aztecNode, defaultAccountAddress } = t); }); afterAll(() => t.teardown()); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts b/yarn-project/end-to-end/src/automine/contracts/deploy/legacy.parallel.test.ts similarity index 91% rename from yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts rename to yarn-project/end-to-end/src/automine/contracts/deploy/legacy.parallel.test.ts index 19f5492bbbb3..97f0e4ce5e4c 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/legacy.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/deploy/legacy.parallel.test.ts @@ -9,22 +9,21 @@ import { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest import { TestContractArtifact } from '@aztec/noir-test-contracts.js/Test'; import { TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import type { TestWallet } from '../test-wallet/test_wallet.js'; -import { DeployTest } from './deploy_test.js'; +import type { TestWallet } from '../../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests legacy ContractDeployer API: basic deploy, consecutive rollups, duplicate-salt rejection, -// and failed public constructor handling. DeployTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, -// fundSponsoredFPC, skipAccountDeployment }) with 1 account. -describe('e2e_deploy_contract legacy', () => { - const t = new DeployTest('legacy'); +// and failed public constructor handling. Runs on a single account. +describe('automine/contracts/deploy/legacy', () => { + const t = new AutomineTestContext(); let logger: Logger; let wallet: TestWallet; let defaultAccountAddress: AztecAddress; beforeAll(async () => { - ({ logger, wallet, defaultAccountAddress } = await t.setup({ ...AUTOMINE_E2E_OPTS })); + await t.setup(); + ({ logger, wallet, defaultAccountAddress } = t); }); afterAll(() => t.teardown()); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts b/yarn-project/end-to-end/src/automine/contracts/deploy/private_initialization.parallel.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts rename to yarn-project/end-to-end/src/automine/contracts/deploy/private_initialization.parallel.test.ts index ee96b42f6194..023356c12593 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/private_initialization.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/deploy/private_initialization.parallel.test.ts @@ -11,18 +11,16 @@ import { PrivateInitTestContract } from '@aztec/noir-test-contracts.js/PrivateIn import { siloNullifier } from '@aztec/stdlib/hash'; import { TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import type { TestWallet } from '../test-wallet/test_wallet.js'; -import { DeployTest } from './deploy_test.js'; +import type { TestWallet } from '../../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; type InitTestCtorArgs = Parameters; // Tests private contract initialization flows: noinitcheck functions, contracts without constructors, // single/batch initialization, ordering constraints between private init and public calls, and -// ContractInitializationStatus reporting. DeployTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, -// fundSponsoredFPC, skipAccountDeployment }) with 1 account. -describe('e2e_deploy_contract private initialization', () => { - const t = new DeployTest('private initialization'); +// ContractInitializationStatus reporting. Runs on a single account. +describe('automine/contracts/deploy/private_initialization', () => { + const t = new AutomineTestContext(); let logger: Logger; let wallet: TestWallet; @@ -30,7 +28,8 @@ describe('e2e_deploy_contract private initialization', () => { let aztecNode: AztecNode; beforeAll(async () => { - ({ logger, wallet, aztecNode, defaultAccountAddress } = await t.setup({ ...AUTOMINE_E2E_OPTS })); + await t.setup(); + ({ logger, wallet, aztecNode, defaultAccountAddress } = t); await publishContractClass(wallet, InitTestContract.artifact).then(c => c.send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof.json b/yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof.json similarity index 100% rename from yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof.json rename to yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof.json diff --git a/yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts b/yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof_fetcher.ts similarity index 100% rename from yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts rename to yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof_fetcher.ts diff --git a/yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts b/yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof_fixture.ts similarity index 100% rename from yarn-project/end-to-end/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts rename to yarn-project/end-to-end/src/automine/contracts/fixtures/storage_proof_fixture.ts diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/importer.test.ts b/yarn-project/end-to-end/src/automine/contracts/nested/importer.parallel.test.ts similarity index 78% rename from yarn-project/end-to-end/src/e2e_nested_contract/importer.test.ts rename to yarn-project/end-to-end/src/automine/contracts/nested/importer.parallel.test.ts index c59493f5f156..eabb2b861f4b 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract/importer.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/nested/importer.parallel.test.ts @@ -1,20 +1,18 @@ import { ImportTestContract } from '@aztec/noir-test-contracts.js/ImportTest'; import { TestContract } from '@aztec/noir-test-contracts.js/Test'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { NestedContractTest } from './nested_contract_test.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests cross-contract calls through the ImportTest contract (which imports functions from Test). -// NestedContractTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, fundSponsoredFPC, skipAccountDeployment }) -// with 1 public-deployed account. ImportTest and Test contracts are deployed fresh per test in beforeEach. -describe('e2e_nested_contract manual', () => { - const t = new NestedContractTest('manual'); +// Runs on a single account. ImportTest and Test contracts are deployed fresh per test in beforeEach. +describe('automine/contracts/nested/importer', () => { + const t = new AutomineTestContext(); let testContract: TestContract; let importerContract: ImportTestContract; let { wallet, logger, defaultAccountAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ wallet, logger, defaultAccountAddress } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/manual_private_call.test.ts b/yarn-project/end-to-end/src/automine/contracts/nested/manual_private_call.test.ts similarity index 56% rename from yarn-project/end-to-end/src/e2e_nested_contract/manual_private_call.test.ts rename to yarn-project/end-to-end/src/automine/contracts/nested/manual_private_call.test.ts index e16c60a91bb9..618d3819d261 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract/manual_private_call.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/nested/manual_private_call.test.ts @@ -1,16 +1,14 @@ -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { NestedContractTest } from './nested_contract_test.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests a nested private call from ParentContract into ChildContract's value() function. -// NestedContractTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, fundSponsoredFPC, skipAccountDeployment }) -// with 1 public-deployed account. applyManual() deploys Parent and Child contracts in beforeAll. -describe('e2e_nested_contract manual', () => { - const t = new NestedContractTest('manual'); +// Runs on a single account. applyManualParentChild() deploys Parent and Child contracts in beforeAll. +describe('automine/contracts/nested/manual_private_call', () => { + const t = new AutomineTestContext(); let { parentContract, childContract, defaultAccountAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); - await t.applyManual(); + await t.setup(); + await t.applyManualParentChild(); ({ parentContract, childContract, defaultAccountAddress } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/manual_private_enqueue.test.ts b/yarn-project/end-to-end/src/automine/contracts/nested/manual_private_enqueue.parallel.test.ts similarity index 85% rename from yarn-project/end-to-end/src/e2e_nested_contract/manual_private_enqueue.test.ts rename to yarn-project/end-to-end/src/automine/contracts/nested/manual_private_enqueue.parallel.test.ts index 1e7d8d6714ed..c243fc5ec51b 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract/manual_private_enqueue.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/nested/manual_private_enqueue.parallel.test.ts @@ -3,14 +3,12 @@ import { Fr } from '@aztec/aztec.js/fields'; import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; import { ParentContract } from '@aztec/noir-test-contracts.js/Parent'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { NestedContractTest } from './nested_contract_test.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests parent contracts enqueuing public calls on a child contract via various call patterns. -// NestedContractTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, fundSponsoredFPC, skipAccountDeployment }) -// with 1 public-deployed account. Parent and Child are deployed fresh per test in beforeEach. -describe('e2e_nested_contract manual_enqueue', () => { - const t = new NestedContractTest('manual_enqueue'); +// Runs on a single account. Parent and Child are deployed fresh per test in beforeEach. +describe('automine/contracts/nested/manual_private_enqueue', () => { + const t = new AutomineTestContext(); let { wallet, parentContract, childContract, defaultAccountAddress, aztecNode } = t; const getChildStoredValue = (child: { address: AztecAddress }) => @@ -18,7 +16,7 @@ describe('e2e_nested_contract manual_enqueue', () => { beforeAll(async () => { // We don't deploy contracts in beforeAll because every test requires a fresh setup - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ wallet, defaultAccountAddress, aztecNode } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/manual_public.test.ts b/yarn-project/end-to-end/src/automine/contracts/nested/manual_public.parallel.test.ts similarity index 85% rename from yarn-project/end-to-end/src/e2e_nested_contract/manual_public.test.ts rename to yarn-project/end-to-end/src/automine/contracts/nested/manual_public.parallel.test.ts index 49e0714e01d4..bb163922df50 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract/manual_public.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/nested/manual_public.parallel.test.ts @@ -4,22 +4,20 @@ import { Fr } from '@aztec/aztec.js/fields'; import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { serializeToBuffer } from '@aztec/foundation/serialize'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { NestedContractTest } from './nested_contract_test.js'; +import { AutomineTestContext } from '../../automine_test_context.js'; // Tests public-to-public nested calls and ordering guarantees (public before private enqueue). -// NestedContractTest wraps setup(0, { ...AUTOMINE_E2E_OPTS, fundSponsoredFPC, skipAccountDeployment }) -// with 1 public-deployed account. applyManual() deploys Parent and Child contracts in beforeAll. -describe('e2e_nested_contract manual', () => { - const t = new NestedContractTest('manual'); +// Runs on a single account. applyManualParentChild() deploys Parent and Child contracts in beforeAll. +describe('automine/contracts/nested/manual_public', () => { + const t = new AutomineTestContext(); let { wallet, parentContract, childContract, defaultAccountAddress, aztecNode } = t; const getChildStoredValue = (child: { address: AztecAddress }) => aztecNode.getPublicStorageAt('latest', child.address, new Fr(1)); beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); - await t.applyManual(); + await t.setup(); + await t.applyManualParentChild(); ({ wallet, parentContract, childContract, defaultAccountAddress, aztecNode } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_nested_utility_calls.test.ts b/yarn-project/end-to-end/src/automine/contracts/nested_utility_calls.parallel.test.ts similarity index 92% rename from yarn-project/end-to-end/src/e2e_nested_utility_calls.test.ts rename to yarn-project/end-to-end/src/automine/contracts/nested_utility_calls.parallel.test.ts index bba5474aff81..6dd1ccbc2c20 100644 --- a/yarn-project/end-to-end/src/e2e_nested_utility_calls.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/nested_utility_calls.parallel.test.ts @@ -8,15 +8,14 @@ import { getContractClassFromArtifact } from '@aztec/stdlib/contract'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Verifies nested utility calls via pow_utility(x, n) = x^n (recursive utility→utility), // calling it from a private function via pow_private, and the default hook behavior. // Single automine node, one funded account, two NestedUtilityContract instances. -describe('Nested utility calls', () => { +describe('automine/contracts/nested_utility_calls', () => { let contractA: NestedUtilityContract; let contractB: NestedUtilityContract; jest.setTimeout(TIMEOUT); @@ -30,7 +29,7 @@ describe('Nested utility calls', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract: contractA } = await NestedUtilityContract.deploy(wallet).send({ from: defaultAccountAddress })); ({ contract: contractB } = await NestedUtilityContract.deploy(wallet).send({ from: defaultAccountAddress })); }); @@ -38,20 +37,20 @@ describe('Nested utility calls', () => { afterAll(() => teardown()); // Simulates pow_utility(2, 0) from the same contract; expects result == 1 with no recursion. - it('pow_utility(x, 0) returns 1 (base case, no nested call)', async () => { + it('pow_utility with exponent 0 returns 1 - base case, no nested call', async () => { const { result } = await contractA.methods.pow_utility(2n, 0).simulate({ from: defaultAccountAddress }); expect(result).toEqual(1n); }); // Simulates pow_utility(2, 10) which recurses 10 times within the same contract; expects 1024. - it('pow_utility(2, 10) returns 2^10 (10 levels of nesting)', async () => { + it('pow_utility 2 to the 10 returns 1024 - 10 levels of nesting', async () => { const { result } = await contractA.methods.pow_utility(2n, 10).simulate({ from: defaultAccountAddress }); expect(result).toEqual(2n ** 10n); }); // Simulates pow_private(2, 10) which calls pow_utility from a private function context; expects // 1024. - it('pow_private(2, 10) returns 2^10 (private function calling utility)', async () => { + it('pow_private 2 to the 10 returns 1024 - private function calling utility', async () => { const { result } = await contractA.methods.pow_private(2n, 10).simulate({ from: defaultAccountAddress }); expect(result).toEqual(2n ** 10n); }); @@ -103,17 +102,19 @@ describe('authorizeUtilityCall hook', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { - ...AUTOMINE_E2E_OPTS, - pxeCreationOptions: { - hooks: { - authorizeUtilityCall: (req: UtilityCallAuthorizationRequest) => { - lastRequest = req; - return Promise.resolve({ authorized: hookAllows }); + } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 1, + pxeCreationOptions: { + hooks: { + authorizeUtilityCall: (req: UtilityCallAuthorizationRequest) => { + lastRequest = req; + return Promise.resolve({ authorized: hookAllows }); + }, }, }, - }, - })); + }) + ).context); ({ contract: contractA } = await NestedUtilityContract.deploy(wallet).send({ from: defaultAccountAddress })); ({ contract: contractB } = await NestedUtilityContract.deploy(wallet).send({ from: defaultAccountAddress })); diff --git a/yarn-project/end-to-end/src/e2e_option_params.test.ts b/yarn-project/end-to-end/src/automine/contracts/option_params.parallel.test.ts similarity index 94% rename from yarn-project/end-to-end/src/e2e_option_params.test.ts rename to yarn-project/end-to-end/src/automine/contracts/option_params.parallel.test.ts index 2678e7acdbf7..b73ce33dcf74 100644 --- a/yarn-project/end-to-end/src/e2e_option_params.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/option_params.parallel.test.ts @@ -5,8 +5,7 @@ import { OptionParamContract } from '@aztec/noir-test-contracts.js/OptionParam'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -16,7 +15,7 @@ const I64_MIN = -(2n ** 63n); // Verifies that the Aztec.js ABI layer correctly serialises/deserialises Noir Option parameters // for public, utility, and private functions. Single node with AutomineSequencer; all calls are // simulate()-only (no on-chain state changes). -describe('Option params', () => { +describe('automine/contracts/option_params', () => { let contract: OptionParamContract; let wallet: Wallet; let defaultAccountAddress: AztecAddress; @@ -36,7 +35,7 @@ describe('Option params', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); contract = (await OptionParamContract.deploy(wallet).send({ from: defaultAccountAddress })).contract; }); diff --git a/yarn-project/end-to-end/src/e2e_state_vars.test.ts b/yarn-project/end-to-end/src/automine/contracts/state_vars.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_state_vars.test.ts rename to yarn-project/end-to-end/src/automine/contracts/state_vars.test.ts index 91b22307ca83..b808114e2925 100644 --- a/yarn-project/end-to-end/src/e2e_state_vars.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/state_vars.test.ts @@ -7,10 +7,9 @@ import { StateVarsContract } from '@aztec/noir-test-contracts.js/StateVars'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { proveInteraction } from '../../test-wallet/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -18,7 +17,7 @@ const TIMEOUT = 300_000; // via the StateVars and Auth contracts. Single node with AutomineSequencer. The DelayedPublicMutable sub-suite // reads DefaultL1ContractsConfig.aztecSlotDuration as a static constant (72) for delay arithmetic and asserts // it has not changed; the runtime slot set by AUTOMINE_E2E_OPTS (12s) is irrelevant to that assertion. -describe('e2e_state_vars', () => { +describe('automine/contracts/state_vars', () => { jest.setTimeout(TIMEOUT); let aztecNode: AztecNode; @@ -37,7 +36,7 @@ describe('e2e_state_vars', () => { aztecNode, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await StateVarsContract.deploy(wallet).send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_static_calls.test.ts b/yarn-project/end-to-end/src/automine/contracts/static_calls.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_static_calls.test.ts rename to yarn-project/end-to-end/src/automine/contracts/static_calls.test.ts index ea1d6087c4de..d8298d186d0b 100644 --- a/yarn-project/end-to-end/src/e2e_static_calls.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/static_calls.test.ts @@ -3,17 +3,13 @@ import type { Wallet } from '@aztec/aztec.js/wallet'; import { StaticChildContract } from '@aztec/noir-test-contracts.js/StaticChild'; import { StaticParentContract } from '@aztec/noir-test-contracts.js/StaticParent'; -import { - AUTOMINE_E2E_OPTS, - STATIC_CALL_STATE_MODIFICATION_ERROR, - STATIC_CONTEXT_ASSERTION_ERROR, -} from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { STATIC_CALL_STATE_MODIFICATION_ERROR, STATIC_CONTEXT_ASSERTION_ERROR } from '../../fixtures/fixtures.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Verifies that static call enforcement prevents state modifications in private and public contexts, // and that non-static calls to functions marked with static-call assertions are rejected. Uses a single // node with AutomineSequencer and two contracts (StaticParent, StaticChild). -describe('e2e_static_calls', () => { +describe('automine/contracts/static_calls', () => { let wallet: Wallet; let parentContract: StaticParentContract; let childContract: StaticChildContract; @@ -26,7 +22,7 @@ describe('e2e_static_calls', () => { teardown, wallet, accounts: [owner], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); sender = owner; ({ contract: parentContract } = await StaticParentContract.deploy(wallet).send({ from: owner })); ({ contract: childContract } = await StaticChildContract.deploy(wallet).send({ from: owner })); diff --git a/yarn-project/end-to-end/src/e2e_storage_proof/e2e_storage_proof.test.ts b/yarn-project/end-to-end/src/automine/contracts/storage_proof.test.ts similarity index 63% rename from yarn-project/end-to-end/src/e2e_storage_proof/e2e_storage_proof.test.ts rename to yarn-project/end-to-end/src/automine/contracts/storage_proof.test.ts index 399f5cee329b..70e20a283add 100644 --- a/yarn-project/end-to-end/src/e2e_storage_proof/e2e_storage_proof.test.ts +++ b/yarn-project/end-to-end/src/automine/contracts/storage_proof.test.ts @@ -2,26 +2,25 @@ import { StorageProofTestContract } from '@aztec/noir-test-contracts.js/StorageP import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { type EndToEndContext, setup, teardown } from '../fixtures/setup.js'; +import { AutomineTestContext } from '../automine_test_context.js'; import { buildStorageProofCapsules, loadStorageProofArgs } from './fixtures/storage_proof_fixture.js'; jest.setTimeout(300_000); // Tests that a Noir contract can verify an Ethereum storage proof (MPT proof) via oracle capsules. -// Plain setup(1, { ...AUTOMINE_E2E_OPTS }) with 1 account. Deploys StorageProofTestContract, then -// loads pre-computed proof args from fixtures/storage_proof.json and verifies on-chain. -describe('Storage proof', () => { - let ctx: EndToEndContext; +// Deploys StorageProofTestContract, then loads pre-computed proof args from fixtures/storage_proof.json +// and verifies on-chain. +describe('automine/contracts/storage_proof', () => { + const t = new AutomineTestContext(); let contract: StorageProofTestContract; beforeAll(async () => { - ctx = await setup(1, { ...AUTOMINE_E2E_OPTS }); - ({ contract } = await StorageProofTestContract.deploy(ctx.wallet).send({ from: ctx.accounts[0] })); + await t.setup({ numberOfAccounts: 1 }); + ({ contract } = await StorageProofTestContract.deploy(t.wallet).send({ from: t.defaultAccountAddress })); }); afterAll(async () => { - await teardown(ctx); + await t.teardown(); }); // Loads pre-computed ethAddress/slotKey/slotContents/root from storage_proof.json, builds oracle @@ -31,12 +30,12 @@ describe('Storage proof', () => { const { ethAddress, slotKey, slotContents, root } = loadStorageProofArgs(); const capsules = await buildStorageProofCapsules(contract.address); - ctx.logger.info('Sending storage proof TX...'); + t.logger.info('Sending storage proof TX...'); const { receipt } = await contract.methods .storage_proof(ethAddress, slotKey, slotContents, root) .with({ capsules }) - .send({ from: ctx.accounts[0] }); + .send({ from: t.defaultAccountAddress }); expect(receipt.hasExecutionSucceeded()).toBe(true); }); diff --git a/yarn-project/end-to-end/src/e2e_double_spend.test.ts b/yarn-project/end-to-end/src/automine/double_spend.test.ts similarity index 91% rename from yarn-project/end-to-end/src/e2e_double_spend.test.ts rename to yarn-project/end-to-end/src/automine/double_spend.test.ts index ae02243d2c10..edf0d35e6b7f 100644 --- a/yarn-project/end-to-end/src/e2e_double_spend.test.ts +++ b/yarn-project/end-to-end/src/automine/double_spend.test.ts @@ -5,12 +5,11 @@ import { TxExecutionResult } from '@aztec/aztec.js/tx'; import type { Wallet } from '@aztec/aztec.js/wallet'; import { TestContract } from '@aztec/noir-test-contracts.js/Test'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Tests that a public nullifier emitted in one tx cannot be emitted again in a subsequent tx. // Uses setup(1, AUTOMINE_E2E_OPTS) with one node, automine sequencer, one funded account. -describe('e2e_double_spend', () => { +describe('automine/double_spend', () => { let wallet: Wallet; let defaultAccountAddress: AztecAddress; @@ -26,7 +25,7 @@ describe('e2e_double_spend', () => { wallet, accounts: [defaultAccountAddress], logger, - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await TestContract.deploy(wallet).send({ from: defaultAccountAddress })); diff --git a/yarn-project/end-to-end/src/e2e_custom_message.test.ts b/yarn-project/end-to-end/src/automine/effects/custom_message.parallel.test.ts similarity index 94% rename from yarn-project/end-to-end/src/e2e_custom_message.test.ts rename to yarn-project/end-to-end/src/automine/effects/custom_message.parallel.test.ts index 19b982f08856..8be39d89cfd2 100644 --- a/yarn-project/end-to-end/src/e2e_custom_message.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/custom_message.parallel.test.ts @@ -7,15 +7,14 @@ import { CustomMessageContract, type MultiLogEvent } from '@aztec/noir-test-cont import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Tests the CustomMessage contract's multi-log event pattern: emitting a single event split across // multiple private logs and reassembling it via wallet.getPrivateEvents. // Uses setup(1, AUTOMINE_E2E_OPTS) with one node, automine sequencer, one account. -describe('CustomMessage - Multi-Log Pattern', () => { +describe('automine/effects/custom_message', () => { let contract: CustomMessageContract; jest.setTimeout(TIMEOUT); @@ -28,7 +27,7 @@ describe('CustomMessage - Multi-Log Pattern', () => { teardown, wallet, accounts: [account], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await CustomMessageContract.deploy(wallet).send({ from: account })); }); diff --git a/yarn-project/end-to-end/src/e2e_event_logs.test.ts b/yarn-project/end-to-end/src/automine/effects/event_logs.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_event_logs.test.ts rename to yarn-project/end-to-end/src/automine/effects/event_logs.test.ts index c563539f0ba8..97b8eaf0010b 100644 --- a/yarn-project/end-to-end/src/e2e_event_logs.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/event_logs.test.ts @@ -17,8 +17,7 @@ import { import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -26,7 +25,7 @@ const TIMEOUT = 300_000; // public-log event emission and retrieval (unencrypted events via getPublicEvents), including nested // events with struct fields and tagging-cache reconciliation against kernel squashing. Uses a single // automine node with two genesis-funded Schnorr accounts and a deployed TestLogContract. -describe('Logs', () => { +describe('automine/effects/event_logs', () => { let testLogContract: TestLogContract; jest.setTimeout(TIMEOUT); @@ -46,7 +45,7 @@ describe('Logs', () => { accounts: [account1Address, account2Address], aztecNode, logger: log, - } = await setup(2, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 2 })).context); log.warn(`Deploying test contract`); ({ contract: testLogContract } = await TestLogContract.deploy(wallet).send({ from: account1Address })); diff --git a/yarn-project/end-to-end/src/e2e_event_only.test.ts b/yarn-project/end-to-end/src/automine/effects/event_only.test.ts similarity index 90% rename from yarn-project/end-to-end/src/e2e_event_only.test.ts rename to yarn-project/end-to-end/src/automine/effects/event_only.test.ts index 845f1c82d839..7ce0e5d05772 100644 --- a/yarn-project/end-to-end/src/e2e_event_only.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/event_only.test.ts @@ -6,14 +6,13 @@ import { EventOnlyContract, type TestEvent } from '@aztec/noir-test-contracts.js import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; /// Tests that a private event can be obtained for a contract that does not work with notes. // Single automine node, one genesis-funded account, EventOnlyContract deployed in beforeAll. -describe('EventOnly', () => { +describe('automine/effects/event_only', () => { let eventOnlyContract: EventOnlyContract; jest.setTimeout(TIMEOUT); @@ -26,7 +25,7 @@ describe('EventOnly', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract: eventOnlyContract } = await EventOnlyContract.deploy(wallet).send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_large_public_event.test.ts b/yarn-project/end-to-end/src/automine/effects/large_public_event.test.ts similarity index 90% rename from yarn-project/end-to-end/src/e2e_large_public_event.test.ts rename to yarn-project/end-to-end/src/automine/effects/large_public_event.test.ts index eb29962fabc9..a31ab8cd55d8 100644 --- a/yarn-project/end-to-end/src/e2e_large_public_event.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/large_public_event.test.ts @@ -8,14 +8,13 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; /// Tests that events exceeding MAX_EVENT_SERIALIZED_LEN can be emitted publicly. // Single automine node, one funded account, LargePublicEventContract deployed in beforeAll. -describe('LargePublicEvent', () => { +describe('automine/effects/large_public_event', () => { let contract: LargePublicEventContract; jest.setTimeout(TIMEOUT); @@ -30,7 +29,7 @@ describe('LargePublicEvent', () => { wallet, aztecNode, accounts: [accountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await LargePublicEventContract.deploy(wallet).send({ from: accountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_note_getter.test.ts b/yarn-project/end-to-end/src/automine/effects/note_getter.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_note_getter.test.ts rename to yarn-project/end-to-end/src/automine/effects/note_getter.test.ts index c05f07f35560..433f13943142 100644 --- a/yarn-project/end-to-end/src/e2e_note_getter.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/note_getter.test.ts @@ -4,8 +4,7 @@ import type { Wallet } from '@aztec/aztec.js/wallet'; import { NoteGetterContract } from '@aztec/noir-test-contracts.js/NoteGetter'; import { TestContract } from '@aztec/noir-test-contracts.js/Test'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; interface NoirBoundedVec { storage: T[]; @@ -19,7 +18,7 @@ function boundedVecToArray(boundedVec: NoirBoundedVec): T[] { // Covers the NoteGetter contract's filtering capabilities (EQ, NEQ, LT, GT, LTE, GTE comparators // and sub-field property selectors) and the TestContract's note status filter (active vs nullified). // Single automine node, one funded account, contracts deployed per describe block. -describe('e2e_note_getter', () => { +describe('automine/effects/note_getter', () => { let wallet: Wallet; let defaultAddress: AztecAddress; let teardown: () => Promise; @@ -29,7 +28,7 @@ describe('e2e_note_getter', () => { teardown, wallet, accounts: [defaultAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); }); afterAll(() => teardown()); diff --git a/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts b/yarn-project/end-to-end/src/automine/effects/offchain_effect.parallel.test.ts similarity index 94% rename from yarn-project/end-to-end/src/e2e_offchain_effect.test.ts rename to yarn-project/end-to-end/src/automine/effects/offchain_effect.parallel.test.ts index 1fbaee2d6ae2..938d413105e8 100644 --- a/yarn-project/end-to-end/src/e2e_offchain_effect.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/offchain_effect.parallel.test.ts @@ -5,10 +5,9 @@ import { OffchainEffectContract, type TestEvent } from '@aztec/noir-test-contrac import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { proveInteraction } from '../../test-wallet/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -16,7 +15,7 @@ const TIMEOUT = 300_000; // proveInteraction, and the offchain-message delivery flow (emitting an event or note as an // offchain message, then delivering it via offchain_receive and retrieving via getPrivateEvents). // Single automine node, one funded account, two OffchainEffectContract instances. -describe('e2e_offchain_effect', () => { +describe('automine/effects/offchain_effect', () => { let contract1: OffchainEffectContract; let contract2: OffchainEffectContract; @@ -30,7 +29,7 @@ describe('e2e_offchain_effect', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract: contract1 } = await OffchainEffectContract.deploy(wallet).send({ from: defaultAccountAddress })); ({ contract: contract2 } = await OffchainEffectContract.deploy(wallet).send({ from: defaultAccountAddress })); }); @@ -39,7 +38,7 @@ describe('e2e_offchain_effect', () => { // Sends emit_offchain_effects with 2 effects; asserts the returned offchainEffects array has // length 2, that effects are reversed (popped from BoundedVec end), and contractAddresses match. - it('should return offchain effects from send()', async () => { + it('should return offchain effects from send', async () => { const effects = Array(2) .fill(null) .map(() => ({ diff --git a/yarn-project/end-to-end/src/e2e_offchain_payment.test.ts b/yarn-project/end-to-end/src/automine/effects/offchain_payment.parallel.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_offchain_payment.test.ts rename to yarn-project/end-to-end/src/automine/effects/offchain_payment.parallel.test.ts index b39311aa079a..567d2749e780 100644 --- a/yarn-project/end-to-end/src/e2e_offchain_payment.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/offchain_payment.parallel.test.ts @@ -8,17 +8,17 @@ import { OffchainPaymentContract } from '@aztec/noir-test-contracts.js/OffchainP import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { getLogger, setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import { getLogger } from '../../fixtures/utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { proveInteraction } from '../../test-wallet/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Tests the OffchainPayment contract's offchain message delivery mechanism. Uses a single node with the // AutomineSequencer so each tx mines a block immediately. Also exercises the AutomineSequencer's // revertToCheckpoint to simulate a reorg and verify that offchain-delivered notes are reprocessed correctly. -describe('e2e_offchain_payment', () => { +describe('automine/effects/offchain_payment', () => { let contract: OffchainPaymentContract; let aztecNode: AztecNode; let aztecNodeService: AztecNodeService; @@ -30,10 +30,12 @@ describe('e2e_offchain_payment', () => { jest.setTimeout(TIMEOUT); beforeAll(async () => { - ({ teardown, wallet, accounts, aztecNode, aztecNodeService } = await setup(2, { - ...AUTOMINE_E2E_OPTS, - anvilSlotsInAnEpoch: 32, - })); + ({ teardown, wallet, accounts, aztecNode, aztecNodeService } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 2, + anvilSlotsInAnEpoch: 32, + }) + ).context); }); afterAll(() => teardown()); diff --git a/yarn-project/end-to-end/src/e2e_partial_notes.test.ts b/yarn-project/end-to-end/src/automine/effects/partial_notes.test.ts similarity index 84% rename from yarn-project/end-to-end/src/e2e_partial_notes.test.ts rename to yarn-project/end-to-end/src/automine/effects/partial_notes.test.ts index 405d056a181e..1eefb41f1d18 100644 --- a/yarn-project/end-to-end/src/e2e_partial_notes.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/partial_notes.test.ts @@ -5,15 +5,14 @@ import type { TokenContract } from '@aztec/noir-contracts.js/Token'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; +import { deployToken, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; // Smoke test for the partial-note pattern: minting tokens into a private note via the // Token contract's mint_to_private path. Single node with AutomineSequencer. -describe('partial notes', () => { +describe('automine/effects/partial_notes', () => { jest.setTimeout(TIMEOUT); let teardown: () => Promise; @@ -35,7 +34,7 @@ describe('partial notes', () => { wallet, accounts: [adminAddress, liquidityProviderAddress], logger, - } = await setup(2, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 2 })).context); const { contract } = await deployToken(wallet, adminAddress, 0n, logger); token0 = contract; diff --git a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts b/yarn-project/end-to-end/src/automine/effects/pending_note_hashes.parallel.test.ts similarity index 93% rename from yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts rename to yarn-project/end-to-end/src/automine/effects/pending_note_hashes.parallel.test.ts index 0604823ed985..f5e718be4c8f 100644 --- a/yarn-project/end-to-end/src/e2e_pending_note_hashes_contract.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/pending_note_hashes.parallel.test.ts @@ -10,14 +10,13 @@ import { } from '@aztec/constants'; import { PendingNoteHashesContract } from '@aztec/noir-test-contracts.js/PendingNoteHashes'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Verifies the kernel's pending-note-hash squashing logic: notes created and nullified in the same tx // are not persisted to the tree. Uses a single node with AutomineSequencer; contracts are deployed // per-test via deployContract(). -describe('e2e_pending_note_hashes_contract', () => { +describe('automine/effects/pending_note_hashes', () => { let aztecNode: AztecNode; let wallet: TestWallet; let owner: AztecAddress; @@ -32,7 +31,7 @@ describe('e2e_pending_note_hashes_contract', () => { wallet, logger, accounts: [owner], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); }); afterAll(() => teardown()); @@ -95,7 +94,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Inserts a note and reads it back within the same nested-call chain; asserts the tx succeeds, // confirming the simulator can access pending (not-yet-persisted) notes within a single tx. - it('Aztec.nr function can "get" notes it just "inserted"', async () => { + it('Aztec.nr function can get notes it just inserted', async () => { const mintAmount = 65n; const deployedContract = await deployContract(); @@ -108,7 +107,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Creates one note and nullifies it in the same tx; asserts both the note hash and its nullifier // are squashed (zeroed) in the mined block, and the private log count is zero. - it('Squash! Aztec.nr function can "create" and "nullify" note in the same TX', async () => { + it('Squash! Aztec.nr function can create and nullify note in the same TX', async () => { // Kernel will squash the noteHash and its nullifier. // Realistic way to describe this test is "Mint note A, then burn note A in the same transaction" const mintAmount = 65n; @@ -132,7 +131,7 @@ describe('e2e_pending_note_hashes_contract', () => { await expectNoteLogsSquashedExcept(0); }); - it('Squash! Aztec.nr function can "create" and "nullify" note in the same TX but the constrained note log survives', async () => { + it('Squash! Aztec.nr function can create and nullify note in the same TX but the constrained note log survives', async () => { // Kernel will squash the noteHash and its nullifier, but NOT the note log: constrained-delivery logs are not // linked to the note for squashing, because a removed log would break the index chain. const mintAmount = 65n; @@ -157,7 +156,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Same as above but the insert emits two private logs; asserts all are squashed along with the note // hash and nullifier. - it('Squash! Aztec.nr function can "create" and "nullify" note in the same TX with 2 note logs', async () => { + it('Squash! Aztec.nr function can create and nullify note in the same TX with 2 note logs', async () => { // Kernel will squash the noteHash and its nullifier and both note logs // Realistic way to describe this test is "Mint note A, then burn note A in the same transaction" const mintAmount = 65n; @@ -182,7 +181,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Creates two notes and nullifies both in the same tx; asserts both note hashes, both nullifiers, // and both private logs are squashed. - it('Squash! Aztec.nr function can "create" 2 notes and "nullify" both in the same TX', async () => { + it('Squash! Aztec.nr function can create 2 notes and nullify both in the same TX', async () => { // Kernel will squash both noteHashes and their nullifier. // Realistic way to describe this test is "Mint notes A and B, then burn both in the same transaction" const mintAmount = 65n; @@ -207,7 +206,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Creates two notes but only nullifies one in the same tx; asserts exactly one note hash persists // and its counterpart is squashed, leaving one private log. - it('Squash! Aztec.nr function can "create" 2 notes and "nullify" 1 in the same TX (kernel will squash one note + nullifier)', async () => { + it('Squash! Aztec.nr function can create 2 notes and nullify 1 in the same TX - kernel will squash one note and nullifier', async () => { // Kernel will squash one noteHash and its nullifier. // The other note will become persistent! // Realistic way to describe this test is "Mint notes A and B, then burn note A in the same transaction" @@ -233,7 +232,7 @@ describe('e2e_pending_note_hashes_contract', () => { // Same as the previous test but both notes share the same inner hash (static randomness); verifies // that only one of the two identical-hash notes is squashed, and the other persists. - it('Squash! Aztec.nr function can "create" 2 notes with the same note hash and "nullify" 1 in the same TX', async () => { + it('Squash! Aztec.nr function can create 2 notes with the same note hash and nullify 1 in the same TX', async () => { // Kernel will squash one noteHash and its nullifier, where two notes with the same inner hash exist. // The other note will become persistent! // Realistic way to describe this test is "Mint notes A and B, then burn note A in the same transaction" diff --git a/yarn-project/end-to-end/src/e2e_pruned_blocks.test.ts b/yarn-project/end-to-end/src/automine/effects/pruned_blocks.test.ts similarity index 92% rename from yarn-project/end-to-end/src/e2e_pruned_blocks.test.ts rename to yarn-project/end-to-end/src/automine/effects/pruned_blocks.test.ts index 7918378715b5..35c25090df7f 100644 --- a/yarn-project/end-to-end/src/e2e_pruned_blocks.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/pruned_blocks.test.ts @@ -9,8 +9,7 @@ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client' import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Tests PXE interacting with a node that has pruned relevant blocks, preventing usage of the archive API (which PXE // should not rely on). @@ -18,7 +17,7 @@ import { setup } from './fixtures/utils.js'; // Uses a single node with AutomineSequencer, worldStateCheckpointHistory=2, and // aztecProofSubmissionEpochs=1024 (effectively no reorg). markAsProven + extra L1 blocks cause world-state // to prune old block data; the test then verifies that PXE can still discover notes from pruned blocks. -describe('e2e_pruned_blocks', () => { +describe('automine/effects/pruned_blocks', () => { jest.setTimeout(5 * 60 * 1000); let logger: Logger; @@ -50,13 +49,15 @@ describe('e2e_pruned_blocks', () => { teardown, wallet, accounts: [admin, sender, recipient], - } = await setup(3, { - ...AUTOMINE_E2E_OPTS, - worldStateCheckpointHistory: WORLD_STATE_CHECKPOINT_HISTORY, - worldStateBlockCheckIntervalMS: WORLD_STATE_CHECK_INTERVAL_MS, - archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS, - aztecProofSubmissionEpochs: 1024, // effectively do not reorg - })); + } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 3, + worldStateCheckpointHistory: WORLD_STATE_CHECKPOINT_HISTORY, + worldStateBlockCheckIntervalMS: WORLD_STATE_CHECK_INTERVAL_MS, + archiverPollingIntervalMS: ARCHIVER_POLLING_INTERVAL_MS, + aztecProofSubmissionEpochs: 1024, // effectively do not reorg + }) + ).context); ({ contract: token } = await TokenContract.deploy(wallet, admin, 'TEST', '$TST', 18).send({ from: admin })); logger.info(`L2 token contract deployed at ${token.address}`); diff --git a/yarn-project/end-to-end/src/e2e_tx_effect_oracle.test.ts b/yarn-project/end-to-end/src/automine/effects/tx_effect_oracle.parallel.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_tx_effect_oracle.test.ts rename to yarn-project/end-to-end/src/automine/effects/tx_effect_oracle.parallel.test.ts index 78764f52f1d1..880c2276b52c 100644 --- a/yarn-project/end-to-end/src/e2e_tx_effect_oracle.test.ts +++ b/yarn-project/end-to-end/src/automine/effects/tx_effect_oracle.parallel.test.ts @@ -19,8 +19,7 @@ import type { TxEffect, TxHash } from '@aztec/stdlib/tx'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 120_000; @@ -34,7 +33,7 @@ const TIMEOUT = 120_000; // obtained tx effect from oracle with the one obtained directly in TS. // // Uses a single node with AutomineSequencer and one account. -describe('e2e tx effect oracle', () => { +describe('automine/effects/tx_effect_oracle', () => { let contract: TxEffectOracleTestContract; let deployTxHash: TxHash; jest.setTimeout(TIMEOUT); @@ -50,7 +49,7 @@ describe('e2e tx effect oracle', () => { wallet, aztecNode, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); const { contract: deployed, receipt } = await TxEffectOracleTestContract.deploy(wallet).send({ from: defaultAccountAddress, }); diff --git a/yarn-project/end-to-end/src/e2e_expiration_timestamp.test.ts b/yarn-project/end-to-end/src/automine/expiration_timestamp.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_expiration_timestamp.test.ts rename to yarn-project/end-to-end/src/automine/expiration_timestamp.test.ts index a42b04e229dc..284a9895fafa 100644 --- a/yarn-project/end-to-end/src/e2e_expiration_timestamp.test.ts +++ b/yarn-project/end-to-end/src/automine/expiration_timestamp.test.ts @@ -5,16 +5,15 @@ import { TestContract } from '@aztec/noir-test-contracts.js/Test'; import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; import { TX_ERROR_INVALID_EXPIRATION_TIMESTAMP } from '@aztec/stdlib/tx'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { proveInteraction } from '../test-wallet/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Covers transaction expiration-timestamp enforcement: setting a valid expiration succeeds, setting // one below the mined block timestamp fails at prove time, and setting one that is then warped past // by L1 time causes rejection at submission. Uses a single automine node; L1 time is warped via // cheatCodes.eth.warp in the invalidation tests. -describe('e2e_expiration_timestamp', () => { +describe('automine/expiration_timestamp', () => { let wallet: TestWallet; let defaultAccountAddress: AztecAddress; let aztecNode: AztecNode & AztecNodeDebug; @@ -32,7 +31,7 @@ describe('e2e_expiration_timestamp', () => { aztecNode, cheatCodes, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await TestContract.deploy(wallet).send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_genesis_timestamp.test.ts b/yarn-project/end-to-end/src/automine/genesis_timestamp.parallel.test.ts similarity index 94% rename from yarn-project/end-to-end/src/e2e_genesis_timestamp.test.ts rename to yarn-project/end-to-end/src/automine/genesis_timestamp.parallel.test.ts index 26f17f834832..e48dffce310f 100644 --- a/yarn-project/end-to-end/src/e2e_genesis_timestamp.test.ts +++ b/yarn-project/end-to-end/src/automine/genesis_timestamp.parallel.test.ts @@ -3,9 +3,9 @@ import { NO_FROM } from '@aztec/aztec.js/account'; import { createLogger } from '@aztec/aztec.js/log'; import { retryUntil } from '@aztec/foundation/retry'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { type EndToEndContext, setup } from './fixtures/utils.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { EndToEndContext } from '../fixtures/utils.js'; +import { proveInteraction } from '../test-wallet/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Verifies that genesis-anchored transactions (proved while PXE is pinned to block 0) can be // included in blocks after block 1, and that PXE can prove transactions anchored to genesis even @@ -14,7 +14,7 @@ import { proveInteraction } from './test-wallet/utils.js'; // syncChainTip='proven' so the anchor stays at genesis until a real proof lands, which never happens // in these tests (no prover node running). (v5: replaced skipAccountDeployment with // advancePastGenesis=false + explicit additionallyFundedAccounts.) -describe('e2e_genesis_timestamp', () => { +describe('automine/genesis_timestamp', () => { let context: EndToEndContext; const logger = createLogger('e2e:genesis_timestamp'); @@ -24,10 +24,9 @@ describe('e2e_genesis_timestamp', () => { // anchor lags behind proposed blocks. Under AUTOMINE_E2E_OPTS the AnvilTestWatcher is disabled // and the AutomineSequencer never marks blocks as proven on its own, so without a prover node // the proven tip stays at genesis for the duration of the test. - context = await setup( - 0, - { - ...AUTOMINE_E2E_OPTS, + context = ( + await AutomineTestContext.setup({ + numberOfAccounts: 0, // This suite pins the proven tip at genesis (no prover node, syncChainTip:'proven', // advancePastGenesis:false) and asserts on genesis-anchored txs. Mining the L1 setup txs // instantly shifts how far L1 time advances past the rollup genesis during deployment, which @@ -36,9 +35,9 @@ describe('e2e_genesis_timestamp', () => { advancePastGenesis: false, // This test proves genesis-anchored account deployment txs, so it needs deployable accounts additionallyFundedAccounts: await generateSchnorrAccounts(2, 'schnorr'), - }, - { syncChainTip: 'proven' }, - ); + pxeOpts: { syncChainTip: 'proven' }, + }) + ).context; }); afterEach(() => context.teardown()); diff --git a/yarn-project/end-to-end/src/e2e_mempool_limit.test.ts b/yarn-project/end-to-end/src/automine/mempool_limit.test.ts similarity index 87% rename from yarn-project/end-to-end/src/e2e_mempool_limit.test.ts rename to yarn-project/end-to-end/src/automine/mempool_limit.test.ts index 5015a2ec076d..28f8a5dc3258 100644 --- a/yarn-project/end-to-end/src/e2e_mempool_limit.test.ts +++ b/yarn-project/end-to-end/src/automine/mempool_limit.test.ts @@ -4,14 +4,14 @@ import { TxStatus } from '@aztec/aztec.js/tx'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import type { AztecNode, AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { type EndToEndContext, setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { EndToEndContext } from '../fixtures/utils.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { proveInteraction } from '../test-wallet/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Verifies that the node rejects incoming transactions when the mempool is at capacity. Uses a // single automine node with aztecNodeAdmin access; sequencer is paused to let txs accumulate. -describe('e2e_mempool_limit', () => { +describe('automine/mempool_limit', () => { let wallet: TestWallet; let defaultAccountAddress: AztecAddress; let aztecNode: AztecNode; @@ -26,10 +26,12 @@ describe('e2e_mempool_limit', () => { aztecNodeAdmin, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { - ...AUTOMINE_E2E_OPTS, - proverTestVerificationDelayMs: undefined, - })); + } = ( + await AutomineTestContext.setup({ + numberOfAccounts: 1, + proverTestVerificationDelayMs: undefined, + }) + ).context); if (!aztecNodeAdmin) { throw new Error('Aztec node admin API must be available for this test'); diff --git a/yarn-project/end-to-end/src/e2e_ordering.test.ts b/yarn-project/end-to-end/src/automine/ordering.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_ordering.test.ts rename to yarn-project/end-to-end/src/automine/ordering.test.ts index eb9f0e214cdf..5b49bb9d88cd 100644 --- a/yarn-project/end-to-end/src/e2e_ordering.test.ts +++ b/yarn-project/end-to-end/src/automine/ordering.test.ts @@ -13,17 +13,16 @@ import { computeCalldataHash } from '@aztec/stdlib/hash'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; -import { proveInteraction } from './test-wallet/utils.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { proveInteraction } from '../test-wallet/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; const TIMEOUT = 300_000; // See https://github.com/AztecProtocol/aztec-packages/issues/1601 // Verifies deterministic execution ordering for enqueued public calls and public state updates. // Uses a single node with AutomineSequencer; each test mines one block per call via beforeEach setup. -describe('e2e_ordering', () => { +describe('automine/ordering', () => { jest.setTimeout(TIMEOUT); let wallet: TestWallet; @@ -50,7 +49,7 @@ describe('e2e_ordering', () => { wallet, aztecNode, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); }, TIMEOUT); afterEach(() => teardown()); diff --git a/yarn-project/end-to-end/src/e2e_phase_check.test.ts b/yarn-project/end-to-end/src/automine/phase_check.parallel.test.ts similarity index 89% rename from yarn-project/end-to-end/src/e2e_phase_check.test.ts rename to yarn-project/end-to-end/src/automine/phase_check.parallel.test.ts index 5dcb027a5e1a..36904d001078 100644 --- a/yarn-project/end-to-end/src/e2e_phase_check.test.ts +++ b/yarn-project/end-to-end/src/automine/phase_check.parallel.test.ts @@ -9,16 +9,15 @@ import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contra import { PublicDataTreeLeaf } from '@aztec/stdlib/trees'; import { defaultInitialAccountFeeJuice } from '@aztec/world-state/testing'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Private functions should receive automatically a phase check that avoids any nested call changing the phase. // Functions that opt out of this phase check can be marked with #[allow_phase_change]. // // Uses a single node with AutomineSequencer. The setup pre-funds a custom SponsoredFPC via genesisPublicData // so that fee payment can be crafted without ending the setup phase, which is needed to trigger the phase-change error. -describe('Phase check', () => { +describe('automine/phase_check', () => { let wallet: TestWallet; let defaultAccountAddress: AztecAddress; let teardown: () => Promise; @@ -37,7 +36,7 @@ describe('Phase check', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS, genesisPublicData: [genesisBalanceEntry] })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1, genesisPublicData: [genesisBalanceEntry] })).context); ({ contract } = await TestContract.deploy(wallet).send({ from: defaultAccountAddress })); sponsoredFPC = await SponsoredFPCNoEndSetupContract.deploy(wallet, { @@ -71,7 +70,7 @@ describe('Phase check', () => { // Same scenario but the function is annotated with #[allow_phase_change]; asserts the simulation // succeeds without throwing. - it('should not fail when a nested call changes the phase if #[allow_phase_change] is used', async () => { + it('should not fail when a nested call changes the phase if the allow_phase_change attribute is used', async () => { await contract.methods.call_function_that_ends_setup_without_phase_check().simulate({ from: defaultAccountAddress, fee: { diff --git a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts b/yarn-project/end-to-end/src/automine/private_voting.test.ts similarity index 92% rename from yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts rename to yarn-project/end-to-end/src/automine/private_voting.test.ts index 3dcbd0157746..1f321c6c8d85 100644 --- a/yarn-project/end-to-end/src/e2e_private_voting_contract.test.ts +++ b/yarn-project/end-to-end/src/automine/private_voting.test.ts @@ -5,12 +5,11 @@ import type { Wallet } from '@aztec/aztec.js/wallet'; import { PrivateVotingContract } from '@aztec/noir-contracts.js/PrivateVoting'; import { TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Verifies the PrivateVoting contract's nullifier-based double-vote prevention. Uses a single node // with AutomineSequencer and one account. -describe('e2e_voting_contract', () => { +describe('automine/private_voting', () => { let wallet: Wallet; let logger: Logger; @@ -26,7 +25,7 @@ describe('e2e_voting_contract', () => { wallet, logger, accounts: [owner], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract: votingContract } = await PrivateVotingContract.deploy(wallet, owner).send({ from: owner })); diff --git a/yarn-project/end-to-end/src/e2e_pxe.test.ts b/yarn-project/end-to-end/src/automine/pxe.test.ts similarity index 85% rename from yarn-project/end-to-end/src/e2e_pxe.test.ts rename to yarn-project/end-to-end/src/automine/pxe.test.ts index ce0092793338..3fdb95dbe14b 100644 --- a/yarn-project/end-to-end/src/e2e_pxe.test.ts +++ b/yarn-project/end-to-end/src/automine/pxe.test.ts @@ -3,15 +3,14 @@ import { Fr } from '@aztec/aztec.js/fields'; import { TestContract } from '@aztec/noir-test-contracts.js/Test'; import { TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { AutomineTestContext } from './automine_test_context.js'; // TODO: Ideally these would be unit tests for PXE, but some functions like simulateTx, proveTx, etc require // more complex setup // // Exercises PXE simulation error paths that require a running node. Single node with AutomineSequencer. -describe('e2e_pxe', () => { +describe('automine/pxe', () => { let wallet: TestWallet; let defaultAccountAddress: AztecAddress; let teardown: () => Promise; @@ -23,7 +22,7 @@ describe('e2e_pxe', () => { teardown, wallet, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await TestContract.deploy(wallet).send({ from: defaultAccountAddress })); }); diff --git a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts b/yarn-project/end-to-end/src/automine/simulation/avm_simulator.test.ts similarity index 99% rename from yarn-project/end-to-end/src/e2e_avm_simulator.test.ts rename to yarn-project/end-to-end/src/automine/simulation/avm_simulator.test.ts index 8da1fbee15a0..04670932deda 100644 --- a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts +++ b/yarn-project/end-to-end/src/automine/simulation/avm_simulator.test.ts @@ -9,8 +9,7 @@ import { AvmTestContract } from '@aztec/noir-test-contracts.js/AvmTest'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 600_000; @@ -18,7 +17,7 @@ const TIMEOUT = 600_000; // nested calls, gas metering, contract instances, L2→L1 messages, and public-storage overrides. // Uses setup(1, AUTOMINE_E2E_OPTS) providing one node, automine sequencer, one funded account. // CI runs this as a separate job with TIMEOUT=30m and optionally dumps AVM circuit inputs. -describe('e2e_avm_simulator', () => { +describe('automine/simulation/avm_simulator', () => { jest.setTimeout(TIMEOUT); let wallet: Wallet; @@ -32,7 +31,7 @@ describe('e2e_avm_simulator', () => { wallet, aztecNode, accounts: [defaultAccountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); }); afterAll(() => teardown()); diff --git a/yarn-project/end-to-end/src/e2e_circuit_recorder.test.ts b/yarn-project/end-to-end/src/automine/simulation/circuit_recorder.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_circuit_recorder.test.ts rename to yarn-project/end-to-end/src/automine/simulation/circuit_recorder.test.ts index d5b79f23eb35..517ffeba2fe1 100644 --- a/yarn-project/end-to-end/src/e2e_circuit_recorder.test.ts +++ b/yarn-project/end-to-end/src/automine/simulation/circuit_recorder.test.ts @@ -4,8 +4,7 @@ import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; import fs from 'fs/promises'; import path from 'path'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; /** * Tests the circuit recorder is working as expected. To read more about it, check JSDoc of CircuitRecorder class. @@ -15,7 +14,7 @@ import { setup } from './fixtures/utils.js'; // ChildContract) and protocol circuits (PrivateKernelInit variant). (v5: the default account is now // initializerless, so the user circuit recorded is the entrypoint, not a SchnorrAccount constructor.) // Uses setup(1, AUTOMINE_E2E_OPTS) with one node, automine sequencer, one account. -describe('Circuit Recorder', () => { +describe('automine/simulation/circuit_recorder', () => { const RECORD_DIR = './circuit_recordings'; // Sets CIRCUIT_RECORD_DIR env var, runs setup + a ChildContract deploy to trigger circuit execution, @@ -31,7 +30,7 @@ describe('Circuit Recorder', () => { teardown, wallet, accounts: [accountAddress], - } = await setup(1, { ...AUTOMINE_E2E_OPTS }); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context; await ChildContract.deploy(wallet).send({ from: accountAddress }); // Check recording directory exists diff --git a/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts b/yarn-project/end-to-end/src/automine/simulation/kernelless_simulation.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts rename to yarn-project/end-to-end/src/automine/simulation/kernelless_simulation.test.ts index 1ebc44b62c01..e1ba22b90a42 100644 --- a/yarn-project/end-to-end/src/e2e_kernelless_simulation.test.ts +++ b/yarn-project/end-to-end/src/automine/simulation/kernelless_simulation.test.ts @@ -19,11 +19,10 @@ import { MerkleTreeId } from '@aztec/stdlib/trees'; import { jest } from '@jest/globals'; -import { simulateThroughAuthwitProxy } from './fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { deployToken, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; /* * Demonstrates the capability of simulating a transaction without executing the kernels, allowing @@ -33,7 +32,7 @@ import type { TestWallet } from './test-wallet/test_wallet.js'; * Uses a single automine node with three funded accounts (admin, liquidityProvider, swapper), * an AMM with two token pairs, and various test contracts deployed in beforeAll. */ -describe('Kernelless simulation', () => { +describe('automine/simulation/kernelless_simulation', () => { let teardown: () => Promise; let logger: Logger; @@ -60,7 +59,7 @@ describe('Kernelless simulation', () => { wallet, accounts: [adminAddress, liquidityProviderAddress, swapperAddress], logger, - } = await setup(3, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 3 })).context); ({ contract: token0 } = await deployToken(wallet, adminAddress, 0n, logger)); ({ contract: token1 } = await deployToken(wallet, adminAddress, 0n, logger)); diff --git a/yarn-project/end-to-end/src/e2e_automine_smoke.test.ts b/yarn-project/end-to-end/src/automine/smoke.parallel.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_automine_smoke.test.ts rename to yarn-project/end-to-end/src/automine/smoke.parallel.test.ts index f85a6c7f666c..556d500293b7 100644 --- a/yarn-project/end-to-end/src/e2e_automine_smoke.test.ts +++ b/yarn-project/end-to-end/src/automine/smoke.parallel.test.ts @@ -11,13 +11,12 @@ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client' import { jest } from '@jest/globals'; import 'jest-extended'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from './automine_test_context.js'; // Smoke tests for the AutomineSequencer: verifies that sequential and parallel txs land correctly, // time warps work, mineBlock produces checkpoints, and revertToCheckpoint restores chain state. // Uses setup(1, AUTOMINE_E2E_OPTS) providing one node with AutomineSequencer. -describe('e2e_automine_smoke', () => { +describe('automine/smoke', () => { jest.setTimeout(10 * 60 * 1000); let teardown: () => Promise; @@ -36,7 +35,7 @@ describe('e2e_automine_smoke', () => { wallet, accounts: [owner], cheatCodes, - } = await setup(1, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context); ({ contract } = await TestContract.deploy(wallet).send({ from: owner })); }); @@ -117,7 +116,7 @@ describe('e2e_automine_smoke', () => { // Mines two checkpoints, then calls automine.revertToCheckpoint(first). Asserts the archiver tip // reverts to the earlier checkpoint and a fresh tx lands cleanly on the reverted chain. - it('revertToCheckpoint rolls back L1+L2 state', async () => { + it('revertToCheckpoint rolls back L1 and L2 state', async () => { // Land a tx and record the checkpoint it landed at. await contract.methods.emit_nullifier_public(BigInt(5000)).send({ from: owner }); const checkpointBefore = (await aztecNode.getChainTips()).checkpointed.checkpoint.number; diff --git a/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts b/yarn-project/end-to-end/src/automine/token/access_control.parallel.test.ts similarity index 62% rename from yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts rename to yarn-project/end-to-end/src/automine/token/access_control.parallel.test.ts index 0c4553a044b7..4806a4c74be7 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts +++ b/yarn-project/end-to-end/src/automine/token/access_control.parallel.test.ts @@ -1,15 +1,14 @@ -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers admin and minter role management on the Token contract: set_admin, set_minter, and failure cases // when called by a non-admin. Setup: single node with AutomineSequencer (AUTOMINE_E2E_OPTS), 3 accounts // deployed, Token contract deployed. No time-warp needed (Token has no role-change delay). -describe('e2e_token_contract access control', () => { +describe('automine/token/access_control', () => { const t = new TokenContractTest('access_control'); beforeAll(async () => { t.applyBaseSnapshots(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); }); afterAll(async () => { @@ -20,30 +19,38 @@ describe('e2e_token_contract access control', () => { await t.tokenSim.check(); }); - // Sets account1 as the new admin via set_admin, then reads back the admin via get_admin. - it('Set admin', async () => { + // Exercises the full admin/minter role narrative as one test: adminAddress hands admin to account1, + // account1 (now admin) grants itself minter, then revokes it. These steps form an ordered chain + // (each builds on the previous), so they live in a single it() — the .parallel split runs every + // top-level it() in its own isolated container, where separate ordered tests could not see each + // other's state. + it('Manages admin and minter roles', async () => { await t.asset.methods.set_admin(t.account1Address).send({ from: t.adminAddress }); expect((await t.asset.methods.get_admin().simulate({ from: t.adminAddress })).result).toBe( t.account1Address.toBigInt(), ); - }); - // Grants minter role to account1 (now admin) via set_minter(true) and verifies via is_minter. - it('Add minter as admin', async () => { await t.asset.methods.set_minter(t.account1Address, true).send({ from: t.account1Address }); expect((await t.asset.methods.is_minter(t.account1Address).simulate({ from: t.adminAddress })).result).toBe(true); - }); - // Revokes minter role from account1 via set_minter(false) and verifies via is_minter. - it('Revoke minter as admin', async () => { await t.asset.methods.set_minter(t.account1Address, false).send({ from: t.account1Address }); expect((await t.asset.methods.is_minter(t.account1Address).simulate({ from: t.adminAddress })).result).toBe(false); }); - // Error cases: unauthorized set_admin and unauthorized set_minter. + // Error cases: unauthorized set_admin and unauthorized set_minter. These assert that calls from + // t.adminAddress revert once it is no longer admin, so the block transfers admin to account1 in its + // own beforeAll rather than relying on the 'Set admin' test above having run (CI runs tests in + // isolation). The transfer is idempotent: it is skipped if admin was already moved. describe('failure cases', () => { + beforeAll(async () => { + const currentAdmin = (await t.asset.methods.get_admin().simulate({ from: t.adminAddress })).result; + if (currentAdmin === t.adminAddress.toBigInt()) { + await t.asset.methods.set_admin(t.account1Address).send({ from: t.adminAddress }); + } + }); + // Attempts set_admin from the original admin address (which is no longer admin); expects 'caller is not admin'. - it('Set admin (not admin)', async () => { + it('Set admin not as admin', async () => { await expect(t.asset.methods.set_admin(t.adminAddress).simulate({ from: t.adminAddress })).rejects.toThrow( 'Assertion failed: caller is not admin', ); diff --git a/yarn-project/end-to-end/src/e2e_amm.test.ts b/yarn-project/end-to-end/src/automine/token/amm.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_amm.test.ts rename to yarn-project/end-to-end/src/automine/token/amm.test.ts index cec42bc3ac71..b65beb77d206 100644 --- a/yarn-project/end-to-end/src/e2e_amm.test.ts +++ b/yarn-project/end-to-end/src/automine/token/amm.test.ts @@ -6,10 +6,9 @@ import type { TokenContract } from '@aztec/noir-contracts.js/Token'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { deployToken, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 900_000; @@ -18,7 +17,7 @@ const TIMEOUT = 900_000; // sequencer, four funded accounts (admin, two LPs, swapper), and three deployed Token contracts. // TODO(F-560): Consider whether it makes sense to drop this // https://linear.app/aztec-labs/issue/F-560/add-more-tests-to-forward-compatibility-testing -describe('AMM', () => { +describe('automine/token/amm', () => { jest.setTimeout(TIMEOUT); let teardown: () => Promise; @@ -54,7 +53,7 @@ describe('AMM', () => { wallet, accounts: [adminAddress, liquidityProviderAddress, otherLiquidityProviderAddress, swapperAddress], logger, - } = await setup(4, { ...AUTOMINE_E2E_OPTS }, { syncChainTip: 'checkpointed' })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 4, pxeOpts: { syncChainTip: 'checkpointed' } })).context); ({ contract: token0 } = await deployToken(wallet, adminAddress, 0n, logger)); ({ contract: token1 } = await deployToken(wallet, adminAddress, 0n, logger)); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_access_control.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_access_control.test.ts index 8b2b11243474..5d2dca2197e1 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_access_control.test.ts @@ -1,17 +1,16 @@ import { AztecAddress } from '@aztec/aztec.js/addresses'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; import { BlacklistTokenContractTest, Role } from './blacklist_token_contract_test.js'; // Covers role management (admin grant/revoke, minter assignment, blacklisting) on the TokenBlacklist contract. // Setup: single node with AutomineSequencer (AUTOMINE_E2E_OPTS), 3 deployed accounts (admin/other/blacklisted), // TokenBlacklist contract deployed. Role changes require crossing a 86400s L2 time delay enforced by the // contract; crossTimestampOfChange() handles this via markAsProven + warpL2TimeAtLeastBy. -describe('e2e_blacklist_token_contract access control', () => { +describe('automine/token/blacklist_access_control', () => { const t = new BlacklistTokenContractTest('access_control'); beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); }); afterAll(async () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_burn.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_burn.test.ts index aac62974e3a9..4ca9b5a0a314 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_burn.test.ts @@ -1,21 +1,20 @@ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers public and private burn operations on TokenBlacklist, including authwit-delegated burns and // blacklist enforcement. Setup: single node with AutomineSequencer, 3 accounts, TokenBlacklist deployed, // initial mint applied (admin has both public and private balances). Time-warp required to cross // role-change delay (86400s) during setup. -describe('e2e_blacklist_token_contract burn', () => { +describe('automine/token/blacklist_burn', () => { const t = new BlacklistTokenContractTest('burn'); let { asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Beware that we are adding the wallet as minter here, which is very slow because it needs multiple blocks. await t.applyMint(); // Have to destructure again to ensure we have latest refs. diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_minting.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_minting.test.ts index ab1ed42868c6..c606a908799d 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_minting.test.ts @@ -2,19 +2,18 @@ import { computeSecretHash } from '@aztec/aztec.js/crypto'; import { Fr } from '@aztec/aztec.js/fields'; import type { TxHash } from '@aztec/aztec.js/tx'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { U128_OVERFLOW_ERROR } from '../fixtures/index.js'; +import { U128_OVERFLOW_ERROR } from '../../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers public and private minting on TokenBlacklist, including minter role enforcement and blacklist // restrictions on recipients. Setup: single node with AutomineSequencer, 3 accounts, TokenBlacklist // deployed with initial balances (applyMint). Role-change delay requires time-warp during setup. -describe('e2e_blacklist_token_contract mint', () => { +describe('automine/token/blacklist_minting', () => { const t = new BlacklistTokenContractTest('mint'); let { asset, tokenSim, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Beware that we are adding the admin as minter here, which is very slow because it needs multiple blocks. await t.applyMint(); // Have to destructure again to ensure we have latest refs. diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_shielding.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_shielding.test.ts index b4b3f84917e0..be9bda564c61 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_shielding.test.ts @@ -1,19 +1,18 @@ import { computeSecretHash } from '@aztec/aztec.js/crypto'; import { Fr } from '@aztec/aztec.js/fields'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { U128_UNDERFLOW_ERROR } from '../../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers the shield (public→private) and redeem_shield operations on TokenBlacklist, including // authwit-delegated shielding and blacklist enforcement. Setup: single node with AutomineSequencer, // 3 accounts, initial mint applied. Time-warp required during setup to cross role-change delay. -describe('e2e_blacklist_token_contract shield + redeem_shield', () => { +describe('automine/token/blacklist_shielding', () => { const t = new BlacklistTokenContractTest('shield'); let { asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); await t.applyMint(); // Beware that we are adding the admin as minter here // Have to destructure again to ensure we have latest refs. ({ asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_token_contract_test.ts similarity index 79% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_token_contract_test.ts index 1639de4c38d3..79ec8a8f2f6a 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_token_contract_test.ts @@ -1,28 +1,18 @@ import { AztecAddress } from '@aztec/aztec.js/addresses'; import { computeSecretHash } from '@aztec/aztec.js/crypto'; import { Fr } from '@aztec/aztec.js/fields'; -import { type Logger, createLogger } from '@aztec/aztec.js/log'; -import type { AztecNode } from '@aztec/aztec.js/node'; +import { createLogger } from '@aztec/aztec.js/log'; import type { TxHash } from '@aztec/aztec.js/tx'; -import type { CheatCodes } from '@aztec/aztec/testing'; import type { TokenContract } from '@aztec/noir-contracts.js/Token'; import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist'; import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy'; import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount'; -import type { SequencerClient } from '@aztec/sequencer-client'; -import type { AztecNodeDebug } from '@aztec/stdlib/interfaces/client'; import { jest } from '@jest/globals'; -import { - type EndToEndContext, - type SetupOptions, - ensureAuthRegistryPublished, - setup, - teardown, -} from '../fixtures/setup.js'; -import { TokenSimulator } from '../simulators/token_simulator.js'; -import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { ensureAuthRegistryPublished } from '../../fixtures/setup.js'; +import { TokenSimulator } from '../../simulators/token_simulator.js'; +import { AutomineTestContext, type AutomineTestOpts } from '../automine_test_context.js'; export class Role { private isAdmin = false; @@ -51,37 +41,33 @@ export class Role { } } -export class BlacklistTokenContractTest { +/** + * TokenBlacklist-domain harness over the automine topology: extends {@link AutomineTestContext} with a + * {@link TokenSimulator}, the {@link Role} helper, the TokenBlacklist deploy plus a bad-account and + * authwit proxy, and the role-change-delay warp. Base setup and mint run in {@link setup}. + */ +export class BlacklistTokenContractTest extends AutomineTestContext { // This value MUST match the same value that we have in the contract static CHANGE_ROLES_DELAY = 86400; - context!: EndToEndContext; - logger: Logger; - wallet!: TestWallet; asset!: TokenBlacklistContract; tokenSim!: TokenSimulator; badAccount!: InvalidAccountContract; authwitProxy!: GenericProxyContract; - cheatCodes!: CheatCodes; - sequencer!: SequencerClient; - aztecNode!: AztecNode & AztecNodeDebug; adminAddress!: AztecAddress; otherAddress!: AztecAddress; blacklistedAddress!: AztecAddress; + private testName: string; + constructor(testName: string) { - this.logger = createLogger(`e2e:e2e_blacklist_token_contract:${testName}`); + super(); + this.testName = testName; } async crossTimestampOfChange() { - // Under AUTOMINE_E2E_OPTS, the 86400s warp crosses many epochs without any proofs being - // submitted. Mark current pending checkpoints as proven first so the rollup contract's - // pruning window doesn't reset the chain tip to genesis (which would make the warp's - // own empty-checkpoint propose fail with Rollup__InvalidArchive). See the AutomineSequencer - // README "Epoch proving caveat" and the equivalent pattern in lending_simulator.progressSlots. - await this.cheatCodes.rollup.markAsProven(); - await this.cheatCodes.warpL2TimeAtLeastBy(this.aztecNode, BlacklistTokenContractTest.CHANGE_ROLES_DELAY); + await this.markProvenAndWarp(BlacklistTokenContractTest.CHANGE_ROLES_DELAY); } /** @@ -139,19 +125,13 @@ export class BlacklistTokenContractTest { ).toEqual(new Role().withAdmin().toNoirStruct()); } - async setup(opts: Partial = {}) { - this.logger.info('Setting up fresh context'); - this.context = await setup(3, { - ...opts, - fundSponsoredFPC: true, - }); + override async setup(opts: AutomineTestOpts = {}) { + await super.setup({ numberOfAccounts: 3, ...opts }); + // hydrateFromContext repoints `this.logger` at the context logger; restore the harness-named one. + this.logger = createLogger(`e2e:automine:blacklist:${this.testName}`); await this.applyBaseSetup(); } - async teardown() { - await teardown(this.context); - } - async addPendingShieldNoteToPXE( contract: TokenBlacklistContract, recipient: AztecAddress, diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_transfer_private.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_transfer_private.test.ts index 1231e8c2df2f..38b70529cdc8 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_transfer_private.test.ts @@ -1,19 +1,19 @@ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../fixtures/fixtures.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers private token transfers on TokenBlacklist: direct, self-transfer, authwit-delegated, and // blacklist enforcement. Setup: single node with AutomineSequencer, 3 accounts, initial mint applied. // Time-warp required during setup to cross role-change delay. -describe('e2e_blacklist_token_contract transfer private', () => { +describe('automine/token/blacklist_transfer_private', () => { const t = new BlacklistTokenContractTest('transfer_private'); let { asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Beware that we are adding the admin as minter here, which is very slow because it needs multiple blocks. await t.applyMint(); // Have to destructure again to ensure we have latest refs. diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_transfer_public.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_transfer_public.test.ts index 65577ab71af5..3717a08239dd 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_transfer_public.test.ts @@ -1,18 +1,17 @@ import { Fr } from '@aztec/aztec.js/fields'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { U128_UNDERFLOW_ERROR } from '../../fixtures/index.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers public token transfers on TokenBlacklist: direct, self, authwit-delegated, and blacklist // enforcement. Setup: single node with AutomineSequencer, 3 accounts, initial mint applied. // Time-warp required during setup to cross role-change delay. -describe('e2e_blacklist_token_contract transfer public', () => { +describe('automine/token/blacklist_transfer_public', () => { const t = new BlacklistTokenContractTest('transfer_public'); let { asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Beware that we are adding the admin as minter here, which is very slow because it needs multiple blocks. await t.applyMint(); // Have to destructure again to ensure we have latest refs. diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts b/yarn-project/end-to-end/src/automine/token/blacklist_unshielding.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts rename to yarn-project/end-to-end/src/automine/token/blacklist_unshielding.test.ts index 2feca0c06cc9..f1355426843e 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts +++ b/yarn-project/end-to-end/src/automine/token/blacklist_unshielding.test.ts @@ -1,19 +1,19 @@ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../fixtures/fixtures.js'; import { BlacklistTokenContractTest } from './blacklist_token_contract_test.js'; // Covers the unshield (private→public) operation on TokenBlacklist, including authwit-delegated unshielding // and blacklist enforcement on sender and recipient. Setup: single node with AutomineSequencer, 3 accounts, // initial mint applied. Time-warp required during setup to cross role-change delay. -describe('e2e_blacklist_token_contract unshielding', () => { +describe('automine/token/blacklist_unshielding', () => { const t = new BlacklistTokenContractTest('unshielding'); let { asset, tokenSim, wallet, adminAddress, otherAddress, blacklistedAddress } = t; beforeAll(async () => { - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Beware that we are adding the admin as minter here, which is very slow because it needs multiple blocks. await t.applyMint(); // Have to destructure again to ensure we have latest refs. diff --git a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts b/yarn-project/end-to-end/src/automine/token/burn.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts rename to yarn-project/end-to-end/src/automine/token/burn.test.ts index 0540453ab413..b317cb9b41e0 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/automine/token/burn.test.ts @@ -1,20 +1,20 @@ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../fixtures/index.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR, U128_UNDERFLOW_ERROR } from '../../fixtures/index.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers public and private burn on Token contract: direct, authwit-delegated via proxy, and error paths. // Setup: single node with AutomineSequencer, 3 accounts, Token deployed with initial public and private mint. -describe('e2e_token_contract burn', () => { +describe('automine/token/burn', () => { const t = new TokenContractTest('burn'); let { asset, tokenSim, wallet, adminAddress, account1Address } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Have to destructure again to ensure we have latest refs. ({ asset, wallet, adminAddress, tokenSim, adminAddress, account1Address } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/automine/token/crowdfunding_and_claim.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts rename to yarn-project/end-to-end/src/automine/token/crowdfunding_and_claim.test.ts index bed7cffbe82b..c5ed4e47108f 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/automine/token/crowdfunding_and_claim.test.ts @@ -10,17 +10,17 @@ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client' import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { mintTokensToPrivate } from './fixtures/token_utils.js'; -import { ensurePublicChecksPublished, setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import { ensurePublicChecksPublished } from '../../fixtures/utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; jest.setTimeout(400_000); // Tests crowdfunding via the Crowdfunding contract and claiming the reward token via the Claim contract. // Uses setup(3, AUTOMINE_E2E_OPTS) with one node, automine sequencer, three accounts (operator, 2 donors). // One test warps L1 time via cheatCodes.eth.warp to pass the deadline. jest.setTimeout(400s). -describe('e2e_crowdfunding_and_claim', () => { +describe('automine/token/crowdfunding_and_claim', () => { const donationTokenMetadata = { name: 'Donation Token', symbol: 'DNT', @@ -63,7 +63,7 @@ describe('e2e_crowdfunding_and_claim', () => { wallet, aztecNode: _aztecNode, accounts: [operatorAddress, donor1Address, donor2Address], - } = await setup(3, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 3 })).context); // Crowdfunding's `donate` calls `privately_check_timestamp`, which dispatches into the deployed // PublicChecks contract. Publish PublicChecks before the test runs anything that uses it. diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/automine/token/escrow.parallel.test.ts similarity index 91% rename from yarn-project/end-to-end/src/e2e_escrow_contract.test.ts rename to yarn-project/end-to-end/src/automine/token/escrow.parallel.test.ts index 330ddf9f5425..735dd0ec4254 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/automine/token/escrow.parallel.test.ts @@ -7,15 +7,14 @@ import { EscrowContract } from '@aztec/noir-contracts.js/Escrow'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import type { PublicKeys } from '@aztec/stdlib/keys'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { expectTokenBalance, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { expectTokenBalance, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Tests the Escrow contract: withdrawing to a recipient, access-control enforcement, and // multi-key batch operations. Uses setup(2, AUTOMINE_E2E_OPTS) with one node, automine sequencer, // and two funded accounts (owner, recipient). A fresh escrow and token are deployed in beforeEach. -describe('e2e_escrow_contract', () => { +describe('automine/token/escrow', () => { let wallet: TestWallet; let logger: Logger; @@ -36,7 +35,7 @@ describe('e2e_escrow_contract', () => { wallet, accounts: [owner, recipient], logger, - } = await setup(2, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 2 })).context); // Generate private key for escrow contract, register key in PXE, and deploy // Note that we need to register it first if we want to emit an encrypted note for it in the constructor @@ -94,7 +93,7 @@ describe('e2e_escrow_contract', () => { // Mints 50 to owner, then uses BatchCall to transfer 10 from owner and withdraw 20 from escrow // in the same tx. Asserts recipient ends up with 30 total. - it('moves funds using multiple keys on the same tx (#1010)', async () => { + it('moves funds using multiple keys on the same tx - regression 1010', async () => { logger.info(`Minting funds in token contract to ${owner}`); const mintAmount = 50n; diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/automine/token/lending.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_lending_contract.test.ts rename to yarn-project/end-to-end/src/automine/token/lending.test.ts index 56a044664ab4..ab781010f946 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/automine/token/lending.test.ts @@ -12,18 +12,18 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { afterAll, jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import type { EndToEndContext } from './fixtures/setup.js'; -import { mintTokensToPrivate } from './fixtures/token_utils.js'; -import { ensureAuthRegistryPublished, setup } from './fixtures/utils.js'; -import { LendingAccount, LendingSimulator, TokenSimulator } from './simulators/index.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import type { EndToEndContext } from '../../fixtures/setup.js'; +import { mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import { ensureAuthRegistryPublished } from '../../fixtures/utils.js'; +import { LendingAccount, LendingSimulator, TokenSimulator } from '../../simulators/index.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; // Covers the full lifecycle of the Lending contract (deposit, borrow, repay, withdraw) in both // private (🥸) and public paths, with and without authorization witnesses. Uses a single automine // node; LendingSimulator tracks expected state and verifies after each test. Note that the // lendingSim.progressSlots calls advance slot time on the simulator (not L1 time directly). -describe('e2e_lending_contract', () => { +describe('automine/token/lending', () => { jest.setTimeout(100_000); let wallet: TestWallet; let defaultAccountAddress: AztecAddress; @@ -85,7 +85,7 @@ describe('e2e_lending_contract', () => { }; beforeAll(async () => { - const ctx = await setup(1, { ...AUTOMINE_E2E_OPTS }); + const ctx = (await AutomineTestContext.setup({ numberOfAccounts: 1 })).context; ({ teardown, logger, diff --git a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts b/yarn-project/end-to-end/src/automine/token/minting.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts rename to yarn-project/end-to-end/src/automine/token/minting.test.ts index 43449b6a1abd..7e128d6bd899 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/automine/token/minting.test.ts @@ -1,15 +1,15 @@ -import { AUTOMINE_E2E_OPTS, U128_OVERFLOW_ERROR } from '../fixtures/fixtures.js'; +import { U128_OVERFLOW_ERROR } from '../../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers public and private minting on Token contract, including minter role enforcement and overflow checks. // Setup: single node with AutomineSequencer, 3 accounts deployed, Token contract deployed (no initial mint). -describe('e2e_token_contract minting', () => { +describe('automine/token/minting', () => { const t = new TokenContractTest('minting'); let { asset, tokenSim, adminAddress, account1Address } = t; beforeAll(async () => { t.applyBaseSnapshots(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ asset, tokenSim, adminAddress, account1Address } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_nft.test.ts b/yarn-project/end-to-end/src/automine/token/nft.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_nft.test.ts rename to yarn-project/end-to-end/src/automine/token/nft.test.ts index 04bd19842852..97768d4ee01e 100644 --- a/yarn-project/end-to-end/src/e2e_nft.test.ts +++ b/yarn-project/end-to-end/src/automine/token/nft.test.ts @@ -5,8 +5,7 @@ import { NFTContract } from '@aztec/noir-contracts.js/NFT'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { setup } from './fixtures/utils.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -14,7 +13,7 @@ const TIMEOUT = 300_000; // This test is only kept around to check that public data writes are squashed as expected. // Single automine node, four funded accounts (admin, minter, user1, user2), NFTContract deployed. // Tests are sequential: each depends on the state left by the previous. -describe('NFT', () => { +describe('automine/token/nft', () => { jest.setTimeout(TIMEOUT); let teardown: () => Promise; @@ -33,7 +32,7 @@ describe('NFT', () => { beforeAll(async () => { let accounts: AztecAddress[]; - ({ teardown, wallet, accounts } = await setup(4, { ...AUTOMINE_E2E_OPTS })); + ({ teardown, wallet, accounts } = (await AutomineTestContext.setup({ numberOfAccounts: 4 })).context); [adminAddress, minterAddress, user1Address, user2Address] = accounts; ({ contract: nftContract } = await NFTContract.deploy(wallet, adminAddress, 'FROG', 'FRG').send({ diff --git a/yarn-project/end-to-end/src/e2e_orderbook.test.ts b/yarn-project/end-to-end/src/automine/token/orderbook.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_orderbook.test.ts rename to yarn-project/end-to-end/src/automine/token/orderbook.test.ts index d9b6390ae178..00a03a253df7 100644 --- a/yarn-project/end-to-end/src/e2e_orderbook.test.ts +++ b/yarn-project/end-to-end/src/automine/token/orderbook.test.ts @@ -9,10 +9,9 @@ import type { TokenContract } from '@aztec/noir-contracts.js/Token'; import { jest } from '@jest/globals'; -import { AUTOMINE_E2E_OPTS } from './fixtures/fixtures.js'; -import { deployToken, mintTokensToPrivate } from './fixtures/token_utils.js'; -import { setup } from './fixtures/utils.js'; -import type { TestWallet } from './test-wallet/test_wallet.js'; +import { deployToken, mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import type { TestWallet } from '../../test-wallet/test_wallet.js'; +import { AutomineTestContext } from '../automine_test_context.js'; const TIMEOUT = 300_000; @@ -24,7 +23,7 @@ const TIMEOUT = 300_000; // Exercises the Orderbook contract's create_order / fulfill_order flow. Uses a single node with AutomineSequencer // and three accounts (admin, maker, taker). Each step lands in its own block; the partial note opened by // create_order is completed in fulfill_order's block. -describe('Orderbook', () => { +describe('automine/token/orderbook', () => { jest.setTimeout(TIMEOUT); let teardown: () => Promise; @@ -52,7 +51,7 @@ describe('Orderbook', () => { accounts: [adminAddress, makerAddress, takerAddress], aztecNode, logger, - } = await setup(3, { ...AUTOMINE_E2E_OPTS })); + } = (await AutomineTestContext.setup({ numberOfAccounts: 3 })).context); ({ contract: token0 } = await deployToken(wallet, adminAddress, 0n, logger)); ({ contract: token1 } = await deployToken(wallet, adminAddress, 0n, logger)); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/private_transfer_recursion.test.ts b/yarn-project/end-to-end/src/automine/token/private_transfer_recursion.parallel.test.ts similarity index 95% rename from yarn-project/end-to-end/src/e2e_token_contract/private_transfer_recursion.test.ts rename to yarn-project/end-to-end/src/automine/token/private_transfer_recursion.parallel.test.ts index 5143ea0f93e3..53123d182b7f 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/private_transfer_recursion.test.ts +++ b/yarn-project/end-to-end/src/automine/token/private_transfer_recursion.parallel.test.ts @@ -1,20 +1,19 @@ import { BlockNumber } from '@aztec/foundation/branded-types'; import { TokenContract, type Transfer } from '@aztec/noir-contracts.js/Token'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; -import { mintNotes } from '../fixtures/token_utils.js'; +import { mintNotes } from '../../fixtures/token_utils.js'; import { TokenContractTest } from './token_contract_test.js'; // Verifies that the Token contract's private transfer function correctly handles note consolidation across // recursive calls (consuming many notes via two levels of recursion). Also checks that private Transfer // events are emitted and readable. Setup: single node with AutomineSequencer, 3 accounts, Token deployed. -describe('e2e_token_contract private transfer recursion', () => { +describe('automine/token/private_transfer_recursion', () => { const t = new TokenContractTest('odd_transfer_private'); let { asset, wallet, adminAddress, account1Address, node } = t; beforeAll(async () => { t.applyBaseSnapshots(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ asset, wallet, adminAddress, account1Address, node } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts b/yarn-project/end-to-end/src/automine/token/reading_constants.parallel.test.ts similarity index 94% rename from yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts rename to yarn-project/end-to-end/src/automine/token/reading_constants.parallel.test.ts index a74a28ca8d40..48cedf500158 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts +++ b/yarn-project/end-to-end/src/automine/token/reading_constants.parallel.test.ts @@ -1,18 +1,17 @@ import { readFieldCompressedString } from '@aztec/aztec.js/utils'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Verifies that Token contract constants (name, symbol, decimals) are readable from both private and public // entry points and match the values supplied at deploy time. Setup: single node with AutomineSequencer, // Token contract deployed with TOKEN_NAME/SYMBOL/DECIMALS. -describe('e2e_token_contract reading constants', () => { +describe('automine/token/reading_constants', () => { const t = new TokenContractTest('reading_constants'); const { TOKEN_DECIMALS, TOKEN_NAME, TOKEN_SYMBOL } = TokenContractTest; beforeAll(async () => { t.applyBaseSnapshots(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); }); afterAll(async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts b/yarn-project/end-to-end/src/automine/token/token_contract_test.ts similarity index 81% rename from yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts rename to yarn-project/end-to-end/src/automine/token/token_contract_test.ts index 7fe1047e2cff..dcd4043b3d31 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts +++ b/yarn-project/end-to-end/src/automine/token/token_contract_test.ts @@ -1,5 +1,5 @@ import { AztecAddress } from '@aztec/aztec.js/addresses'; -import { type Logger, createLogger } from '@aztec/aztec.js/log'; +import { createLogger } from '@aztec/aztec.js/log'; import type { AztecNode } from '@aztec/aztec.js/node'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy'; @@ -7,25 +7,23 @@ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAcc import { jest } from '@jest/globals'; -import { - type EndToEndContext, - type SetupOptions, - ensureAuthRegistryPublished, - setup, - teardown, -} from '../fixtures/setup.js'; -import { mintTokensToPrivate } from '../fixtures/token_utils.js'; -import { TokenSimulator } from '../simulators/token_simulator.js'; -import type { TestWallet } from '../test-wallet/test_wallet.js'; +import { ensureAuthRegistryPublished } from '../../fixtures/setup.js'; +import { mintTokensToPrivate } from '../../fixtures/token_utils.js'; +import { TokenSimulator } from '../../simulators/token_simulator.js'; +import { AutomineTestContext, type AutomineTestOpts } from '../automine_test_context.js'; const { METRICS_PORT: metricsPort } = process.env; -export class TokenContractTest { +/** + * Token-domain harness over the automine topology: extends {@link AutomineTestContext} with a + * {@link TokenSimulator}, the USDC Token deploy plus a bad-account and authwit proxy, and an optional + * mint. The base/mint steps are opt-in via {@link applyBaseSnapshots}/{@link applyMintSnapshot}, run + * after `super.setup()`. + */ +export class TokenContractTest extends AutomineTestContext { static TOKEN_NAME = 'USDC'; static TOKEN_SYMBOL = 'USD'; static TOKEN_DECIMALS = 18n; - context!: EndToEndContext; - logger: Logger; metricsPort?: number; asset!: TokenContract; tokenSim!: TokenSimulator; @@ -33,16 +31,17 @@ export class TokenContractTest { badAccount!: InvalidAccountContract; authwitProxy!: GenericProxyContract; - wallet!: TestWallet; adminAddress!: AztecAddress; account1Address!: AztecAddress; account2Address!: AztecAddress; private shouldApplyBaseSetup = false; private shouldApplyMint = false; + private testName: string; constructor(testName: string) { - this.logger = createLogger(`e2e:e2e_token_contract:${testName}`); + super(); + this.testName = testName; this.metricsPort = metricsPort ? parseInt(metricsPort) : undefined; } @@ -111,12 +110,10 @@ export class TokenContractTest { ); } - async setup(opts: Partial = {}) { - this.context = await setup(3, { - ...opts, - metricsPort: this.metricsPort, - fundSponsoredFPC: true, - }); + override async setup(opts: AutomineTestOpts = {}) { + await super.setup({ numberOfAccounts: 3, metricsPort: this.metricsPort, ...opts }); + // hydrateFromContext repoints `this.logger` at the context logger; restore the harness-named one. + this.logger = createLogger(`e2e:automine:token:${this.testName}`); if (this.shouldApplyBaseSetup) { await this.applyBaseSetup(); @@ -127,10 +124,6 @@ export class TokenContractTest { } } - async teardown() { - await teardown(this.context); - } - private async applyMint() { this.logger.info('Applying mint setup'); const { asset, adminAddress, tokenSim } = this; diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts b/yarn-project/end-to-end/src/automine/token/transfer.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts rename to yarn-project/end-to-end/src/automine/token/transfer.test.ts index bca964bc8762..6c00f1d9fc15 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer.test.ts +++ b/yarn-project/end-to-end/src/automine/token/transfer.test.ts @@ -2,21 +2,20 @@ import { AztecAddress, CompleteAddress } from '@aztec/aztec.js/addresses'; import { BlockNumber } from '@aztec/foundation/branded-types'; import { TokenContract, type Transfer } from '@aztec/noir-contracts.js/Token'; -import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers the top-level transfer() entry point on Token contract (private-to-private), including transfer to // non-deployed accounts and private Transfer event emission. Note: the describe title collides with // transfer_in_private.test.ts — the tested contract methods differ (transfer vs transfer_in_private). // Setup: single node with AutomineSequencer, 3 accounts, Token deployed with initial mint. -describe('e2e_token_contract transfer private', () => { +describe('automine/token/transfer', () => { const t = new TokenContractTest('transfer_private'); let { asset, adminAddress, wallet, account1Address, tokenSim } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ asset, adminAddress, wallet, account1Address, tokenSim } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts b/yarn-project/end-to-end/src/automine/token/transfer_in_private.test.ts similarity index 97% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts rename to yarn-project/end-to-end/src/automine/token/transfer_in_private.test.ts index 2c2773a46126..5a093f4306e6 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_private.test.ts +++ b/yarn-project/end-to-end/src/automine/token/transfer_in_private.test.ts @@ -1,21 +1,21 @@ import { computeAuthWitMessageHash, computeInnerAuthWitHashFromAction } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers the transfer_in_private entry point on Token contract: authwit-delegated transfers via proxy, // authwit cancellation, and error paths including bad-account validation. Setup: single node with // AutomineSequencer, 3 accounts + InvalidAccount, Token deployed with initial mint. -describe('e2e_token_contract transfer private', () => { +describe('automine/token/transfer_in_private', () => { const t = new TokenContractTest('transfer_private'); let { asset, tokenSim, wallet, adminAddress, account1Address, badAccount } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); ({ asset, tokenSim, wallet, adminAddress, account1Address, badAccount } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts b/yarn-project/end-to-end/src/automine/token/transfer_in_public.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts rename to yarn-project/end-to-end/src/automine/token/transfer_in_public.test.ts index 689736e3facf..a5a55aa13623 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_in_public.test.ts +++ b/yarn-project/end-to-end/src/automine/token/transfer_in_public.test.ts @@ -1,7 +1,7 @@ import { Fr } from '@aztec/aztec.js/fields'; -import { AUTOMINE_E2E_OPTS, U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; -import { type AlertConfig, GrafanaClient } from '../quality_of_service/grafana_client.js'; +import { U128_UNDERFLOW_ERROR } from '../../fixtures/fixtures.js'; +import { type AlertConfig, GrafanaClient } from '../../quality_of_service/grafana_client.js'; import { TokenContractTest } from './token_contract_test.js'; const CHECK_ALERTS = process.env.CHECK_ALERTS === 'true'; @@ -21,14 +21,14 @@ const qosAlerts: AlertConfig[] = [ // Covers the transfer_in_public entry point on Token contract: direct, self, authwit-delegated, authwit // cancellation (two flows), and bad-account validation. Also conditionally checks Grafana QoS alerts when // CHECK_ALERTS=true. Setup: single node with AutomineSequencer, Token deployed with initial mint. -describe('e2e_token_contract transfer public', () => { +describe('automine/token/transfer_in_public', () => { const t = new TokenContractTest('transfer_in_public'); let { asset, tokenSim, wallet, adminAddress, account1Address, badAccount } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Have to destructure again to ensure we have latest refs. ({ asset, tokenSim, wallet, adminAddress, account1Address, badAccount } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts b/yarn-project/end-to-end/src/automine/token/transfer_to_private.test.ts similarity index 93% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts rename to yarn-project/end-to-end/src/automine/token/transfer_to_private.test.ts index e9de4064a1f9..7cca9f3ec34a 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts +++ b/yarn-project/end-to-end/src/automine/token/transfer_to_private.test.ts @@ -1,17 +1,17 @@ -import { AUTOMINE_E2E_OPTS, U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; +import { U128_UNDERFLOW_ERROR } from '../../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers the transfer_to_private entry point on Token contract (public→private), including self and // cross-account transfers. Setup: single node with AutomineSequencer, 3 accounts, Token deployed with // initial mint. -describe('e2e_token_contract transfer_to_private', () => { +describe('automine/token/transfer_to_private', () => { const t = new TokenContractTest('transfer_to_private'); let { asset, adminAddress, account1Address, tokenSim } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Have to destructure again to ensure we have latest refs. ({ asset, adminAddress, account1Address, tokenSim } = t); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_public.test.ts b/yarn-project/end-to-end/src/automine/token/transfer_to_public.test.ts similarity index 96% rename from yarn-project/end-to-end/src/e2e_token_contract/transfer_to_public.test.ts rename to yarn-project/end-to-end/src/automine/token/transfer_to_public.test.ts index 362666dd76ec..db3df48724b4 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_to_public.test.ts +++ b/yarn-project/end-to-end/src/automine/token/transfer_to_public.test.ts @@ -1,21 +1,21 @@ import { computeAuthWitMessageHash } from '@aztec/aztec.js/authorization'; import { Fr } from '@aztec/aztec.js/fields'; -import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../fixtures/authwit_proxy.js'; -import { AUTOMINE_E2E_OPTS, DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; +import { sendThroughAuthwitProxy, simulateThroughAuthwitProxy } from '../../fixtures/authwit_proxy.js'; +import { DUPLICATE_NULLIFIER_ERROR } from '../../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; // Covers the transfer_to_public entry point on Token contract (private→public): direct, authwit-delegated // via proxy, and error paths. Setup: single node with AutomineSequencer, 3 accounts, Token deployed with // initial mint. -describe('e2e_token_contract transfer_to_public', () => { +describe('automine/token/transfer_to_public', () => { const t = new TokenContractTest('transfer_to_public'); let { asset, wallet, adminAddress, account1Address, tokenSim } = t; beforeAll(async () => { t.applyBaseSnapshots(); t.applyMintSnapshot(); - await t.setup({ ...AUTOMINE_E2E_OPTS }); + await t.setup(); // Have to destructure again to ensure we have latest refs. ({ asset, wallet, adminAddress, account1Address, tokenSim } = t); }); diff --git a/yarn-project/end-to-end/src/bench/client_flows/storage_proof.test.ts b/yarn-project/end-to-end/src/bench/client_flows/storage_proof.test.ts index 7dff13c7454c..f8530977e0be 100644 --- a/yarn-project/end-to-end/src/bench/client_flows/storage_proof.test.ts +++ b/yarn-project/end-to-end/src/bench/client_flows/storage_proof.test.ts @@ -10,7 +10,7 @@ import { jest } from '@jest/globals'; import { buildStorageProofCapsules, loadStorageProofArgs, -} from '../../e2e_storage_proof/fixtures/storage_proof_fixture.js'; +} from '../../automine/contracts/fixtures/storage_proof_fixture.js'; import type { TestWallet } from '../../test-wallet/test_wallet.js'; import { captureProfile, expectedExecutionSteps } from './benchmark.js'; import { type AccountType, type BenchmarkingFeePaymentMethod, ClientFlowsBenchmark } from './client_flows_benchmark.js'; diff --git a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts index 2073a2b6b710..fe48d6a45c65 100644 --- a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts @@ -15,7 +15,7 @@ import { mkdtemp } from 'fs/promises'; import { tmpdir } from 'os'; import { join } from 'path'; -import { BlacklistTokenContractTest, Role } from '../e2e_blacklist_token_contract/blacklist_token_contract_test.js'; +import { BlacklistTokenContractTest, Role } from '../automine/token/blacklist_token_contract_test.js'; import { PIPELINING_SETUP_OPTS } from '../fixtures/fixtures.js'; import { type EndToEndContext, setup } from '../fixtures/utils.js'; import type { TestWallet } from '../test-wallet/test_wallet.js'; diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts deleted file mode 100644 index abf70734c12d..000000000000 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { ContractArtifact } from '@aztec/aztec.js/abi'; -import type { AztecAddress } from '@aztec/aztec.js/addresses'; -import { type ContractBase, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts'; -import { Fr } from '@aztec/aztec.js/fields'; -import type { PublicKeys } from '@aztec/aztec.js/keys'; -import { type Logger, createLogger } from '@aztec/aztec.js/log'; -import type { AztecNode } from '@aztec/aztec.js/node'; -import type { Wallet } from '@aztec/aztec.js/wallet'; -import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest'; -import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client'; - -import { type EndToEndContext, type SetupOptions, setup, teardown } from '../fixtures/setup.js'; -import type { TestWallet } from '../test-wallet/test_wallet.js'; - -export class DeployTest { - public context!: EndToEndContext; - public logger: Logger; - public wallet!: TestWallet; - public defaultAccountAddress!: AztecAddress; - public aztecNode!: AztecNode; - public aztecNodeAdmin!: AztecNodeAdmin; - - constructor(testName: string) { - this.logger = createLogger(`e2e:e2e_deploy_contract:${testName}`); - } - - async setup(opts: Partial = {}) { - this.logger.info('Setting up test environment'); - this.context = await setup(1, { - ...opts, - fundSponsoredFPC: true, - }); - this.aztecNode = this.context.aztecNodeService; - this.wallet = this.context.wallet; - this.aztecNodeAdmin = this.context.aztecNodeService; - this.defaultAccountAddress = this.context.accounts[0]; - return this; - } - - async teardown() { - await teardown(this.context); - } - - async registerContract( - wallet: Wallet, - contractArtifact: ContractArtifactClass, - opts: { - salt?: Fr; - publicKeys?: PublicKeys; - initArgs?: any[]; - constructorName?: string; - deployer?: AztecAddress; - } = {}, - ): Promise { - const { salt, publicKeys, initArgs, constructorName, deployer } = opts; - const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, { - constructorArgs: initArgs ?? [], - constructorArtifact: constructorName, - salt: salt ?? Fr.random(), - publicKeys, - deployer, - }); - await wallet.registerContract(instance, contractArtifact.artifact); - return contractArtifact.at(instance.address, wallet); - } -} - -export type StatefulContractCtorArgs = Parameters; - -export type ContractArtifactClass = { - at(address: AztecAddress, wallet: Wallet): T; - artifact: ContractArtifact; -}; diff --git a/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts b/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts deleted file mode 100644 index fb586da297fe..000000000000 --- a/yarn-project/end-to-end/src/e2e_nested_contract/nested_contract_test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { AztecAddress } from '@aztec/aztec.js/addresses'; -import { type Logger, createLogger } from '@aztec/aztec.js/log'; -import type { AztecNode } from '@aztec/aztec.js/node'; -import type { Wallet } from '@aztec/aztec.js/wallet'; -import { ChildContract } from '@aztec/noir-test-contracts.js/Child'; -import { ParentContract } from '@aztec/noir-test-contracts.js/Parent'; - -import { type EndToEndContext, type SetupOptions, setup, teardown as teardownSubsystems } from '../fixtures/setup.js'; - -export class NestedContractTest { - context!: EndToEndContext; - logger: Logger; - wallet!: Wallet; - defaultAccountAddress!: AztecAddress; - aztecNode!: AztecNode; - - parentContract!: ParentContract; - childContract!: ChildContract; - - constructor( - testName: string, - private numberOfAccounts = 1, - ) { - this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`); - } - - async setup(opts: Partial = {}) { - this.logger.info('Setting up fresh subsystems'); - this.context = await setup(this.numberOfAccounts, { - ...opts, - fundSponsoredFPC: true, - }); - this.wallet = this.context.wallet; - this.defaultAccountAddress = this.context.accounts[0]; - this.aztecNode = this.context.aztecNodeService; - } - - async teardown() { - await teardownSubsystems(this.context); - } - - async applyManual() { - this.logger.info('Deploying parent and child contracts'); - ({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({ - from: this.defaultAccountAddress, - })); - ({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({ - from: this.defaultAccountAddress, - })); - } -} diff --git a/yarn-project/end-to-end/src/e2e_snapshot_sync.test.ts b/yarn-project/end-to-end/src/single-node/sync/snapshot_sync.test.ts similarity index 98% rename from yarn-project/end-to-end/src/e2e_snapshot_sync.test.ts rename to yarn-project/end-to-end/src/single-node/sync/snapshot_sync.test.ts index c9dc8eb08464..1296d0c06bb8 100644 --- a/yarn-project/end-to-end/src/e2e_snapshot_sync.test.ts +++ b/yarn-project/end-to-end/src/single-node/sync/snapshot_sync.test.ts @@ -15,8 +15,8 @@ import { cp, mkdtemp, readFile, readdir, rm, writeFile } from 'fs/promises'; import { tmpdir } from 'os'; import { join } from 'path'; -import { PIPELINING_SETUP_OPTS } from './fixtures/fixtures.js'; -import { type EndToEndContext, setup } from './fixtures/utils.js'; +import { PIPELINING_SETUP_OPTS } from '../../fixtures/fixtures.js'; +import { type EndToEndContext, setup } from '../../fixtures/utils.js'; const L1_BLOCK_TIME_IN_S = process.env.L1_BLOCK_TIME ? parseInt(process.env.L1_BLOCK_TIME) : 8; const L2_TARGET_BLOCK_NUM = 3; diff --git a/yarn-project/protocol-contracts/src/tests/fixtures.ts b/yarn-project/protocol-contracts/src/tests/fixtures.ts index d71fc48ac162..670d3e76924f 100644 --- a/yarn-project/protocol-contracts/src/tests/fixtures.ts +++ b/yarn-project/protocol-contracts/src/tests/fixtures.ts @@ -2,13 +2,13 @@ import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; -// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1 +// Generated from end-to-end/src/automine/contracts/deploy/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1 export function getSampleContractClassPublishedEventPayload(): Buffer { const path = getPathToFixture('ContractClassPublishedEventData.hex'); return Buffer.from(readFileSync(path).toString(), 'hex'); } -// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1 +// Generated from end-to-end/src/automine/contracts/deploy/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1 export function getSampleContractInstancePublishedEventPayload(): Buffer { const path = getPathToFixture('ContractInstancePublishedEventData.hex'); return Buffer.from(readFileSync(path).toString(), 'hex'); diff --git a/yarn-project/update-snapshots.sh b/yarn-project/update-snapshots.sh index eb275769d2df..2acf915105a7 100755 --- a/yarn-project/update-snapshots.sh +++ b/yarn-project/update-snapshots.sh @@ -7,7 +7,7 @@ yarn build:fast export AZTEC_GENERATE_TEST_DATA=1 yarn workspace @aztec/end-to-end test integration_l1_publisher.test.ts -yarn workspace @aztec/end-to-end test e2e_nested_contract -t 'performs nested calls' +yarn workspace @aztec/end-to-end test automine/contracts/nested -t 'performs nested calls' # this test takes considerable resources to run since it fully proves blocks # only enable if needed