From bed393f6e443c7d2f5acbc82a682b4bc57e10f82 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Sun, 15 Sep 2024 09:26:34 +0000 Subject: [PATCH] init 2 --- .../contracts/auth_contract/src/test/utils.nr | 1 - .../token_bridge_failure_cases.test.ts | 2 +- .../token_bridge_private.test.ts | 8 +++--- .../token_bridge_public_to_private.test.ts | 11 +++----- .../e2e_deploy_contract/deploy_method.test.ts | 17 +++++++++++- .../e2e_deploy_contract/regressions.test.ts | 27 ------------------- 6 files changed, 26 insertions(+), 40 deletions(-) delete mode 100644 yarn-project/end-to-end/src/e2e_deploy_contract/regressions.test.ts diff --git a/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr index 7e085e8fb911..a2003f657fcf 100644 --- a/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr @@ -5,7 +5,6 @@ use dep::aztec::{ use crate::Auth; pub fn setup() -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress) { - // Setup env, generate keys let mut env = TestEnvironment::new(); let admin = env.create_account(); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts index 2d51bc3975af..afc868a2086e 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_failure_cases.test.ts @@ -3,8 +3,8 @@ import { sha256ToField } from '@aztec/foundation/crypto'; import { toFunctionSelector } from 'viem'; -import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; import { NO_L1_TO_L2_MSG_ERROR } from '../fixtures/fixtures.js'; +import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; describe('e2e_cross_chain_messaging token_bridge_failure_cases', () => { const t = new CrossChainMessagingTest('token_bridge_failure_cases'); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts index 3f097916d520..dc94eb0426c7 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts @@ -1,9 +1,10 @@ import { Fr, L1Actor, L1ToL2Message, L2Actor } from '@aztec/aztec.js'; - -import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; import { sha256ToField } from '@aztec/foundation/crypto'; + import { toFunctionSelector } from 'viem/utils'; +import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; + describe('e2e_cross_chain_messaging token_bridge_private', () => { const t = new CrossChainMessagingTest('token_bridge_private'); @@ -166,5 +167,6 @@ describe('e2e_cross_chain_messaging token_bridge_private', () => { ); await crossChainTestHarness.redeemShieldPrivatelyOnL2(bridgeAmount, secretForRedeemingMintedNotes); await crossChainTestHarness.expectPrivateBalanceOnL2(ownerAddress, bridgeAmount); - }), 90_000; + }), + 90_000; }); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts index 05922e448602..5b1086c095c0 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts @@ -3,12 +3,8 @@ import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; describe('e2e_cross_chain_messaging token_bridge_public_to_private', () => { const t = new CrossChainMessagingTest('token_bridge_public_to_private'); - let { - crossChainTestHarness, - ethAccount, - aztecNode, - ownerAddress, - } = t; + let { crossChainTestHarness, ethAccount, aztecNode, ownerAddress } = t; + let underlyingERC20: any; beforeEach(async () => { await t.applyBaseSnapshots(); @@ -19,6 +15,7 @@ describe('e2e_cross_chain_messaging token_bridge_public_to_private', () => { ethAccount = crossChainTestHarness.ethAccount; aztecNode = crossChainTestHarness.aztecNode; ownerAddress = crossChainTestHarness.ownerAddress; + underlyingERC20 = crossChainTestHarness.underlyingERC20; }, 300_000); afterEach(async () => { @@ -36,7 +33,7 @@ describe('e2e_cross_chain_messaging token_bridge_public_to_private', () => { await crossChainTestHarness.mintTokensOnL1(l1TokenBalance); const msgHash = await crossChainTestHarness.sendTokensToPortalPublic(bridgeAmount, secretHash); - expect(await crossChainTestHarness.underlyingERC20.read.balanceOf([ethAccount.toString()])).toBe(l1TokenBalance - bridgeAmount); + expect(await underlyingERC20.read.balanceOf([ethAccount.toString()])).toBe(l1TokenBalance - bridgeAmount); await crossChainTestHarness.makeMessageConsumable(msgHash); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts index 5daa7a72611c..cebc961785b5 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_method.test.ts @@ -1,4 +1,5 @@ -import { AztecAddress, type DebugLogger, type PXE, type Wallet } from '@aztec/aztec.js'; +import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing'; +import { AztecAddress, type DebugLogger, type PXE, type Wallet, createPXEClient, makeFetch } from '@aztec/aztec.js'; import { CounterContract, StatefulTestContract } from '@aztec/noir-contracts.js'; import { TestContract } from '@aztec/noir-contracts.js/Test'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; @@ -98,4 +99,18 @@ describe('e2e_deploy_contract deploy method', () => { it.skip('publicly deploys and calls a public function in a tx in the same block', async () => { // TODO(@spalladino): Requires being able to read a nullifier on the same block it was emitted. }); + + describe('regressions', () => { + it('fails properly when trying to deploy a contract with a failing constructor with a pxe client with retries', async () => { + const { PXE_URL } = process.env; + if (!PXE_URL) { + return; + } + const pxeClient = createPXEClient(PXE_URL, makeFetch([1, 2, 3], false)); + const [wallet] = await getDeployedTestAccountsWallets(pxeClient); + await expect( + StatefulTestContract.deployWithOpts({ wallet, method: 'wrong_constructor' }).send().deployed(), + ).rejects.toThrow(/Unknown function/); + }); + }); }); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/regressions.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/regressions.test.ts deleted file mode 100644 index 729ed9764504..000000000000 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/regressions.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { getDeployedTestAccountsWallets } from '@aztec/accounts/testing'; -import { createPXEClient, makeFetch } from '@aztec/aztec.js'; -import { StatefulTestContract } from '@aztec/noir-contracts.js'; - -import { DeployTest } from './deploy_test.js'; - -describe('e2e_deploy_contract regressions', () => { - const t = new DeployTest('regressions'); - - beforeAll(async () => { - await t.setup(); - }); - - afterAll(() => t.teardown()); - - it('fails properly when trying to deploy a contract with a failing constructor with a pxe client with retries', async () => { - const { PXE_URL } = process.env; - if (!PXE_URL) { - return; - } - const pxeClient = createPXEClient(PXE_URL, makeFetch([1, 2, 3], false)); - const [wallet] = await getDeployedTestAccountsWallets(pxeClient); - await expect( - StatefulTestContract.deployWithOpts({ wallet, method: 'wrong_constructor' }).send().deployed(), - ).rejects.toThrow(/Unknown function/); - }); -});