From 5a319e472c995a67bcb38cc6b7956ef1dc2e4112 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 17 Oct 2023 14:59:56 +0000 Subject: [PATCH 1/6] test: run all e2e tests against sandbox --- .circleci/config.yml | 27 +++++-------------- .../scripts/docker-compose-e2e-sandbox.yml | 2 +- yarn-project/canary/scripts/run_tests | 4 --- ...browser.yml => docker-compose-browser.yml} | 0 ...dbox.yml => docker-compose-no-sandbox.yml} | 18 +++---------- .../end-to-end/scripts/docker-compose.yml | 19 ++++++++++--- 6 files changed, 27 insertions(+), 43 deletions(-) rename yarn-project/end-to-end/scripts/{docker-compose-e2e-sandbox-browser.yml => docker-compose-browser.yml} (100%) rename yarn-project/end-to-end/scripts/{docker-compose-e2e-sandbox.yml => docker-compose-no-sandbox.yml} (81%) diff --git a/.circleci/config.yml b/.circleci/config.yml index ff3c13631a6..c93dbfd1b27 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -639,7 +639,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local e2e_sandbox_example.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local e2e_sandbox_example.test.ts environment: { DEBUG: "aztec:*" } e2e-block-building: @@ -831,7 +831,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local e2e_aztec_js_browser.test.ts ./scripts/docker-compose-e2e-sandbox-browser.yml + command: cond_run_script end-to-end ./scripts/run_tests_local e2e_aztec_js_browser.test.ts ./scripts/docker-compose-browser.yml environment: { DEBUG: "aztec:*" } e2e-card-game: @@ -855,7 +855,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local pxe_sandbox.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local pxe_sandbox.test.ts environment: { DEBUG: "aztec:*" } cli-docs-sandbox: @@ -867,7 +867,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local cli_docs_sandbox.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local cli_docs_sandbox.test.ts environment: { DEBUG: "aztec:*" } guides-writing-an-account-contract: @@ -891,7 +891,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local guides/dapp_testing.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local guides/dapp_testing.test.ts environment: { DEBUG: "aztec:*" } guides-sample-dapp: @@ -903,7 +903,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local sample-dapp ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local sample-dapp environment: { DEBUG: "aztec:*" } guides-up-quick-start: @@ -915,20 +915,9 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local guides/up_quick_start.test.ts ./scripts/docker-compose-e2e-sandbox.yml + command: cond_run_script end-to-end ./scripts/run_tests_local guides/up_quick_start.test.ts environment: { DEBUG: "aztec:*" } - e2e-canary-test: - machine: - image: ubuntu-2204:2023.07.2 - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: "Test" - command: cond_run_script canary-build ./scripts/run_tests uniswap_trade_on_l1_from_l2.test.ts canary-build ./scripts/docker-compose-e2e-sandbox.yml - bench-publish-rollup: machine: image: ubuntu-2204:2023.07.2 @@ -1339,7 +1328,6 @@ workflows: - integration-l1-publisher: *e2e_test - integration-archiver-l1-to-l2: *e2e_test - e2e-p2p: *e2e_test - - e2e-canary-test: *e2e_test - e2e-browser-sandbox: *e2e_test - e2e-card-game: *e2e_test - pxe-sandbox: *e2e_test @@ -1375,7 +1363,6 @@ workflows: - integration-archiver-l1-to-l2 - e2e-p2p - e2e-browser-sandbox - - e2e-canary-test - e2e-card-game - pxe-sandbox - cli-docs-sandbox diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml index e9d8f75c5b3..1e412506f61 100644 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml @@ -13,7 +13,7 @@ services: - '8545:8545' sandbox: - image: aztecprotocol/sandbox:latest + image: aztecprotocol/aztec-sandbox:canary environment: DEBUG: 'aztec:*' ETHEREUM_HOST: http://fork:8545 diff --git a/yarn-project/canary/scripts/run_tests b/yarn-project/canary/scripts/run_tests index 5ed4d4609c1..f43ad280e61 100755 --- a/yarn-project/canary/scripts/run_tests +++ b/yarn-project/canary/scripts/run_tests @@ -22,9 +22,5 @@ IMAGE_URI=$(calculate_image_uri $IMAGE) retry docker pull $IMAGE_URI retry docker tag $IMAGE_URI aztecprotocol/canary:latest -SANDBOX_IMAGE_URI=$(calculate_image_uri aztec-sandbox) -retry docker pull $SANDBOX_IMAGE_URI -retry docker tag $SANDBOX_IMAGE_URI aztecprotocol/sandbox:latest - docker-compose -f $COMPOSE_FILE rm -f docker-compose -f $COMPOSE_FILE up --exit-code-from canary diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-browser.yml similarity index 100% rename from yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml rename to yarn-project/end-to-end/scripts/docker-compose-browser.yml diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/end-to-end/scripts/docker-compose-no-sandbox.yml similarity index 81% rename from yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml rename to yarn-project/end-to-end/scripts/docker-compose-no-sandbox.yml index b357f9bef83..bd2020709e5 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-no-sandbox.yml @@ -12,10 +12,11 @@ services: ports: - '8545:8545' - sandbox: - image: aztecprotocol/aztec-sandbox:latest + end-to-end: + image: aztecprotocol/end-to-end:latest environment: - DEBUG: 'aztec:*' + BENCHMARK: true + DEBUG: ${DEBUG:-'aztec:*'} ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 ARCHIVER_POLLING_INTERVAL_MS: 50 @@ -24,17 +25,6 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - ports: - - '8080:8080' - - end-to-end: - image: aztecprotocol/end-to-end:latest - environment: - BENCHMARK: true - DEBUG: ${DEBUG:-'aztec:*'} - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - PXE_URL: http://sandbox:8080 command: ${TEST:-./src/e2e_deploy_contract.test.ts} volumes: - ../log:/usr/src/yarn-project/end-to-end/log:rw diff --git a/yarn-project/end-to-end/scripts/docker-compose.yml b/yarn-project/end-to-end/scripts/docker-compose.yml index bd2020709e5..ed5880dad89 100644 --- a/yarn-project/end-to-end/scripts/docker-compose.yml +++ b/yarn-project/end-to-end/scripts/docker-compose.yml @@ -12,11 +12,10 @@ services: ports: - '8545:8545' - end-to-end: - image: aztecprotocol/end-to-end:latest + sandbox: + image: aztecprotocol/aztec-sandbox:latest environment: - BENCHMARK: true - DEBUG: ${DEBUG:-'aztec:*'} + DEBUG: 'aztec:*' ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 ARCHIVER_POLLING_INTERVAL_MS: 50 @@ -25,6 +24,18 @@ services: WS_BLOCK_CHECK_INTERVAL_MS: 50 PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 + ports: + - '8080:8080' + + end-to-end: + image: aztecprotocol/end-to-end:latest + environment: + BENCHMARK: true + LOG_LEVL: 'debug' + DEBUG: ${DEBUG:-'aztec:*'} + ETHEREUM_HOST: http://fork:8545 + CHAIN_ID: 31337 + PXE_URL: http://sandbox:8080 command: ${TEST:-./src/e2e_deploy_contract.test.ts} volumes: - ../log:/usr/src/yarn-project/end-to-end/log:rw From 4435d2e1c2a59f1c1523e42a34601105b20a4459 Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 17 Oct 2023 15:33:50 +0000 Subject: [PATCH 2/6] fix cli test --- yarn-project/end-to-end/src/e2e_cli.test.ts | 11 ++--------- .../src/json-rpc/server/json_rpc_server.test.ts | 2 +- .../foundation/src/json-rpc/server/json_rpc_server.ts | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 1f24698ce1e..c8a22fcb7da 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,15 +1,11 @@ -import { startHttpRpcServer } from '@aztec/aztec-sandbox'; import { PXE, createDebugLogger } from '@aztec/aztec.js'; -import { createPXERpcServer } from '@aztec/pxe'; import { cliTestSuite } from './canary/cli.js'; import { setup as e2eSetup } from './fixtures/utils.js'; -const HTTP_PORT = 9009; -const RPC_URL = `http://localhost:${HTTP_PORT}`; +const { PXE_URL } = process.env; const debug = createDebugLogger('aztec:e2e_cli'); -let http: ReturnType; let pxe: PXE; let teardown: () => Promise; @@ -17,14 +13,11 @@ const testSetup = async () => { const context = await e2eSetup(2); debug(`Environment set up`); ({ pxe, teardown } = context); - http = startHttpRpcServer(pxe, createPXERpcServer, HTTP_PORT); - debug(`HTTP RPC server started in port ${HTTP_PORT}`); return pxe; }; const testCleanup = async () => { - http.close(); await teardown(); }; -cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), RPC_URL); +cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), PXE_URL); diff --git a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.test.ts b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.test.ts index e8e4d2edc45..7c2d2c856cf 100644 --- a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.test.ts +++ b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.test.ts @@ -44,7 +44,7 @@ test('invalid method', async () => { }); expect(response.status).toBe(400); expect(response.body).toEqual({ - error: { code: -32601, message: 'Method not found' }, + error: { code: -32601, message: 'Method not found: invalid' }, id: 42, jsonrpc: '2.0', }); diff --git a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts index 4302a42b657..722f0c925f8 100644 --- a/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts +++ b/yarn-project/foundation/src/json-rpc/server/json_rpc_server.ts @@ -145,7 +145,7 @@ export class JsonRpcServer { id, error: { code: -32601, - message: 'Method not found', + message: `Method not found: ${method}`, }, }; } else { From 291d835a4a0aacea06073e50e67dac13df08c3bb Mon Sep 17 00:00:00 2001 From: spypsy Date: Tue, 17 Oct 2023 15:42:18 +0000 Subject: [PATCH 3/6] no sandbox for benchmark tests --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c93dbfd1b27..11370591dcf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -927,7 +927,7 @@ jobs: - *setup_env - run: name: "Benchmark" - command: cond_run_script end-to-end ./scripts/run_tests_local benchmarks/bench_publish_rollup.test.ts + command: cond_run_script end-to-end ./scripts/run_tests_local benchmarks/bench_publish_rollup.test.ts ./scripts/docker-compose-no-sandbox.yml environment: DEBUG: "aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees" @@ -940,7 +940,7 @@ jobs: - *setup_env - run: name: "Benchmark" - command: cond_run_script end-to-end ./scripts/run_tests_local benchmarks/bench_process_history.test.ts + command: cond_run_script end-to-end ./scripts/run_tests_local benchmarks/bench_process_history.test.ts ./scripts/docker-compose-no-sandbox.yml environment: DEBUG: "aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees" From 347ee2fb7be525734ee597a419bcfb3bbdbdc72e Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 18 Oct 2023 17:00:07 +0000 Subject: [PATCH 4/6] fix remaining tests --- .circleci/config.yml | 2 +- yarn-project/end-to-end/src/e2e_card_game.test.ts | 4 ++-- .../src/e2e_multiple_accounts_1_enc_key.test.ts | 9 ++++++++- .../end-to-end/src/integration_archiver_l1_to_l2.test.ts | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 11370591dcf..f3fc08f7775 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -819,7 +819,7 @@ jobs: - *setup_env - run: name: "Test" - command: cond_run_script end-to-end ./scripts/run_tests_local e2e_p2p_network.test.ts + command: cond_run_script end-to-end ./scripts/run_tests_local e2e_p2p_network.test.ts ./scripts/docker-compose-no-sandbox.yml environment: { DEBUG: "aztec:*" } e2e-browser-sandbox: diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/e2e_card_game.test.ts index 5fdb0a4e1ee..2632ef1a648 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/e2e_card_game.test.ts @@ -1,4 +1,4 @@ -import { AccountWallet, AztecAddress, Wallet, deployInitialSandboxAccounts } from '@aztec/aztec.js'; +import { AccountWallet, AztecAddress, Wallet, getSandboxAccountsWallets } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { CardGameContract } from '@aztec/noir-contracts/types'; import { PXE } from '@aztec/types'; @@ -65,7 +65,7 @@ describe('e2e_card_game', () => { // Card stats are derived from the users' private keys, so to get consistent values, we set up the // initial sandbox accounts that always use the same private keys, instead of random ones. ({ pxe, logger, teardown } = await setup(0)); - wallets = await Promise.all((await deployInitialSandboxAccounts(pxe)).map(a => a.account.getWallet())); + wallets = await getSandboxAccountsWallets(pxe); [firstPlayerWallet, secondPlayerWallet, thirdPlayerWallet] = wallets; [firstPlayer, secondPlayer, thirdPlayer] = wallets.map(a => a.getAddress()); await deployContract(); diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 69200cf54a1..9e8f9d1b139 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -4,6 +4,7 @@ import { Wallet, computeMessageSecretHash, generatePublicKey, + getSandboxAccountsWallets, getSchnorrAccount, } from '@aztec/aztec.js'; import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; @@ -44,7 +45,13 @@ describe('e2e_multiple_accounts_1_enc_key', () => { // Verify that all accounts use the same encryption key const encryptionPublicKey = await generatePublicKey(encryptionPrivateKey); - for (const account of await pxe.getRegisteredAccounts()) { + // Disregard sandbox accounts + const sandBoxWallets = await getSandboxAccountsWallets(pxe); + const allAccounts = await pxe.getRegisteredAccounts(); + const keyAccounts = allAccounts.filter( + acc => !sandBoxWallets.map(wlt => wlt.getAddress().toString()).includes(acc.address.toString()), + ); + for (const account of keyAccounts) { expect(account.publicKey).toEqual(encryptionPublicKey); } diff --git a/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts b/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts index 94bfe22844e..eb1fe393d18 100644 --- a/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts +++ b/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts @@ -35,7 +35,7 @@ describe('archiver integration with l1 to l2 messages', () => { let accounts: CompleteAddress[]; ({ teardown, wallet, deployL1ContractsValues, accounts, config, logger } = await setup(2)); config.archiverPollingIntervalMS = 100; - archiver = await Archiver.createAndSync(config); + archiver = await Archiver.createAndSync({ ...config, l1Contracts: deployL1ContractsValues.l1ContractAddresses }); const walletClient = deployL1ContractsValues.walletClient; publicClient = deployL1ContractsValues.publicClient; From a07087db3c2d6bf516cdb740c51a05613d259e98 Mon Sep 17 00:00:00 2001 From: spypsy Date: Wed, 18 Oct 2023 17:40:27 +0000 Subject: [PATCH 5/6] Run canary tests using sandbox docker-compose.yml --- yarn-project/aztec-sandbox/README.md | 7 +++- .../aztec-sandbox/docker-compose-fork.yml | 21 ----------- .../canary/scripts/docker-compose-browser.yml | 31 ++-------------- .../scripts/docker-compose-e2e-sandbox.yml | 36 ------------------- .../canary/scripts/docker-compose.yml | 33 ++--------------- yarn-project/canary/scripts/run_tests | 9 ++--- 6 files changed, 14 insertions(+), 123 deletions(-) delete mode 100644 yarn-project/aztec-sandbox/docker-compose-fork.yml delete mode 100644 yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml diff --git a/yarn-project/aztec-sandbox/README.md b/yarn-project/aztec-sandbox/README.md index 91b65563598..02d5daf51bb 100644 --- a/yarn-project/aztec-sandbox/README.md +++ b/yarn-project/aztec-sandbox/README.md @@ -46,7 +46,12 @@ From the `aztec-sandbox` directory, you can run the two existing examples: - `yarn run:example:token` - An L1 / L2 uniswap token trade. - `yarn run:example:uniswap` - - To run this example, you need to use the `docker-compose-fork.yml` configuration. + - To run this example, you need to set the following vars: + +``` +export FORK_BLOCK_NUMBER=17514288 +export FORK_URL= +``` ## Publishing diff --git a/yarn-project/aztec-sandbox/docker-compose-fork.yml b/yarn-project/aztec-sandbox/docker-compose-fork.yml deleted file mode 100644 index 69660298029..00000000000 --- a/yarn-project/aztec-sandbox/docker-compose-fork.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3' -services: - fork: - image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 - entrypoint: 'anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --host 0.0.0.0 --fork-block-number 17514288 --chain-id 31337' - ports: - - '8545:8545' - - rpc-server: - image: aztecprotocol/aztec-sandbox:latest - ports: - - '8080:8080' - environment: - DEBUG: 'aztec:*' - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - ARCHIVER_POLLING_INTERVAL_MS: 50 - P2P_BLOCK_CHECK_INTERVAL_MS: 50 - SEQ_TX_POLLING_INTERVAL_MS: 50 - WS_BLOCK_CHECK_INTERVAL_MS: 50 - ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml index 6e9429371ab..98d8a7d9625 100644 --- a/yarn-project/canary/scripts/docker-compose-browser.yml +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -1,36 +1,9 @@ version: '3' services: - fork: - image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 - entrypoint: > - sh -c ' - if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" - else - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 - fi' - ports: - - '8545:8545' - - sandbox: - image: aztecprotocol/aztec-sandbox:canary - environment: - DEBUG: 'aztec:*' - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - ARCHIVER_POLLING_INTERVAL_MS: 50 - P2P_BLOCK_CHECK_INTERVAL_MS: 50 - SEQ_TX_POLLING_INTERVAL_MS: 50 - WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_BLOCK_POLLING_INTERVAL_MS: 50 - ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - ports: - - '8080:8080' - canary: image: aztecprotocol/canary:latest environment: - ETHEREUM_HOST: http://fork:8545 + ETHEREUM_HOST: http://ethereum:8545 CHAIN_ID: 31337 - PXE_URL: http://sandbox:8080 + PXE_URL: http://aztec:8080 command: ['./scripts/start_e2e_ci_browser.sh', './src/aztec_js_browser.test.ts'] diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml deleted file mode 100644 index e9d8f75c5b3..00000000000 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: '3' -services: - fork: - image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 - entrypoint: > - sh -c ' - if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" - else - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 - fi' - ports: - - '8545:8545' - - sandbox: - image: aztecprotocol/sandbox:latest - environment: - DEBUG: 'aztec:*' - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - ARCHIVER_POLLING_INTERVAL_MS: 50 - P2P_BLOCK_CHECK_INTERVAL_MS: 50 - SEQ_TX_POLLING_INTERVAL_MS: 50 - WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_BLOCK_POLLING_INTERVAL_MS: 50 - ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - ports: - - '8080:8080' - - canary: - image: aztecprotocol/canary:latest - environment: - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - PXE_URL: http://sandbox:8080 - command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/canary/scripts/docker-compose.yml b/yarn-project/canary/scripts/docker-compose.yml index 06a2c094a19..74a28452a07 100644 --- a/yarn-project/canary/scripts/docker-compose.yml +++ b/yarn-project/canary/scripts/docker-compose.yml @@ -1,36 +1,9 @@ version: '3' services: - fork: - image: ghcr.io/foundry-rs/foundry:nightly-a44aa13cfc23491ba32aaedc093e9488c1a6db43 - entrypoint: > - sh -c ' - if [ -n "$FORK_BLOCK_NUMBER" ] && [ -n "$FORK_URL" ]; then - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 --fork-url "$FORK_URL" --fork-block-number "$FORK_BLOCK_NUMBER" - else - exec anvil -p 8545 --host 0.0.0.0 --chain-id 31337 - fi' - ports: - - '8545:8545' - - sandbox: - image: aztecprotocol/aztec-sandbox:canary - environment: - DEBUG: 'aztec:*' - ETHEREUM_HOST: http://fork:8545 - CHAIN_ID: 31337 - ARCHIVER_POLLING_INTERVAL_MS: 50 - P2P_BLOCK_CHECK_INTERVAL_MS: 50 - SEQ_TX_POLLING_INTERVAL_MS: 50 - WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_BLOCK_POLLING_INTERVAL_MS: 50 - ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 - ports: - - '8080:8080' - canary: image: aztecprotocol/canary:latest environment: - ETHEREUM_HOST: http://fork:8545 + ETHEREUM_HOST: http://ethereum:8545 CHAIN_ID: 31337 - PXE_URL: http://sandbox:8080 - command: ${TEST:-./src/uniswap_trade_on_l1_from_l2.test.ts} + PXE_URL: http://aztec:8080 + command: ${TEST:-./src/cli.test.ts} diff --git a/yarn-project/canary/scripts/run_tests b/yarn-project/canary/scripts/run_tests index 5ed4d4609c1..6ea4c000880 100755 --- a/yarn-project/canary/scripts/run_tests +++ b/yarn-project/canary/scripts/run_tests @@ -22,9 +22,6 @@ IMAGE_URI=$(calculate_image_uri $IMAGE) retry docker pull $IMAGE_URI retry docker tag $IMAGE_URI aztecprotocol/canary:latest -SANDBOX_IMAGE_URI=$(calculate_image_uri aztec-sandbox) -retry docker pull $SANDBOX_IMAGE_URI -retry docker tag $SANDBOX_IMAGE_URI aztecprotocol/sandbox:latest - -docker-compose -f $COMPOSE_FILE rm -f -docker-compose -f $COMPOSE_FILE up --exit-code-from canary +export SANDBOX_VERSION=canary +docker-compose -f ../../aztec-sandbox/docker-compose.yml -f $COMPOSE_FILE rm -f +docker-compose -f ../../aztec-sandbox/docker-compose.yml -f $COMPOSE_FILE up --exit-code-from canary From f4c69e42f258b7c2011dc9055e112a9cb4f7ffc1 Mon Sep 17 00:00:00 2001 From: spypsy Date: Mon, 23 Oct 2023 14:05:43 +0000 Subject: [PATCH 6/6] update tests to work locally as well --- .../end-to-end/src/e2e_card_game.test.ts | 19 ++++++++++++++++-- yarn-project/end-to-end/src/e2e_cli.test.ts | 19 ++++++++++++++++-- .../e2e_multiple_accounts_1_enc_key.test.ts | 20 +++++++++++++------ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_card_game.test.ts b/yarn-project/end-to-end/src/e2e_card_game.test.ts index 2632ef1a648..84d52e8cca4 100644 --- a/yarn-project/end-to-end/src/e2e_card_game.test.ts +++ b/yarn-project/end-to-end/src/e2e_card_game.test.ts @@ -1,4 +1,10 @@ -import { AccountWallet, AztecAddress, Wallet, getSandboxAccountsWallets } from '@aztec/aztec.js'; +import { + AccountWallet, + AztecAddress, + Wallet, + deployInitialSandboxAccounts, + getSandboxAccountsWallets, +} from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { CardGameContract } from '@aztec/noir-contracts/types'; import { PXE } from '@aztec/types'; @@ -7,6 +13,8 @@ import { setup } from './fixtures/utils.js'; /* eslint-disable camelcase */ +const { PXE_URL } = process.env; + interface Card { points: bigint; strength: bigint; @@ -65,7 +73,14 @@ describe('e2e_card_game', () => { // Card stats are derived from the users' private keys, so to get consistent values, we set up the // initial sandbox accounts that always use the same private keys, instead of random ones. ({ pxe, logger, teardown } = await setup(0)); - wallets = await getSandboxAccountsWallets(pxe); + + // Get pre-deployed account wallets if we're running against sandbox. + if (PXE_URL) { + wallets = await getSandboxAccountsWallets(pxe); + } else { + // Deploy initial wallets if we're NOT running against sandbox. + wallets = await Promise.all((await deployInitialSandboxAccounts(pxe)).map(a => a.account.getWallet())); + } [firstPlayerWallet, secondPlayerWallet, thirdPlayerWallet] = wallets; [firstPlayer, secondPlayer, thirdPlayer] = wallets.map(a => a.getAddress()); await deployContract(); diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 681fc0b2adb..bb3d0a11d71 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,23 +1,38 @@ +import { startHttpRpcServer } from '@aztec/aztec-sandbox'; import { PXE, createDebugLogger } from '@aztec/aztec.js'; +import { createPXERpcServer } from '@aztec/pxe'; import { setup as e2eSetup } from './fixtures/utils.js'; import { cliTestSuite } from './shared/cli.js'; -const { PXE_URL } = process.env; +const HTTP_PORT = 9009; +let RPC_URL = `http://localhost:${HTTP_PORT}`; const debug = createDebugLogger('aztec:e2e_cli'); +let http: ReturnType; let pxe: PXE; let teardown: () => Promise; +// Use Sandbox PXE URL if we're running against sandbox +const { PXE_URL } = process.env; +if (PXE_URL) { + RPC_URL = PXE_URL; +} + const testSetup = async () => { const context = await e2eSetup(2); debug(`Environment set up`); ({ pxe, teardown } = context); + if (!PXE_URL) { + http = startHttpRpcServer(pxe, createPXERpcServer, HTTP_PORT); + debug(`HTTP RPC server started in port ${HTTP_PORT}`); + } return pxe; }; const testCleanup = async () => { + http?.close(); await teardown(); }; -cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), PXE_URL); +cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), RPC_URL); diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 9e8f9d1b139..85cca3baeb0 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -10,10 +10,12 @@ import { import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { DebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts/types'; -import { AztecNode, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; +const { PXE_URL } = process.env; + describe('e2e_multiple_accounts_1_enc_key', () => { let aztecNode: AztecNode | undefined; let pxe: PXE; @@ -45,12 +47,18 @@ describe('e2e_multiple_accounts_1_enc_key', () => { // Verify that all accounts use the same encryption key const encryptionPublicKey = await generatePublicKey(encryptionPrivateKey); + // Disregard sandbox accounts - const sandBoxWallets = await getSandboxAccountsWallets(pxe); - const allAccounts = await pxe.getRegisteredAccounts(); - const keyAccounts = allAccounts.filter( - acc => !sandBoxWallets.map(wlt => wlt.getAddress().toString()).includes(acc.address.toString()), - ); + let keyAccounts: CompleteAddress[]; + if (PXE_URL) { + const sandBoxWallets = await getSandboxAccountsWallets(pxe); + const allAccounts = await pxe.getRegisteredAccounts(); + keyAccounts = allAccounts.filter( + acc => !sandBoxWallets.map(wlt => wlt.getAddress().toString()).includes(acc.address.toString()), + ); + } else { + keyAccounts = await pxe.getRegisteredAccounts(); + } for (const account of keyAccounts) { expect(account.publicKey).toEqual(encryptionPublicKey); }