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 b64b782
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 47 deletions.
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
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 b64b782

Please sign in to comment.