Skip to content

Commit b3f3509

Browse files
committed
test: add anvil harness for integration tests
1 parent a0ec198 commit b3f3509

File tree

10 files changed

+1216
-8
lines changed

10 files changed

+1216
-8
lines changed

nitro-contracts/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ghcr.io/foundry-rs/foundry:v1.3.1 AS foundry
2+
3+
FROM node:20-bullseye-slim
4+
5+
COPY --from=foundry /usr/local/bin/forge /usr/local/bin/forge
6+
7+
WORKDIR /workspace
8+
COPY . /workspace
9+
RUN cp scripts/config.example.ts scripts/config.ts
10+
RUN yarn install
11+
RUN yarn build:all
12+
13+
ENTRYPOINT ["yarn"]

src/createRollup.integration.test.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from 'vitest';
2-
import { createPublicClient, http, parseGwei, zeroAddress } from 'viem';
2+
import { Address, createPublicClient, http, parseGwei, zeroAddress } from 'viem';
33

44
import { nitroTestnodeL2 } from './chains';
55
import {
@@ -8,17 +8,32 @@ import {
88
getInformationFromTestnode,
99
} from './testHelpers';
1010
import { createRollupFetchTransactionHash } from './createRollupFetchTransactionHash';
11+
import { isAnvilIntegrationTestMode } from './integrationTestHelpers/injectedMode';
12+
import { getInitializedAnvilTestStackEnv } from './integrationTestHelpers/anvilHarness';
13+
import { PrivateKeyAccountWithPrivateKey } from './testHelpers';
14+
15+
const env = isAnvilIntegrationTestMode() ? getInitializedAnvilTestStackEnv() : undefined;
1116

1217
const parentChainPublicClient = createPublicClient({
13-
chain: nitroTestnodeL2,
18+
chain: env ? env.l2.chain : nitroTestnodeL2,
1419
transport: http(),
1520
});
1621

22+
let l3TokenBridgeDeployer: PrivateKeyAccountWithPrivateKey;
23+
let batchPosters: Address[];
24+
let validators: Address[];
25+
1726
// test inputs
18-
const testnodeAccounts = getNitroTestnodePrivateKeyAccounts();
19-
const l3TokenBridgeDeployer = testnodeAccounts.l3TokenBridgeDeployer;
20-
const batchPosters = [testnodeAccounts.deployer.address];
21-
const validators = [testnodeAccounts.deployer.address];
27+
if (env) {
28+
l3TokenBridgeDeployer = env.l3.accounts.tokenBridgeDeployer;
29+
batchPosters = [env.l2.accounts.deployer.address];
30+
validators = [env.l2.accounts.deployer.address];
31+
} else {
32+
const testnodeAccounts = getNitroTestnodePrivateKeyAccounts();
33+
l3TokenBridgeDeployer = testnodeAccounts.l3TokenBridgeDeployer;
34+
batchPosters = [testnodeAccounts.deployer.address];
35+
validators = [testnodeAccounts.deployer.address];
36+
}
2237

2338
describe(`create an AnyTrust chain that uses ETH as gas token`, async () => {
2439
const { createRollupConfig, createRollupInformation } = await createRollupHelper({
@@ -27,6 +42,8 @@ describe(`create an AnyTrust chain that uses ETH as gas token`, async () => {
2742
validators,
2843
nativeToken: zeroAddress,
2944
client: parentChainPublicClient,
45+
customParentTimingParams: env?.l2.timingParams,
46+
maxDataSize: env ? 104_857n : undefined,
3047
});
3148

3249
it(`successfully deploys core contracts through rollup creator`, async () => {
@@ -58,14 +75,16 @@ describe(`create an AnyTrust chain that uses ETH as gas token`, async () => {
5875
});
5976

6077
describe(`create an AnyTrust chain that uses a custom gas token`, async () => {
61-
const nativeToken = getInformationFromTestnode().l3NativeToken;
78+
const nativeToken = env ? env.l3.nativeToken : getInformationFromTestnode().l3NativeToken;
6279

6380
const { createRollupConfig, createRollupInformation } = await createRollupHelper({
6481
deployer: l3TokenBridgeDeployer,
6582
batchPosters,
6683
validators,
6784
nativeToken,
6885
client: parentChainPublicClient,
86+
customParentTimingParams: env?.l2.timingParams,
87+
maxDataSize: env ? 104_857n : undefined,
6988
});
7089

7190
it(`successfully deploys core contracts through rollup creator`, async () => {

0 commit comments

Comments
 (0)