From b8972b4838df02004e8c2b40da446a484e1c0df4 Mon Sep 17 00:00:00 2001 From: Lasse Herskind <16536249+LHerskind@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:05:31 +0200 Subject: [PATCH] chore: Create fixtures folder in E2E (#1419) Creates a folder for fixtures in E2E and moves: - dumps - fixtures.ts - utils - cross_chain_test_harness.ts Not moving the `cheat_codes.ts` as @rahul-kothari was in progress of moving that to another location already. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts | 2 +- yarn-project/end-to-end/src/e2e_account_contracts.test.ts | 2 +- yarn-project/end-to-end/src/e2e_block_building.test.ts | 2 +- yarn-project/end-to-end/src/e2e_cheat_codes.test.ts | 2 +- .../end-to-end/src/e2e_cross_chain_messaging.test.ts | 4 ++-- yarn-project/end-to-end/src/e2e_deploy_contract.test.ts | 2 +- yarn-project/end-to-end/src/e2e_escrow_contract.test.ts | 2 +- yarn-project/end-to-end/src/e2e_lending_contract.test.ts | 2 +- .../end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts | 2 +- yarn-project/end-to-end/src/e2e_nested_contract.test.ts | 2 +- .../end-to-end/src/e2e_non_contract_account.test.ts | 2 +- yarn-project/end-to-end/src/e2e_p2p_network.test.ts | 2 +- .../src/e2e_pending_commitments_contract.test.ts | 2 +- .../src/e2e_public_cross_chain_messaging.test.ts | 4 ++-- .../end-to-end/src/e2e_public_to_private_messaging.test.ts | 4 ++-- .../end-to-end/src/e2e_public_token_contract.test.ts | 2 +- yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts | 6 +++++- .../cross_chain_test_harness.ts} | 2 +- .../end-to-end/src/{ => fixtures}/dumps/uniswap_state.json | 0 yarn-project/end-to-end/src/{ => fixtures}/fixtures.ts | 0 yarn-project/end-to-end/src/{ => fixtures}/utils.ts | 2 +- .../end-to-end/src/integration_archiver_l1_to_l2.test.ts | 2 +- .../end-to-end/src/integration_l1_publisher.test.ts | 2 +- .../end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts | 7 ++++--- 24 files changed, 32 insertions(+), 27 deletions(-) rename yarn-project/end-to-end/src/{cross_chain/test_harness.ts => fixtures/cross_chain_test_harness.ts} (99%) rename yarn-project/end-to-end/src/{ => fixtures}/dumps/uniswap_state.json (100%) rename yarn-project/end-to-end/src/{ => fixtures}/fixtures.ts (100%) rename yarn-project/end-to-end/src/{ => fixtures}/utils.ts (99%) diff --git a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts index 37fccd2d39d..b219d65fb0a 100644 --- a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts @@ -12,7 +12,7 @@ import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup, setupAztecRPCServer, -} from './utils.js'; +} from './fixtures/utils.js'; const { SANDBOX_URL = '' } = process.env; diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts index a97d9f880db..8efcd1d0afd 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts @@ -11,7 +11,7 @@ import { } from '@aztec/noir-contracts/artifacts'; import { ChildContract } from '@aztec/noir-contracts/types'; -import { CreateAccountImplFn, createNewAccount, deployContract, setup } from './utils.js'; +import { CreateAccountImplFn, createNewAccount, deployContract, setup } from './fixtures/utils.js'; function itShouldBehaveLikeAnAccountContract( abi: ContractAbi, diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 88f6d03bbf7..7015bc97d70 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -7,7 +7,7 @@ import { AztecRPC, TxStatus } from '@aztec/types'; import times from 'lodash.times'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 3d63096e345..dceed86dd6d 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -3,7 +3,7 @@ import { AztecRPCServer } from '@aztec/aztec-rpc'; import { AztecRPC } from '@aztec/types'; import { CheatCodes } from './cheat_codes.js'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_cheat_codes', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 7b4e7e7a25f..c343f66c89a 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -6,8 +6,8 @@ import { DebugLogger } from '@aztec/foundation/log'; import { NonNativeTokenContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { CrossChainTestHarness } from './cross_chain/test_harness.js'; -import { delay, setup } from './utils.js'; +import { CrossChainTestHarness } from './fixtures/cross_chain_test_harness.js'; +import { delay, setup } from './fixtures/utils.js'; describe('e2e_cross_chain_messaging', () => { let aztecNode: AztecNodeService; diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index ed0a4a4f25d..a7a3f1f00f5 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -6,7 +6,7 @@ import { DebugLogger } from '@aztec/foundation/log'; import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_deploy_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts index a863f07634a..c7c7d32aaaa 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts @@ -9,7 +9,7 @@ import { EscrowContractAbi, ZkTokenContractAbi } from '@aztec/noir-contracts/art import { EscrowContract, ZkTokenContract } from '@aztec/noir-contracts/types'; import { AztecRPC, PublicKey } from '@aztec/types'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_escrow_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index 46d20311335..b4ec41e38f6 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -8,7 +8,7 @@ import { LendingContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; import { CheatCodes } from './cheat_codes.js'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_lending_contract', () => { let aztecNode: AztecNodeService | undefined; 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 62b09364808..dddb8b88a1f 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 @@ -13,7 +13,7 @@ import { expectUnencryptedLogsFromLastBlockToBe, expectsNumOfEncryptedLogsInTheLastBlockToBe, setup, -} from './utils.js'; +} from './fixtures/utils.js'; describe('e2e_multiple_accounts_1_enc_key', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts index a87fbe5ff35..fba6e540515 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts @@ -8,7 +8,7 @@ import { ChildContractAbi, ParentContractAbi } from '@aztec/noir-contracts/artif import { ChildContract, ParentContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_nested_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index d3df4942d6c..6bb5880aec4 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -7,7 +7,7 @@ import { retryUntil } from '@aztec/foundation/retry'; import { PokeableTokenContract } from '@aztec/noir-contracts/types'; import { AztecRPC, FunctionCall, PackedArguments, TxExecutionRequest, TxStatus } from '@aztec/types'; -import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './utils.js'; +import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; /** * Wallet implementation which creates a simple transaction request without any signing. diff --git a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts index f37716cad11..a5c66745283 100644 --- a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts @@ -14,7 +14,7 @@ import { TestContractAbi } from '@aztec/noir-contracts/artifacts'; import { BootstrapNode, P2PConfig, createLibP2PPeerId, exportLibP2PPeerIdToString } from '@aztec/p2p'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; const NUM_NODES = 4; const NUM_TXS_PER_BLOCK = 4; diff --git a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts index 6985c026373..94a544305c2 100644 --- a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts @@ -5,7 +5,7 @@ import { DebugLogger } from '@aztec/foundation/log'; import { PendingCommitmentsContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_pending_commitments_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index 7cc8ccd2934..8117b913fcf 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -6,8 +6,8 @@ import { DebugLogger } from '@aztec/foundation/log'; import { NonNativeTokenContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { CrossChainTestHarness } from './cross_chain/test_harness.js'; -import { delay, setup } from './utils.js'; +import { CrossChainTestHarness } from './fixtures/cross_chain_test_harness.js'; +import { delay, setup } from './fixtures/utils.js'; describe('e2e_public_cross_chain_messaging', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts index ced0650c0a1..191a2f59775 100644 --- a/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_to_private_messaging.test.ts @@ -4,8 +4,8 @@ import { AztecAddress, AztecRPC } from '@aztec/aztec.js'; import { EthAddress } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; -import { CrossChainTestHarness } from './cross_chain/test_harness.js'; -import { delay, setup } from './utils.js'; +import { CrossChainTestHarness } from './fixtures/cross_chain_test_harness.js'; +import { delay, setup } from './fixtures/utils.js'; describe('e2e_public_to_private_messaging', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts index 37fe2327994..204922e8514 100644 --- a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts @@ -8,7 +8,7 @@ import { AztecRPC, L2BlockL2Logs, TxStatus } from '@aztec/types'; import times from 'lodash.times'; import { CheatCodes } from './cheat_codes.js'; -import { setup } from './utils.js'; +import { setup } from './fixtures/utils.js'; describe('e2e_public_token_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts index 4b56c3f4b5f..4b58299099b 100644 --- a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts @@ -5,7 +5,11 @@ import { DebugLogger } from '@aztec/foundation/log'; import { ZkTokenContract } from '@aztec/noir-contracts/types'; import { AztecRPC, TxStatus } from '@aztec/types'; -import { expectUnencryptedLogsFromLastBlockToBe, expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './utils.js'; +import { + expectUnencryptedLogsFromLastBlockToBe, + expectsNumOfEncryptedLogsInTheLastBlockToBe, + setup, +} from './fixtures/utils.js'; describe('e2e_zk_token_contract', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/cross_chain/test_harness.ts b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts similarity index 99% rename from yarn-project/end-to-end/src/cross_chain/test_harness.ts rename to yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts index 130a8a24066..1bdcb632d8a 100644 --- a/yarn-project/end-to-end/src/cross_chain/test_harness.ts +++ b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts @@ -13,7 +13,7 @@ import { AztecRPC, TxStatus } from '@aztec/types'; import { Chain, HttpTransport, PublicClient, getContract } from 'viem'; import { CheatCodes } from '../cheat_codes.js'; -import { deployAndInitializeNonNativeL2TokenContracts } from '../utils.js'; +import { deployAndInitializeNonNativeL2TokenContracts } from './utils.js'; /** * A Class for testing cross chain interactions, contains common interactions diff --git a/yarn-project/end-to-end/src/dumps/uniswap_state.json b/yarn-project/end-to-end/src/fixtures/dumps/uniswap_state.json similarity index 100% rename from yarn-project/end-to-end/src/dumps/uniswap_state.json rename to yarn-project/end-to-end/src/fixtures/dumps/uniswap_state.json diff --git a/yarn-project/end-to-end/src/fixtures.ts b/yarn-project/end-to-end/src/fixtures/fixtures.ts similarity index 100% rename from yarn-project/end-to-end/src/fixtures.ts rename to yarn-project/end-to-end/src/fixtures/fixtures.ts diff --git a/yarn-project/end-to-end/src/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts similarity index 99% rename from yarn-project/end-to-end/src/utils.ts rename to yarn-project/end-to-end/src/fixtures/utils.ts index 52d4e3345f6..dabb5fb8c96 100644 --- a/yarn-project/end-to-end/src/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -51,7 +51,7 @@ import { } from 'viem'; import { mnemonicToAccount } from 'viem/accounts'; -import { CheatCodes, L1CheatCodes } from './cheat_codes.js'; +import { CheatCodes, L1CheatCodes } from '../cheat_codes.js'; import { MNEMONIC, localAnvil } from './fixtures.js'; const { SANDBOX_URL = '' } = process.env; 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 1df2260fd5f..25f7271b162 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 @@ -10,7 +10,7 @@ import { NonNativeTokenContract } from '@aztec/noir-contracts/types'; import { Chain, HttpTransport, PublicClient } from 'viem'; -import { delay, deployAndInitializeNonNativeL2TokenContracts, setNextBlockTimestamp, setup } from './utils.js'; +import { delay, deployAndInitializeNonNativeL2TokenContracts, setNextBlockTimestamp, setup } from './fixtures/utils.js'; describe('archiver integration with l1 to l2 messages', () => { let aztecNode: AztecNodeService | undefined; diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 2ba1655bc8f..ffd59647ecb 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -50,7 +50,7 @@ import { } from 'viem'; import { PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts'; -import { localAnvil } from './fixtures.js'; +import { localAnvil } from './fixtures/fixtures.js'; // Accounts 4 and 5 of Anvil default startup with mnemonic: 'test test test test test test test test test test test junk' const sequencerPK = '0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a'; diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index e1f74736a3b..6ac27d8b1bb 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -11,8 +11,8 @@ import { AztecRPC, TxStatus } from '@aztec/types'; import { getContract, parseEther } from 'viem'; import { CheatCodes } from './cheat_codes.js'; -import { CrossChainTestHarness } from './cross_chain/test_harness.js'; -import { delay, deployAndInitializeNonNativeL2TokenContracts, setup } from './utils.js'; +import { CrossChainTestHarness } from './fixtures/cross_chain_test_harness.js'; +import { delay, deployAndInitializeNonNativeL2TokenContracts, setup } from './fixtures/utils.js'; // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we // don't need to burn through RPC requests. @@ -21,7 +21,8 @@ import { delay, deployAndInitializeNonNativeL2TokenContracts, setup } from './ut // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337 // For CI, this is configured in `run_tests.sh` and `docker-compose.yml` -const dumpedState = 'src/dumps/uniswap_state'; +const dumpedState = 'src/fixtures/dumps/uniswap_state'; +// When taking a dump use the block number of the fork to improve speed. const EXPECTED_FORKED_BLOCK = 0; //17514288; // We tell the archiver to only sync from this block. process.env.SEARCH_START_BLOCK = EXPECTED_FORKED_BLOCK.toString();