@aztec/end-to-end 5.0.0-rc.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -27
- package/dest/automine/automine_test_context.d.ts +85 -0
- package/dest/automine/automine_test_context.d.ts.map +1 -0
- package/dest/automine/automine_test_context.js +98 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
- package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
- package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +17 -24
- package/dest/automine/token/token_contract_test.d.ts +40 -0
- package/dest/automine/token/token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +22 -28
- package/dest/automine/token/token_test_helpers.d.ts +73 -0
- package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
- package/dest/automine/token/token_test_helpers.js +97 -0
- package/dest/bench/client_flows/benchmark.d.ts +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +3 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +16 -4
- package/dest/bench/utils.d.ts +1 -1
- package/dest/composed/ha/ha_full_setup.d.ts +77 -0
- package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
- package/dest/composed/ha/ha_full_setup.js +383 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.d.ts +10 -7
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +30 -11
- package/dest/fixtures/fixtures.d.ts +7 -5
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -4
- package/dest/fixtures/ha_setup.d.ts +3 -3
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +4 -1
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +32 -8
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +165 -160
- package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
- package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
- package/dest/fixtures/standard_contracts_genesis.js +25 -0
- package/dest/fixtures/timing.d.ts +42 -0
- package/dest/fixtures/timing.d.ts.map +1 -0
- package/dest/fixtures/timing.js +72 -0
- package/dest/fixtures/wait_helpers.d.ts +135 -0
- package/dest/fixtures/wait_helpers.d.ts.map +1 -0
- package/dest/fixtures/wait_helpers.js +154 -0
- package/dest/forward-compatibility/wallet_service.js +1 -1
- package/dest/multi-node/block-production/setup.d.ts +97 -0
- package/dest/multi-node/block-production/setup.d.ts.map +1 -0
- package/dest/multi-node/block-production/setup.js +158 -0
- package/dest/multi-node/governance/setup.d.ts +67 -0
- package/dest/multi-node/governance/setup.d.ts.map +1 -0
- package/dest/multi-node/governance/setup.js +126 -0
- package/dest/multi-node/multi_node_test_context.d.ts +212 -0
- package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
- package/dest/multi-node/multi_node_test_context.js +347 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/inactivity_setup.js +111 -0
- package/dest/multi-node/slashing/setup.d.ts +167 -0
- package/dest/multi-node/slashing/setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/setup.js +275 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +9 -1
- package/dest/p2p/p2p_network.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.js +26 -1
- package/dest/p2p/reqresp/utils.d.ts +19 -0
- package/dest/p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/reqresp/utils.js +4 -15
- package/dest/p2p/shared.d.ts +72 -0
- package/dest/p2p/shared.d.ts.map +1 -0
- package/dest/p2p/shared.js +212 -0
- package/dest/shared/cross_chain_test_harness.d.ts +3 -3
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +24 -16
- package/dest/shared/gas_portal_test_harness.d.ts +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +8 -5
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +12 -5
- package/dest/shared/timing_env.d.js +5 -0
- package/dest/shared/timing_env.js +158 -47
- package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.js +74 -26
- package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
- package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
- package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
- package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +9 -6
- package/dest/single-node/fees/fees_test.d.ts +95 -0
- package/dest/single-node/fees/fees_test.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/fees_test.js +121 -45
- package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
- package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
- package/dest/single-node/l1-reorgs/setup.js +57 -0
- package/dest/single-node/partial-proofs/setup.d.ts +5 -0
- package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
- package/dest/single-node/partial-proofs/setup.js +5 -0
- package/dest/single-node/proving/setup.d.ts +5 -0
- package/dest/single-node/proving/setup.d.ts.map +1 -0
- package/dest/single-node/proving/setup.js +5 -0
- package/dest/single-node/recovery/setup.d.ts +5 -0
- package/dest/single-node/recovery/setup.d.ts.map +1 -0
- package/dest/single-node/recovery/setup.js +5 -0
- package/dest/single-node/setup.d.ts +49 -0
- package/dest/single-node/setup.d.ts.map +1 -0
- package/dest/single-node/setup.js +56 -0
- package/dest/single-node/single_node_test_context.d.ts +373 -0
- package/dest/single-node/single_node_test_context.d.ts.map +1 -0
- package/dest/single-node/single_node_test_context.js +845 -0
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +13 -7
- package/dest/spartan/tx_metrics.d.ts +10 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +32 -0
- package/dest/test-wallet/test_wallet.d.ts +23 -4
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +20 -4
- package/dest/test-wallet/utils.d.ts +36 -1
- package/dest/test-wallet/utils.d.ts.map +1 -1
- package/dest/test-wallet/utils.js +64 -4
- package/dest/test-wallet/wallet_worker_script.js +5 -2
- package/dest/test-wallet/worker_wallet.d.ts +5 -5
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +2 -2
- package/dest/test-wallet/worker_wallet_schema.js +2 -1
- package/package.json +40 -40
- package/src/automine/README.md +60 -0
- package/src/automine/automine_test_context.ts +153 -0
- package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
- package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
- package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +19 -39
- package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -43
- package/src/automine/token/token_test_helpers.ts +138 -0
- package/src/bench/client_flows/benchmark.ts +3 -1
- package/src/bench/client_flows/client_flows_benchmark.ts +17 -4
- package/src/composed/ha/ha_full_setup.ts +466 -0
- package/src/fixtures/e2e_prover_test.ts +36 -20
- package/src/fixtures/fixtures.ts +6 -4
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +202 -161
- package/src/fixtures/standard_contracts_genesis.ts +28 -0
- package/src/fixtures/timing.ts +97 -0
- package/src/fixtures/wait_helpers.ts +333 -0
- package/src/forward-compatibility/wallet_service.ts +2 -2
- package/src/infra/README.md +12 -0
- package/src/multi-node/README.md +96 -0
- package/src/multi-node/block-production/setup.ts +272 -0
- package/src/multi-node/governance/setup.ts +172 -0
- package/src/multi-node/multi_node_test_context.ts +447 -0
- package/src/multi-node/slashing/inactivity_setup.ts +139 -0
- package/src/multi-node/slashing/setup.ts +433 -0
- package/src/p2p/README.md +78 -0
- package/src/{e2e_p2p → p2p}/p2p_network.ts +26 -0
- package/src/{e2e_p2p → p2p}/reqresp/utils.ts +5 -14
- package/src/p2p/shared.ts +329 -0
- package/src/shared/cross_chain_test_harness.ts +22 -13
- package/src/shared/gas_portal_test_harness.ts +13 -5
- package/src/shared/submit-transactions.ts +13 -5
- package/src/shared/timing_env.d.mts +39 -0
- package/src/shared/timing_env.mjs +152 -48
- package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
- package/src/single-node/README.md +66 -0
- package/src/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.ts +100 -38
- package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
- package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +11 -7
- package/src/{e2e_fees → single-node/fees}/fees_test.ts +132 -47
- package/src/single-node/l1-reorgs/setup.ts +93 -0
- package/src/single-node/partial-proofs/setup.ts +8 -0
- package/src/single-node/proving/setup.ts +15 -0
- package/src/single-node/recovery/setup.ts +8 -0
- package/src/single-node/setup.ts +63 -0
- package/src/single-node/single_node_test_context.ts +1054 -0
- package/src/spartan/setup_test_wallets.ts +19 -7
- package/src/spartan/tx_metrics.ts +26 -0
- package/src/test-wallet/test_wallet.ts +28 -6
- package/src/test-wallet/utils.ts +102 -5
- package/src/test-wallet/wallet_worker_script.ts +6 -3
- package/src/test-wallet/worker_wallet.ts +5 -9
- package/src/test-wallet/worker_wallet_schema.ts +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -59
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.js +0 -42
- package/dest/e2e_epochs/epochs_test.d.ts +0 -137
- package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
- package/dest/e2e_epochs/epochs_test.js +0 -485
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
- package/dest/e2e_fees/fees_test.d.ts +0 -89
- package/dest/e2e_fees/fees_test.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
- package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.js +0 -57
- package/dest/e2e_multi_validator/utils.d.ts +0 -12
- package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -22
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +0 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
- package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.d.ts +0 -100
- package/dest/e2e_p2p/shared.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.js +0 -257
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
- package/src/e2e_deploy_contract/deploy_test.ts +0 -73
- package/src/e2e_epochs/epochs_test.ts +0 -596
- package/src/e2e_l1_publisher/write_json.ts +0 -78
- package/src/e2e_nested_contract/nested_contract_test.ts +0 -51
- package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
- package/src/e2e_p2p/shared.ts +0 -391
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
- /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
- /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,47 +1,235 @@
|
|
|
1
|
-
# End
|
|
1
|
+
# End-to-end tests
|
|
2
2
|
|
|
3
|
-
This package
|
|
4
|
-
|
|
3
|
+
This package holds Aztec's end-to-end (e2e) tests: full-stack scenarios that spin up an Aztec node (or
|
|
4
|
+
several), a PXE, and an L1 (anvil) and exercise the system the way a real deployment would. It is the
|
|
5
|
+
integration layer above the per-package unit tests.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
> **Two audiences.** The top of this document is a quick orientation for humans. The
|
|
8
|
+
> [Reference for agents](#reference-for-agents) section at the bottom is the detailed, exhaustive
|
|
9
|
+
> version — read that when you are placing, moving, or wiring up a test.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
## Quick start
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
Run a single test (spawns its own in-process anvil):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn test:e2e src/automine/token/access_control.parallel.test.ts
|
|
17
|
+
yarn test:e2e src/single-node/block-building/block_building.test.ts -t 'rejects a private then private double-spend'
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Turn up logging with `LOG_LEVEL` (`verbose` is the useful default; `debug:sequencer,archiver` scopes it):
|
|
17
21
|
|
|
18
|
-
```
|
|
19
|
-
yarn test:
|
|
22
|
+
```bash
|
|
23
|
+
LOG_LEVEL=verbose yarn test:e2e src/single-node/proving/default_node.test.ts
|
|
20
24
|
```
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
Each run spawns anvil on port 8545, so two tests can only run side by side if each gets its own
|
|
27
|
+
`ANVIL_PORT` (p2p tests additionally bind fixed p2p ports and can never run concurrently — see
|
|
28
|
+
[`src/p2p/README.md`](src/p2p/README.md)). To shake flakiness out of a test,
|
|
29
|
+
`scripts/deflaker.sh yarn test:e2e <file>` reruns it up to 100 times and stops at the first failure
|
|
30
|
+
(output lands in `scripts/deflaker.log`).
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
Compose-based tests (those under `src/composed/`) need a running local network — see
|
|
33
|
+
[Compose / HA / web3signer tests](#compose--ha--web3signer-tests).
|
|
34
|
+
|
|
35
|
+
## Test categories
|
|
36
|
+
|
|
37
|
+
Tests are grouped by **node topology** — the shape of the network a test needs. The top-level folder is
|
|
38
|
+
the category; the second level names the behavior under test. Each category owns a base class that builds
|
|
39
|
+
its environment, so a test file only describes the scenario, not the wiring.
|
|
40
|
+
|
|
41
|
+
| Category | Topology | A test belongs here when… | README |
|
|
42
|
+
|---|---|---|---|
|
|
43
|
+
| [`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 |
|
|
44
|
+
| [`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 |
|
|
45
|
+
| [`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 |
|
|
46
|
+
| [`p2p/`](src/p2p/README.md) | Real libp2p transport between nodes. | the networking transport itself is under test (gossip, rediscovery, req/resp). | yes |
|
|
47
|
+
| [`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 |
|
|
48
|
+
|
|
49
|
+
A handful of tests live **outside** this package, next to the code they test — see
|
|
50
|
+
[Tests that live elsewhere](#tests-that-live-elsewhere). Other non-category test groups (`composed/`,
|
|
51
|
+
`guides/`, `bench/`) are described in the reference section.
|
|
52
|
+
|
|
53
|
+
## Where does my test go?
|
|
54
|
+
|
|
55
|
+
1. **Does it need real networking transport?** → `p2p/`.
|
|
56
|
+
2. **Does it need a validator committee (consensus/slashing/governance)?** → `multi-node/`.
|
|
57
|
+
3. **Does it assert on the production sequencer, proving, reorgs, fees, or cross-chain flows?** →
|
|
58
|
+
`single-node/`.
|
|
59
|
+
4. **Is it pure contract/protocol behavior that's happy with one-block-per-tx?** → `automine/` (the
|
|
60
|
+
default home for most contract tests).
|
|
61
|
+
5. **Is it really a unit/integration test of one package with no Aztec node?** → it probably belongs in
|
|
62
|
+
that package, not here (see [Tests that live elsewhere](#tests-that-live-elsewhere)).
|
|
63
|
+
|
|
64
|
+
When in doubt, prefer `automine/` for contract behavior and `single-node/` for anything that watches the
|
|
65
|
+
chain advance.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Reference for agents
|
|
70
|
+
|
|
71
|
+
This section is the detailed contract for adding, moving, and wiring tests. It assumes you've read the
|
|
72
|
+
overview above.
|
|
73
|
+
|
|
74
|
+
### Category base classes
|
|
75
|
+
|
|
76
|
+
Each category centralizes its environment in a base class. The hierarchy:
|
|
77
|
+
|
|
78
|
+
- `single-node/single_node_test_context.ts` → **`SingleNodeTestContext`**. Owns the environment
|
|
79
|
+
(in-process anvil + L1 deploy), node spawning (`createNonValidatorNode`, `createProverNode`), the
|
|
80
|
+
`ChainMonitor`, and the epoch/checkpoint/proof-window/reorg waiters.
|
|
81
|
+
- `multi-node/multi_node_test_context.ts` → **`MultiNodeTestContext extends SingleNodeTestContext`**.
|
|
82
|
+
Adds the N-validator topology over a mock-gossip bus, inheriting the base environment and waiters.
|
|
83
|
+
- `automine/automine_test_context.ts` → **`AutomineTestContext`**. A sibling of `SingleNodeTestContext`
|
|
84
|
+
(both wrap `fixtures/setup.ts:setup()`), but fixes the automine topology and makes `AUTOMINE_E2E_OPTS`
|
|
85
|
+
the default. Exposes `markProvenAndWarp`, `registerContract`, `applyManualParentChild`.
|
|
86
|
+
- `p2p/p2p_network.ts` → **`P2PNetworkTest`**. Real libp2p; node creation goes through
|
|
87
|
+
`fixtures/setup_p2p_test.ts`.
|
|
88
|
+
- `infra/` has no shared base — its tests target a network selected by `L1_CHAIN_ID` (local anvil in CI,
|
|
89
|
+
a public testnet with credentials).
|
|
90
|
+
|
|
91
|
+
All of the above ultimately wrap `fixtures/setup.ts:setup(numberOfAccounts, opts)`, the single entry point
|
|
92
|
+
that deploys L1 contracts, starts the node(s), and provisions a PXE and accounts.
|
|
93
|
+
|
|
94
|
+
### Setup factories
|
|
95
|
+
|
|
96
|
+
Categories expose thin factories over their base's static `setup`, named by what the test wants, so a test
|
|
97
|
+
calls the factory instead of spreading option presets:
|
|
98
|
+
|
|
99
|
+
- `single-node/setup.ts`: `setupWithProver` (fake in-process prover — the single-node default) and
|
|
100
|
+
`setupBlockProducer` (no prover; raises `aztecProofSubmissionEpochs` to `NO_REORG_SUBMISSION_EPOCHS`
|
|
101
|
+
(1024) so unproven blocks aren't pruned, and points the PXE at `syncChainTip: 'proposed'`).
|
|
102
|
+
- `automine` tests call `AutomineTestContext.setup({ numberOfAccounts })` directly.
|
|
25
103
|
|
|
26
|
-
|
|
104
|
+
### The harness pattern (domain setup on top of a category)
|
|
105
|
+
|
|
106
|
+
A test suite with bespoke domain setup does **not** fork `setup()`. It subclasses the category base and
|
|
107
|
+
overrides a `protected hydrateFromContext(context)` split out of `setup`, so it reuses the base's
|
|
108
|
+
rollup/epoch-cache/chain-monitor/waiter/teardown machinery while adding its own domain state. Examples:
|
|
109
|
+
|
|
110
|
+
- `single-node/prover/` → `FullProverTest` (real Barretenberg env) extends `SingleNodeTestContext`.
|
|
111
|
+
- `single-node/fees/` → `FeesTest`; `single-node/cross-chain/` → `CrossChainMessagingTest`.
|
|
112
|
+
- `automine/token/` → `TokenContractTest` and `BlacklistTokenContractTest` extend `AutomineTestContext`
|
|
113
|
+
and run their `TokenSimulator`/snapshot setup after `super.setup()`.
|
|
114
|
+
|
|
115
|
+
When two suites share behavior: if their public APIs are nearly identical, use inheritance; if behavior
|
|
116
|
+
overlaps but APIs differ, compose. Don't duplicate a category's environment wiring.
|
|
117
|
+
|
|
118
|
+
### The `.parallel` suffix
|
|
119
|
+
|
|
120
|
+
CI splits each `it` in a `.parallel.test.ts` file into its own docker job, running it in isolation via
|
|
121
|
+
`jest --testNamePattern` (the names come from `extract_test_names` in `bootstrap.sh`, which matches
|
|
122
|
+
`it`/`test` at **any** nesting depth, not just top level). When an `it` runs alone its enclosing
|
|
123
|
+
`beforeAll`/`beforeEach` hooks still run, but sibling `it`s do not. Rules:
|
|
124
|
+
|
|
125
|
+
- The `.parallel` suffix is for files whose `it`s are **independent**: every `it` must pass when run
|
|
126
|
+
entirely on its own. That holds only when all shared state is built in `beforeAll`/`beforeEach` and no
|
|
127
|
+
`it` reads or asserts on state produced by a sibling `it`.
|
|
128
|
+
- A file with sequential or stateful `it`s (progressive mutation across `it`s, a describe-scope variable
|
|
129
|
+
assigned in one `it` and read in another, a note/token created in an earlier `it` and used later) stays
|
|
130
|
+
a plain `.test.ts` **even if it has many top-level `it`s** — it runs as one ordered job. Adding
|
|
131
|
+
`.parallel` to such a file breaks CI, because each `it` then runs without its predecessors.
|
|
132
|
+
- A file with a single top-level `it` is a plain `.test.ts`.
|
|
133
|
+
- `it`/`test` names in a `.parallel` file must avoid regex/shell-special characters —
|
|
134
|
+
`"` `(` `)` `[` `]` `{` `}` `$` `\` and backtick. The split passes each name to
|
|
135
|
+
`run_test.sh ... "<name>"` as a shell-quoted `--testNamePattern` regex: an embedded `"` closes the
|
|
136
|
+
quote early and hard-fails the job, while regex metacharacters (`(` `)` `[` `]` `+` `*` `?` `|` `{` `}`)
|
|
137
|
+
silently match zero tests so the shard runs nothing and passes green — a coverage gap that hides the
|
|
138
|
+
test. Plain `.test.ts` files run as one job and are unaffected, so any name is fine there.
|
|
139
|
+
(`.` `!` `#` `-` `:` `,` are safe in `.parallel` names.)
|
|
140
|
+
- Each file has exactly one top-level `describe`, named to match its path
|
|
141
|
+
(e.g. `describe('automine/token/transfer', …)`).
|
|
142
|
+
|
|
143
|
+
### CI test discovery — `bootstrap.sh`
|
|
144
|
+
|
|
145
|
+
`end-to-end/bootstrap.sh` enumerates tests in two arrays, and a test must resolve through the relevant one
|
|
146
|
+
or it **won't run in CI**:
|
|
147
|
+
|
|
148
|
+
- `test_cmds` — the standard run. Covers each category with a recursive glob (e.g.
|
|
149
|
+
`src/automine/!(simulation)/**/*.test.ts`, `src/multi-node/**/*.test.ts`), so a new file or sub-folder
|
|
150
|
+
inside an existing category is picked up automatically; only a new top-level category needs its own glob
|
|
151
|
+
line. Tests with bespoke handling sit outside the globs: the `single-node/prover/` lanes at the top of
|
|
152
|
+
the function (real proofs and custom resources under `CI_FULL`, `FAKE_PROOFS=1` otherwise) and
|
|
153
|
+
`avm_simulator` (below).
|
|
154
|
+
- `compat_test_cmds` — the forward/legacy-compat run (a subset). This one enumerates **single-level leaf
|
|
155
|
+
globs** (e.g. `src/automine/token/*.test.ts`), so a new sub-folder whose tests should run against legacy
|
|
156
|
+
contract artifacts needs its own line here.
|
|
157
|
+
|
|
158
|
+
Bespoke handling to be aware of:
|
|
159
|
+
|
|
160
|
+
- **`avm_simulator`** (`automine/simulation/avm_simulator.test.ts`) has a dedicated line in `test_cmds`
|
|
161
|
+
that sets `DUMP_AVM_INPUTS_TO_DIR` (feeds the downstream `avm_check_circuit` job) and is therefore
|
|
162
|
+
excluded from the generic `simulation/` glob there (`!(avm_simulator)`). In `compat_test_cmds` it runs
|
|
163
|
+
as a regular test (no dump line), so it is **not** excluded there.
|
|
164
|
+
- **`kernelless_simulation`** is excluded from `compat_test_cmds` only.
|
|
165
|
+
|
|
166
|
+
After editing the arrays, confirm every `*.test.ts` resolves through exactly one line (no duplicate, no
|
|
167
|
+
omission — anything excluded via `!(...)` must be matched by its dedicated line). Per-test bash `TIMEOUT`
|
|
168
|
+
overrides live in the `case` block in `test_cmds` and must stay in sync with the test's `jest.setTimeout`.
|
|
169
|
+
|
|
170
|
+
### Flaky tests — `.test_patterns.yml`
|
|
171
|
+
|
|
172
|
+
Flaky/owner entries live in `.test_patterns.yml` at the **git root** (not in this package), keyed on the
|
|
173
|
+
test path. A bare entry flags the test as flaky whenever it fails; add `error_regex` to flag only on a
|
|
174
|
+
matching message; `skip: true` disables it. Blanket regex entries (e.g. `src/automine/.*\.test\.ts`) are
|
|
175
|
+
depth-agnostic and survive folder renames; path-specific entries must be updated when a file moves.
|
|
176
|
+
|
|
177
|
+
### Compose / HA / web3signer tests
|
|
178
|
+
|
|
179
|
+
`src/composed/` tests run against a **running local network** rather than an in-process stack, via
|
|
180
|
+
`scripts/run_test.sh` in different modes:
|
|
181
|
+
|
|
182
|
+
- `src/composed/*.test.ts` → `compose` mode (e.g. `e2e_persistence`, `uniswap_trade_on_l1_from_l2`,
|
|
183
|
+
`e2e_cheat_codes` — the compose variant, distinct from the relocated unit-style one).
|
|
184
|
+
- `src/composed/web3signer/*.test.ts` → `web3signer` mode (remote-signer scenarios).
|
|
185
|
+
- `src/composed/ha/*.test.ts` → `ha` mode (high-availability multi-process scenarios).
|
|
186
|
+
- `src/guides/*.test.ts` → tutorial/guide flows; `src/bench/` → benchmarks (see `bench_cmds`).
|
|
187
|
+
|
|
188
|
+
Run one compose test locally with `yarn test:compose <name>` (anvil + the test runner are spawned for
|
|
189
|
+
you), or `docker-compose up` for separate containers.
|
|
27
190
|
|
|
28
|
-
|
|
191
|
+
### Tests that live elsewhere
|
|
192
|
+
|
|
193
|
+
Tests with **no Aztec node** that exercise one package belong in that package, not here:
|
|
194
|
+
|
|
195
|
+
- L1 cheat-code behavior (`EthCheatCodes`/`RollupCheatCodes` against raw anvil) → `@aztec/ethereum`
|
|
196
|
+
(`ethereum/src/test/eth_cheat_codes.test.ts`).
|
|
197
|
+
- The `SequencerPublisher` integration test (anvil + L1 deploy, no node) → `@aztec/sequencer-client`
|
|
198
|
+
(`sequencer-client/src/publisher/`).
|
|
199
|
+
|
|
200
|
+
These run in their own package's test lane (both packages already run anvil-backed integration tests).
|
|
201
|
+
|
|
202
|
+
### Support directories (not test categories)
|
|
203
|
+
|
|
204
|
+
- `fixtures/` — the shared `setup()`, option presets (`fixtures.ts`), the named node-level waiters
|
|
205
|
+
(`wait_helpers.ts`), the span instrumentation (`timing.ts` — `testSpan`, zero-cost unless
|
|
206
|
+
`TEST_TIMING_FILE` is set), `l1_to_l2_messaging`, and common utils.
|
|
207
|
+
- `shared/` — shared test bodies, the `CrossChainTestHarness`, and `timing_env.mjs`, a **custom jest
|
|
208
|
+
`testEnvironment`** referenced from this package's `package.json`. `yarn prepare` / the package-json
|
|
209
|
+
check will try to revert it to the default — don't let it.
|
|
210
|
+
- `simulators/` — in-TS reference models (`TokenSimulator`, `LendingSimulator`) used to assert contract
|
|
211
|
+
behavior.
|
|
212
|
+
- `test-wallet/`, `bench/`, `spartan/`, `quality_of_service/`, `forward-compatibility/` — helpers,
|
|
213
|
+
benchmarks, and network/ops tests outside the topology categories.
|
|
214
|
+
|
|
215
|
+
### Running tests against legacy contract artifacts
|
|
29
216
|
|
|
30
217
|
To verify that contracts deployed from a previous release still work against the current stack, set
|
|
31
|
-
`CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` /
|
|
218
|
+
`CONTRACT_ARTIFACTS_VERSION` to a published version of `@aztec/noir-contracts.js` /
|
|
219
|
+
`@aztec/noir-test-contracts.js`:
|
|
32
220
|
|
|
33
|
-
```
|
|
34
|
-
CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/
|
|
221
|
+
```bash
|
|
222
|
+
CONTRACT_ARTIFACTS_VERSION=4.1.3 yarn test:e2e src/automine/token/access_control.parallel.test.ts
|
|
35
223
|
```
|
|
36
224
|
|
|
37
225
|
Only the JSON artifact files (`.../artifacts/*.json`) are redirected. The TypeScript wrapper classes
|
|
38
|
-
(e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` —
|
|
39
|
-
exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client,
|
|
40
|
-
legacy wrapper code still imports cleanly.
|
|
226
|
+
(e.g. `TokenContract`) continue to load from the current workspace and use the current `@aztec/aztec.js` —
|
|
227
|
+
so this exercises whether a deployed contract's ABI / bytecode / notes still work through the *new* client,
|
|
228
|
+
not whether the legacy wrapper code still imports cleanly.
|
|
41
229
|
|
|
42
|
-
The first run downloads the pinned packages into `.legacy-contracts/<version>/node_modules/` (cached across
|
|
43
|
-
startup banner and a per-redirect line are printed to stderr so you can confirm the legacy
|
|
44
|
-
loaded:
|
|
230
|
+
The first run downloads the pinned packages into `.legacy-contracts/<version>/node_modules/` (cached across
|
|
231
|
+
runs). A startup banner and a per-redirect line are printed to stderr so you can confirm the legacy
|
|
232
|
+
artifacts were actually loaded:
|
|
45
233
|
|
|
46
234
|
```
|
|
47
235
|
[legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=4.1.3
|
|
@@ -49,5 +237,5 @@ loaded:
|
|
|
49
237
|
[legacy-contracts][jest] redirected token_contract-Token.json -> /abs/.../.legacy-contracts/4.1.3/.../token_contract-Token.json
|
|
50
238
|
```
|
|
51
239
|
|
|
52
|
-
When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The
|
|
53
|
-
populated automatically on first use.
|
|
240
|
+
When `CONTRACT_ARTIFACTS_VERSION` is unset the test run is byte-identical to the default behaviour. The
|
|
241
|
+
cache is populated automatically on first use.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { type ContractBase } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import type { PublicKeys } from '@aztec/aztec.js/keys';
|
|
6
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
7
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
8
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import type { CheatCodes } from '@aztec/aztec/testing';
|
|
10
|
+
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
11
|
+
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
12
|
+
import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest';
|
|
13
|
+
import type { PXEConfig } from '@aztec/pxe/config';
|
|
14
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
15
|
+
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
16
|
+
import { type EndToEndContext, type SetupOptions } from '../fixtures/setup.js';
|
|
17
|
+
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
18
|
+
export type AutomineTestOpts = Partial<SetupOptions> & {
|
|
19
|
+
/** Number of accounts to create and deploy during setup. */
|
|
20
|
+
numberOfAccounts?: number;
|
|
21
|
+
/** Options forwarded to PXE creation. */
|
|
22
|
+
pxeOpts?: Partial<PXEConfig>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Base class for the automine-sequencer test topology: a single in-process node running the
|
|
26
|
+
* deterministic {@link AUTOMINE_E2E_OPTS} preset (one block per submitted tx, synchronous L1 publish,
|
|
27
|
+
* no committee, no prover, no validator client). Owns the environment (in-proc anvil in automine mode
|
|
28
|
+
* plus the L1 deploy) and exposes the handles every automine test uses (`wallet`, `aztecNode`,
|
|
29
|
+
* `cheatCodes`, `sequencer`, `accounts`, `logger`).
|
|
30
|
+
*
|
|
31
|
+
* The sibling of {@link SingleNodeTestContext}: both wrap the same underlying `fixtures/setup.ts:setup()`
|
|
32
|
+
* but fix opposite sequencer topologies. Making {@link AUTOMINE_E2E_OPTS} the base default removes the
|
|
33
|
+
* per-test-file spread every automine test would otherwise repeat.
|
|
34
|
+
*
|
|
35
|
+
* Domain harnesses (the token simulators) compose on top by extending this base and overriding
|
|
36
|
+
* {@link setup} to run their domain steps after `super.setup()`.
|
|
37
|
+
*/
|
|
38
|
+
export declare class AutomineTestContext {
|
|
39
|
+
context: EndToEndContext;
|
|
40
|
+
logger: Logger;
|
|
41
|
+
wallet: TestWallet;
|
|
42
|
+
aztecNode: AztecNode & AztecNodeDebug;
|
|
43
|
+
aztecNodeAdmin: AztecNodeAdmin;
|
|
44
|
+
cheatCodes: CheatCodes;
|
|
45
|
+
sequencer: SequencerClient;
|
|
46
|
+
accounts: AztecAddress[];
|
|
47
|
+
defaultAccountAddress: AztecAddress;
|
|
48
|
+
parentContract: ParentContract;
|
|
49
|
+
childContract: ChildContract;
|
|
50
|
+
static setup<T extends AutomineTestContext>(this: new () => T, opts?: AutomineTestOpts): Promise<T>;
|
|
51
|
+
setup(opts?: AutomineTestOpts): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Populates the context-derived handles from an already-built {@link EndToEndContext}. Split out of
|
|
54
|
+
* {@link setup} so domain harnesses that build the environment with their own bespoke `setup(...)`
|
|
55
|
+
* opts can still reuse the shared handle wiring.
|
|
56
|
+
*/
|
|
57
|
+
protected hydrateFromContext(context: EndToEndContext): Promise<void>;
|
|
58
|
+
teardown(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Marks the current pending checkpoints as proven, then warps the L2 clock forward by `seconds`.
|
|
61
|
+
*
|
|
62
|
+
* Under {@link AUTOMINE_E2E_OPTS} a long warp crosses many epochs with no proofs being submitted, so
|
|
63
|
+
* without a prior `markAsProven()` the rollup contract's pruning window resets the chain tip to genesis
|
|
64
|
+
* and the warp's own empty-checkpoint propose fails with `Rollup__InvalidArchive`. Marking proven before
|
|
65
|
+
* warping keeps the pending chain alive. Composes the existing `cheatCodes.rollup.markAsProven` and
|
|
66
|
+
* `warpL2TimeAtLeastBy` with that required ordering.
|
|
67
|
+
*/
|
|
68
|
+
markProvenAndWarp(seconds: number | bigint): Promise<void>;
|
|
69
|
+
/** Computes and registers a contract instance in the wallet without deploying it on-chain. */
|
|
70
|
+
registerContract<T extends ContractBase>(wallet: Wallet, contractArtifact: ContractArtifactClass<T>, opts?: {
|
|
71
|
+
salt?: Fr;
|
|
72
|
+
publicKeys?: PublicKeys;
|
|
73
|
+
initArgs?: any[];
|
|
74
|
+
constructorName?: string;
|
|
75
|
+
deployer?: AztecAddress;
|
|
76
|
+
}): Promise<T>;
|
|
77
|
+
/** Deploys a Parent and a Child contract from the default account for the nested-call tests. */
|
|
78
|
+
applyManualParentChild(): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export type StatefulContractCtorArgs = Parameters<StatefulTestContract['methods']['constructor']>;
|
|
81
|
+
export type ContractArtifactClass<T extends ContractBase> = {
|
|
82
|
+
at(address: AztecAddress, wallet: Wallet): T;
|
|
83
|
+
artifact: ContractArtifact;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b21pbmVfdGVzdF9jb250ZXh0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXV0b21pbmUvYXV0b21pbmVfdGVzdF9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDNUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxFQUFFLEtBQUssWUFBWSxFQUE4QyxNQUFNLDJCQUEyQixDQUFDO0FBQzFHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUF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,CAAC;AAElG,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,YAAY,IAAI;IAC1D,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;IAC7C,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { ChildContract } from '@aztec/noir-test-contracts.js/Child';
|
|
4
|
+
import { ParentContract } from '@aztec/noir-test-contracts.js/Parent';
|
|
5
|
+
import { AUTOMINE_E2E_OPTS } from '../fixtures/fixtures.js';
|
|
6
|
+
import { setup, teardown } from '../fixtures/setup.js';
|
|
7
|
+
/**
|
|
8
|
+
* Base class for the automine-sequencer test topology: a single in-process node running the
|
|
9
|
+
* deterministic {@link AUTOMINE_E2E_OPTS} preset (one block per submitted tx, synchronous L1 publish,
|
|
10
|
+
* no committee, no prover, no validator client). Owns the environment (in-proc anvil in automine mode
|
|
11
|
+
* plus the L1 deploy) and exposes the handles every automine test uses (`wallet`, `aztecNode`,
|
|
12
|
+
* `cheatCodes`, `sequencer`, `accounts`, `logger`).
|
|
13
|
+
*
|
|
14
|
+
* The sibling of {@link SingleNodeTestContext}: both wrap the same underlying `fixtures/setup.ts:setup()`
|
|
15
|
+
* but fix opposite sequencer topologies. Making {@link AUTOMINE_E2E_OPTS} the base default removes the
|
|
16
|
+
* per-test-file spread every automine test would otherwise repeat.
|
|
17
|
+
*
|
|
18
|
+
* Domain harnesses (the token simulators) compose on top by extending this base and overriding
|
|
19
|
+
* {@link setup} to run their domain steps after `super.setup()`.
|
|
20
|
+
*/ export class AutomineTestContext {
|
|
21
|
+
context;
|
|
22
|
+
logger;
|
|
23
|
+
wallet;
|
|
24
|
+
aztecNode;
|
|
25
|
+
aztecNodeAdmin;
|
|
26
|
+
cheatCodes;
|
|
27
|
+
sequencer;
|
|
28
|
+
accounts;
|
|
29
|
+
defaultAccountAddress;
|
|
30
|
+
parentContract;
|
|
31
|
+
childContract;
|
|
32
|
+
static async setup(opts = {}) {
|
|
33
|
+
const test = new this();
|
|
34
|
+
await test.setup(opts);
|
|
35
|
+
return test;
|
|
36
|
+
}
|
|
37
|
+
async setup(opts = {}) {
|
|
38
|
+
const { numberOfAccounts = 1, pxeOpts, ...setupOpts } = opts;
|
|
39
|
+
const context = await setup(numberOfAccounts, {
|
|
40
|
+
...AUTOMINE_E2E_OPTS,
|
|
41
|
+
fundSponsoredFPC: true,
|
|
42
|
+
...setupOpts
|
|
43
|
+
}, pxeOpts);
|
|
44
|
+
await this.hydrateFromContext(context);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Populates the context-derived handles from an already-built {@link EndToEndContext}. Split out of
|
|
48
|
+
* {@link setup} so domain harnesses that build the environment with their own bespoke `setup(...)`
|
|
49
|
+
* opts can still reuse the shared handle wiring.
|
|
50
|
+
*/ hydrateFromContext(context) {
|
|
51
|
+
this.context = context;
|
|
52
|
+
this.logger = context.logger;
|
|
53
|
+
this.wallet = context.wallet;
|
|
54
|
+
this.aztecNode = context.aztecNodeService;
|
|
55
|
+
this.aztecNodeAdmin = context.aztecNodeService;
|
|
56
|
+
this.cheatCodes = context.cheatCodes;
|
|
57
|
+
this.sequencer = context.sequencer;
|
|
58
|
+
this.accounts = context.accounts;
|
|
59
|
+
this.defaultAccountAddress = context.accounts[0];
|
|
60
|
+
return Promise.resolve();
|
|
61
|
+
}
|
|
62
|
+
async teardown() {
|
|
63
|
+
await teardown(this.context);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Marks the current pending checkpoints as proven, then warps the L2 clock forward by `seconds`.
|
|
67
|
+
*
|
|
68
|
+
* Under {@link AUTOMINE_E2E_OPTS} a long warp crosses many epochs with no proofs being submitted, so
|
|
69
|
+
* without a prior `markAsProven()` the rollup contract's pruning window resets the chain tip to genesis
|
|
70
|
+
* and the warp's own empty-checkpoint propose fails with `Rollup__InvalidArchive`. Marking proven before
|
|
71
|
+
* warping keeps the pending chain alive. Composes the existing `cheatCodes.rollup.markAsProven` and
|
|
72
|
+
* `warpL2TimeAtLeastBy` with that required ordering.
|
|
73
|
+
*/ async markProvenAndWarp(seconds) {
|
|
74
|
+
await this.cheatCodes.rollup.markAsProven();
|
|
75
|
+
await this.cheatCodes.warpL2TimeAtLeastBy(this.aztecNode, seconds);
|
|
76
|
+
}
|
|
77
|
+
/** Computes and registers a contract instance in the wallet without deploying it on-chain. */ async registerContract(wallet, contractArtifact, opts = {}) {
|
|
78
|
+
const { salt, publicKeys, initArgs, constructorName, deployer } = opts;
|
|
79
|
+
const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, {
|
|
80
|
+
constructorArgs: initArgs ?? [],
|
|
81
|
+
constructorArtifact: constructorName,
|
|
82
|
+
salt: salt ?? Fr.random(),
|
|
83
|
+
publicKeys,
|
|
84
|
+
deployer
|
|
85
|
+
});
|
|
86
|
+
await wallet.registerContract(instance, contractArtifact.artifact);
|
|
87
|
+
return contractArtifact.at(instance.address, wallet);
|
|
88
|
+
}
|
|
89
|
+
/** Deploys a Parent and a Child contract from the default account for the nested-call tests. */ async applyManualParentChild() {
|
|
90
|
+
this.logger.info('Deploying parent and child contracts');
|
|
91
|
+
({ contract: this.parentContract } = await ParentContract.deploy(this.wallet).send({
|
|
92
|
+
from: this.defaultAccountAddress
|
|
93
|
+
}));
|
|
94
|
+
({ contract: this.childContract } = await ChildContract.deploy(this.wallet).send({
|
|
95
|
+
from: this.defaultAccountAddress
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZV9wcm9vZl9mZXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXV0b21pbmUvY29udHJhY3RzL2ZpeHR1cmVzL3N0b3JhZ2VfcHJvb2ZfZmV0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage_proof_fetcher.d.ts","sourceRoot":"","sources":["../../../../src/automine/contracts/fixtures/storage_proof_fetcher.ts"],"names":[],"mappings":""}
|
|
@@ -15,4 +15,4 @@ export type StorageProofArgs = {
|
|
|
15
15
|
export declare function loadStorageProofArgs(): StorageProofArgs;
|
|
16
16
|
/** Builds all the capsules the StorageProofTest contract expects during private execution. */
|
|
17
17
|
export declare function buildStorageProofCapsules(contractAddress: AztecAddress): Promise<Capsule[]>;
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZV9wcm9vZl9maXh0dXJlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXV0b21pbmUvY29udHJhY3RzL2ZpeHR1cmVzL3N0b3JhZ2VfcHJvb2ZfZml4dHVyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUc5RCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDM0QsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBd0YzQyxnRkFBZ0Y7QUFDaEYsTUFBTSxNQUFNLGdCQUFnQixHQUFHO0lBQzdCLFVBQVUsRUFBRSxVQUFVLENBQUM7SUFDdkIsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ2xCLFlBQVksRUFBRTtRQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsQ0FBQztRQUFDLFlBQVksRUFBRSxNQUFNLENBQUE7S0FBRSxDQUFDO0lBQ3hELElBQUksRUFBRSxNQUFNLEVBQUUsQ0FBQztDQUNoQixDQUFDO0FBRUYsK0VBQStFO0FBQy9FLHdCQUFnQixvQkFBb0IsSUFBSSxnQkFBZ0IsQ0FhdkQ7QUFFRCw4RkFBOEY7QUFDOUYsd0JBQXNCLHlCQUF5QixDQUFDLGVBQWUsRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDLENBdURqRyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage_proof_fixture.d.ts","sourceRoot":"","sources":["../../../../src/automine/contracts/fixtures/storage_proof_fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAwF3C,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,oBAAoB,IAAI,gBAAgB,CAavD;AAED,8FAA8F;AAC9F,wBAAsB,yBAAyB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAuDjG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AztecAddress, type CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type SchnorrSignature } from '@aztec/foundation/crypto/schnorr';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
5
|
+
import type { CustomRequest } from '@aztec/pxe/config';
|
|
6
|
+
import { type PublicKeys } from '@aztec/stdlib/keys';
|
|
7
|
+
/**
|
|
8
|
+
* The decoded payload of the registry's interactive-handshake signature request. Note it never carries the sender,
|
|
9
|
+
* so the recipient authorizes the handshake without learning who initiated it.
|
|
10
|
+
*/
|
|
11
|
+
export type InteractiveHandshakeRequest = {
|
|
12
|
+
/** The account whose authorization is being requested. */
|
|
13
|
+
recipient: AztecAddress;
|
|
14
|
+
chainId: Fr;
|
|
15
|
+
version: Fr;
|
|
16
|
+
/** The x-coordinate of the handshake's ephemeral public key (its y-coordinate is positive by construction). */
|
|
17
|
+
ephPkX: Fr;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The recipient's signed authorization for an interactive handshake. Mirrors the registry contract's
|
|
21
|
+
* `RecipientSignature` struct field for field.
|
|
22
|
+
*/
|
|
23
|
+
export type RecipientSignature = {
|
|
24
|
+
/** The recipient's master public keys, bound in-circuit to the recipient's address via `partialAddress`. */
|
|
25
|
+
publicKeys: PublicKeys;
|
|
26
|
+
partialAddress: Fr;
|
|
27
|
+
/** The x-coordinate of the recipient's master message-signing public key. */
|
|
28
|
+
mspkX: Fr;
|
|
29
|
+
/** Whether that key's y-coordinate is positive, so the circuit can reconstruct the point from `mspkX`. */
|
|
30
|
+
mspkYIsPositive: boolean;
|
|
31
|
+
/** The schnorr signature over the handshake message. */
|
|
32
|
+
signature: SchnorrSignature;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Parses and validates the registry's interactive-handshake signature request.
|
|
36
|
+
*
|
|
37
|
+
* @throws If the request kind is not {@link INTERACTIVE_HANDSHAKE_REQUEST_KIND}, the issuing contract is not the
|
|
38
|
+
* standard HandshakeRegistry, or the payload does not have the expected shape.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseInteractiveHandshakeRequest(request: CustomRequest): InteractiveHandshakeRequest;
|
|
41
|
+
/**
|
|
42
|
+
* Produces the recipient's signed authorization for an interactive handshake, signing with the master
|
|
43
|
+
* message-signing secret key.
|
|
44
|
+
*/
|
|
45
|
+
export declare function signInteractiveHandshake(request: InteractiveHandshakeRequest, completeAddress: CompleteAddress, masterMessageSigningSecretKey: GrumpkinScalar): Promise<RecipientSignature>;
|
|
46
|
+
/** Serializes a {@link RecipientSignature} to the field layout the registry's in-circuit deserialization expects. */
|
|
47
|
+
export declare function recipientSignatureToFields(recipientSignature: RecipientSignature): Fr[];
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJhY3RpdmVfaGFuZHNoYWtlX3Jlc3BvbmRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2F1dG9taW5lL2RlbGl2ZXJ5L2ludGVyYWN0aXZlX2hhbmRzaGFrZV9yZXNwb25kZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxLQUFLLGVBQWUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRy9FLE9BQU8sRUFBVyxLQUFLLGdCQUFnQixFQUFFLE1BQU0sa0NBQWtDLENBQUM7QUFDbEYsT0FBTyxFQUFNLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3hELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBS3ZELE9BQU8sRUFBRSxLQUFLLFVBQVUsRUFBZ0MsTUFBTSxvQkFBb0IsQ0FBQztBQUVuRjs7O0dBR0c7QUFDSCxNQUFNLE1BQU0sMkJBQTJCLEdBQUc7SUFDeEMsMERBQTBEO0lBQzFELFNBQVMsRUFBRSxZQUFZLENBQUM7SUFDeEIsT0FBTyxFQUFFLEVBQUUsQ0FBQztJQUNaLE9BQU8sRUFBRSxFQUFFLENBQUM7SUFDWiwrR0FBK0c7SUFDL0csTUFBTSxFQUFFLEVBQUUsQ0FBQztDQUNaLENBQUM7QUFFRjs7O0dBR0c7QUFDSCxNQUFNLE1BQU0sa0JBQWtCLEdBQUc7SUFDL0IsNEdBQTRHO0lBQzVHLFVBQVUsRUFBRSxVQUFVLENBQUM7SUFDdkIsY0FBYyxFQUFFLEVBQUUsQ0FBQztJQUNuQiw2RUFBNkU7SUFDN0UsS0FBSyxFQUFFLEVBQUUsQ0FBQztJQUNWLDBHQUEwRztJQUMxRyxlQUFlLEVBQUUsT0FBTyxDQUFDO0lBQ3pCLHdEQUF3RDtJQUN4RCxTQUFTLEVBQUUsZ0JBQWdCLENBQUM7Q0FDN0IsQ0FBQztBQUVGOzs7OztHQUtHO0FBQ0gsd0JBQWdCLGdDQUFnQyxDQUFDLE9BQU8sRUFBRSxhQUFhLEdBQUcsMkJBQTJCLENBZXBHO0FBRUQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsMkJBQTJCLEVBQ3BDLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLDZCQUE2QixFQUFFLGNBQWMsR0FDNUMsT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBbUI3QjtBQUVELHFIQUFxSDtBQUNySCx3QkFBZ0IsMEJBQTBCLENBQUMsa0JBQWtCLEVBQUUsa0JBQWtCLEdBQUcsRUFBRSxFQUFFLENBYXZGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive_handshake_responder.d.ts","sourceRoot":"","sources":["../../../src/automine/delivery/interactive_handshake_responder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe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|
|
3
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
4
|
+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
5
|
+
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import { INTERACTIVE_HANDSHAKE_REQUEST_KIND, STANDARD_HANDSHAKE_REGISTRY_ADDRESS } from '@aztec/standard-contracts/handshake-registry/constants';
|
|
7
|
+
import { derivePublicKeyFromSecretKey } from '@aztec/stdlib/keys';
|
|
8
|
+
/**
|
|
9
|
+
* Parses and validates the registry's interactive-handshake signature request.
|
|
10
|
+
*
|
|
11
|
+
* @throws If the request kind is not {@link INTERACTIVE_HANDSHAKE_REQUEST_KIND}, the issuing contract is not the
|
|
12
|
+
* standard HandshakeRegistry, or the payload does not have the expected shape.
|
|
13
|
+
*/ export function parseInteractiveHandshakeRequest(request) {
|
|
14
|
+
if (!request.kind.equals(INTERACTIVE_HANDSHAKE_REQUEST_KIND)) {
|
|
15
|
+
throw new Error(`Not an interactive-handshake signature request: unexpected kind ${request.kind}`);
|
|
16
|
+
}
|
|
17
|
+
if (!request.contractAddress.equals(STANDARD_HANDSHAKE_REGISTRY_ADDRESS)) {
|
|
18
|
+
throw new Error(`Interactive-handshake signature request issued by ${request.contractAddress}, expected the standard HandshakeRegistry at ${STANDARD_HANDSHAKE_REGISTRY_ADDRESS}`);
|
|
19
|
+
}
|
|
20
|
+
if (request.payload.length !== 4) {
|
|
21
|
+
throw new Error(`Interactive-handshake signature request payload has ${request.payload.length} fields, expected 4`);
|
|
22
|
+
}
|
|
23
|
+
const [recipient, chainId, version, ephPkX] = request.payload;
|
|
24
|
+
return {
|
|
25
|
+
recipient: new AztecAddress(recipient),
|
|
26
|
+
chainId,
|
|
27
|
+
version,
|
|
28
|
+
ephPkX
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Produces the recipient's signed authorization for an interactive handshake, signing with the master
|
|
33
|
+
* message-signing secret key.
|
|
34
|
+
*/ export async function signInteractiveHandshake(request, completeAddress, masterMessageSigningSecretKey) {
|
|
35
|
+
const mspk = await derivePublicKeyFromSecretKey(masterMessageSigningSecretKey);
|
|
36
|
+
const [mspkX, mspkYIsPositive] = mspk.toXAndSign();
|
|
37
|
+
const message = await computeInteractiveHandshakeSignatureMessage({
|
|
38
|
+
chainId: request.chainId,
|
|
39
|
+
version: request.version,
|
|
40
|
+
registry: STANDARD_HANDSHAKE_REGISTRY_ADDRESS,
|
|
41
|
+
ephPkX: request.ephPkX
|
|
42
|
+
});
|
|
43
|
+
const signature = await new Schnorr().constructSignature(message, masterMessageSigningSecretKey);
|
|
44
|
+
return {
|
|
45
|
+
publicKeys: completeAddress.publicKeys,
|
|
46
|
+
partialAddress: completeAddress.partialAddress,
|
|
47
|
+
mspkX,
|
|
48
|
+
mspkYIsPositive,
|
|
49
|
+
signature
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Serializes a {@link RecipientSignature} to the field layout the registry's in-circuit deserialization expects. */ export function recipientSignatureToFields(recipientSignature) {
|
|
53
|
+
const s = Fq.fromBuffer(recipientSignature.signature.s);
|
|
54
|
+
const e = Fq.fromBuffer(recipientSignature.signature.e);
|
|
55
|
+
return [
|
|
56
|
+
...recipientSignature.publicKeys.toFields(),
|
|
57
|
+
recipientSignature.partialAddress,
|
|
58
|
+
recipientSignature.mspkX,
|
|
59
|
+
new Fr(recipientSignature.mspkYIsPositive),
|
|
60
|
+
s.lo,
|
|
61
|
+
s.hi,
|
|
62
|
+
e.lo,
|
|
63
|
+
e.hi
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The message an interactive-handshake authorization signs: the handshake's ephemeral key and chain context under
|
|
68
|
+
* `DomainSeparator.INTERACTIVE_HANDSHAKE_SIGNATURE`, exactly as the registry recomputes it in-circuit.
|
|
69
|
+
*/ function computeInteractiveHandshakeSignatureMessage(args) {
|
|
70
|
+
return poseidon2HashWithSeparator([
|
|
71
|
+
args.chainId,
|
|
72
|
+
args.version,
|
|
73
|
+
args.registry,
|
|
74
|
+
args.ephPkX
|
|
75
|
+
], DomainSeparator.INTERACTIVE_HANDSHAKE_SIGNATURE);
|
|
76
|
+
}
|