Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:debug": "LOG_LEVEL=${LOG_LEVEL:-verbose} NODE_NO_WARNINGS=1 node --inspect --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --no-cache --runInBand --config jest.integration.config.json",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests src/fixtures",
"test:compose": "./scripts/test.sh compose",
"formatting": "run -T prettier --check ./src && run -T eslint ./src"
},
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/package.local.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "yarn clean && tsc -b && webpack",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures"
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests src/fixtures"
},
"jest": {
"reporters": [
Expand Down
45 changes: 0 additions & 45 deletions yarn-project/end-to-end/src/fixtures/setup_l1_contracts.test.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the ethereum package

This file was deleted.

2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/snapshot_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ async function setupFromFresh(
client: deployL1ContractsValues.publicClient,
});

const blockReward = await rewardDistributor.read.BLOCK_REWARD([]);
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
const mintAmount = 10_000n * (blockReward as bigint);

const feeJuice = getContract({
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export async function setup(
client: deployL1ContractsValues.publicClient,
});

const blockReward = await rewardDistributor.read.BLOCK_REWARD([]);
const blockReward = await rewardDistributor.read.BLOCK_REWARD();
const mintAmount = 10_000n * (blockReward as bigint);

const feeJuice = getContract({
Expand Down
99 changes: 99 additions & 0 deletions yarn-project/ethereum/src/deploy_l1_contracts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { times } from '@aztec/foundation/collection';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { type Logger, createLogger } from '@aztec/foundation/log';
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';

import { type Anvil } from '@viem/anvil';
import { getContract } from 'viem';
import { type PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts';
import { foundry } from 'viem/chains';

import { DefaultL1ContractsConfig } from './config.js';
import { type DeployL1ContractsArgs, deployL1Contracts } from './deploy_l1_contracts.js';
import { startAnvil } from './test/start_anvil.js';

describe('deploy_l1_contracts', () => {
let anvil: Anvil;
let rpcUrl: string;
let privateKey: PrivateKeyAccount;
let logger: Logger;

let vkTreeRoot: Fr;
let protocolContractTreeRoot: Fr;
let initialValidators: EthAddress[];
let l2FeeJuiceAddress: AztecAddress;

beforeAll(async () => {
logger = createLogger('ethereum:test:deploy_l1_contracts');
privateKey = privateKeyToAccount('0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba');
vkTreeRoot = Fr.random();
protocolContractTreeRoot = Fr.random();
initialValidators = times(3, EthAddress.random);
l2FeeJuiceAddress = AztecAddress.random();

({ anvil, rpcUrl } = await startAnvil());
});

afterAll(async () => {
await anvil.stop();
});

const deploy = (args: Partial<DeployL1ContractsArgs> = {}) =>
deployL1Contracts(rpcUrl, privateKey, foundry, logger, {
...DefaultL1ContractsConfig,
salt: undefined,
vkTreeRoot,
protocolContractTreeRoot,
l2FeeJuiceAddress,
...args,
});

const getRollup = (deployed: Awaited<ReturnType<typeof deploy>>) =>
getContract({
address: deployed.l1ContractAddresses.rollupAddress.toString(),
abi: RollupAbi,
client: deployed.publicClient,
});

it('deploys without salt', async () => {
await deploy();
});

it('deploys initializing validators', async () => {
const deployed = await deploy({ initialValidators });
const rollup = getRollup(deployed);
for (const validator of initialValidators) {
const { status } = await rollup.read.getInfo([validator.toString()]);
expect(status).toBeGreaterThan(0);
}
});

it('deploys with salt on different addresses', async () => {
const first = await deploy({ salt: 42 });
const second = await deploy({ salt: 43 });

expect(first.l1ContractAddresses).not.toEqual(second.l1ContractAddresses);
});

it('deploys twice with salt on same addresses', async () => {
const first = await deploy({ salt: 44 });
const second = await deploy({ salt: 44 });

expect(first.l1ContractAddresses).toEqual(second.l1ContractAddresses);
});

it('deploys twice with salt on same addresses initializing validators', async () => {
const first = await deploy({ salt: 44, initialValidators });
const second = await deploy({ salt: 44, initialValidators });

expect(first.l1ContractAddresses).toEqual(second.l1ContractAddresses);

const rollup = getRollup(first);
for (const validator of initialValidators) {
const { status } = await rollup.read.getInfo([validator.toString()]);
expect(status).toBeGreaterThan(0);
}
});
});
Loading
Loading