Skip to content

Commit

Permalink
init 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Sep 16, 2024
1 parent 8c19ec5 commit 6b048ad
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Similarly we have discovered some anti-patterns too (like privacy leakage) that
We call this the "authentication witness" pattern or authwit for short.

- Approve someone in private domain:
#include_code authwit_to_another_sc /yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts typescript
#include_code authwit_to_another_sc /yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts typescript

Here you approve a contract to burn funds on your behalf.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ This fetches the wallets from the sandbox and deploys our cross chain harness on
Paste the private flow test below the setup:
#include_code e2e_private_cross_chain /yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts typescript
#include_code e2e_private_cross_chain /yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_private.test.ts typescript
## Public flow test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod main;
mod utils;
mod utils;
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
use dep::aztec::{
prelude::AztecAddress, test::helpers::test_environment::TestEnvironment,
};
use dep::aztec::{prelude::AztecAddress, test::helpers::test_environment::TestEnvironment};

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();
let to_authorize = env.create_account();
let other = env.create_account();

let initializer_call_interface = Auth::interface().constructor(
admin,
);
let initializer_call_interface = Auth::interface().constructor(admin);

let auth_contract = env.deploy_self("Auth").with_public_initializer(initializer_call_interface);
let auth_contract_address = auth_contract.to_address();
Expand Down
8 changes: 1 addition & 7 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ e2e-cheat-codes:
e2e-counter-contract:
DO +E2E_TEST --test=./src/e2e_counter_contract.test.ts

e2e-cross-chain-messaging:
DO +E2E_TEST --test=./src/e2e_cross_chain_messaging.test.ts

e2e-crowdfunding-and-claim:
DO +E2E_TEST --test=./src/e2e_crowdfunding_and_claim.test.ts

Expand Down Expand Up @@ -230,12 +227,9 @@ e2e-fees-fee-juice-payments:
e2e-fees-account-init:
DO +E2E_TEST --test=./src/e2e_fees/account_init.test.ts

e2e-public-cross-chain-messaging:
e2e-cross-chain-messaging:
DO +E2E_TEST --test=./src/e2e_cross_chain_messaging

e2e-public-to-private-messaging:
DO +E2E_TEST --test=./src/e2e_public_to_private_messaging.test.ts

e2e-state-vars:
DO +E2E_TEST --test=./src/e2e_state_vars.test.ts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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;
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 () => {
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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/);
});
});
});

This file was deleted.

0 comments on commit 6b048ad

Please sign in to comment.