Skip to content

Commit 9ff0ea7

Browse files
committed
test: update createRollup test to anvil
1 parent fcea011 commit 9ff0ea7

File tree

5 files changed

+82
-8
lines changed

5 files changed

+82
-8
lines changed

.github/workflows/build-test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,36 @@ jobs:
222222
INTEGRATION_TEST_DECIMALS=${{matrix.config.decimals}} \
223223
INTEGRATION_TEST_NITRO_CONTRACTS_BRANCH=${{matrix.config.nitro-contracts-branch}} \
224224
pnpm test:integration
225+
226+
test-integration-anvil:
227+
name: Test (Integration Anvil)
228+
runs-on: ubuntu-latest
229+
steps:
230+
- name: Checkout
231+
uses: actions/checkout@v4
232+
233+
- name: Setup pnpm
234+
uses: pnpm/action-setup@v4
235+
with:
236+
version: 10.30.3
237+
run_install: false
238+
239+
- name: Setup Node.js
240+
uses: actions/setup-node@v4
241+
with:
242+
node-version-file: .nvmrc
243+
244+
- name: Install node_modules
245+
uses: OffchainLabs/actions/node-modules/install@main
246+
with:
247+
install-command: pnpm install --frozen-lockfile
248+
cache-key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
249+
250+
- name: Copy .env
251+
run: cp ./.env.example ./.env
252+
253+
- name: Build
254+
run: pnpm build
255+
256+
- name: Test
257+
run: pnpm test:integration:anvil

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test:type": "vitest --config vitest.type.config.ts",
1313
"test:unit": "vitest --config vitest.unit.config.ts",
1414
"test:integration": "vitest --config vitest.integration.config.ts",
15+
"test:integration:anvil": "vitest --run --config vitest.integration.anvil.config.ts",
1516
"postinstall": "patch-package",
1617
"lint": "eslint . --cache",
1718
"lint:fix": "eslint . --fix --cache",

src/createRollup.integration.test.ts

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

44
import { nitroTestnodeL2 } from './chains';
55
import {
66
createRollupHelper,
77
getNitroTestnodePrivateKeyAccounts,
88
getInformationFromTestnode,
9+
type PrivateKeyAccountWithPrivateKey,
910
} from './testHelpers';
1011
import { createRollupFetchTransactionHash } from './createRollupFetchTransactionHash';
12+
import { getInitializedAnvilTestStackEnv } from './integrationTestHelpers/anvilHarness';
13+
import { isAnvilIntegrationTestMode } from './integrationTestHelpers/injectedMode';
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

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

2337
describe(`create an AnyTrust chain that uses ETH as gas token`, async () => {
2438
const { createRollupConfig, createRollupInformation } = await createRollupHelper({
@@ -27,6 +41,8 @@ describe(`create an AnyTrust chain that uses ETH as gas token`, async () => {
2741
validators,
2842
nativeToken: zeroAddress,
2943
client: parentChainPublicClient,
44+
customParentTimingParams: env?.l2.timingParams,
45+
maxDataSize: env ? 104_857n : undefined,
3046
});
3147

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

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

6379
const { createRollupConfig, createRollupInformation } = await createRollupHelper({
6480
deployer: l3TokenBridgeDeployer,
6581
batchPosters,
6682
validators,
6783
nativeToken,
6884
client: parentChainPublicClient,
85+
customParentTimingParams: env?.l2.timingParams,
86+
maxDataSize: env ? 104_857n : undefined,
6987
});
7088

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

vitest.integration.anvil.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { configDefaults, defineConfig, mergeConfig } from 'vitest/config';
2+
import commonConfig from './vitest.common';
3+
4+
export default mergeConfig(
5+
commonConfig,
6+
defineConfig({
7+
test: {
8+
provide: {
9+
integrationTestMode: 'anvil',
10+
},
11+
// The Anvil stack boots a forked L1 and dockerized Nitro L2 in-process.
12+
testTimeout: 45 * 60 * 1000,
13+
setupFiles: ['./src/integrationTestHelpers/globalSetup.mjs'],
14+
exclude: [...configDefaults.exclude],
15+
include: ['./src/createRollup.integration.test.ts'],
16+
fileParallelism: false,
17+
},
18+
}),
19+
);

vitest.integration.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export default mergeConfig(
55
commonConfig,
66
defineConfig({
77
test: {
8+
provide: {
9+
integrationTestMode: 'testnode',
10+
},
811
// allow tests to run for 7 minutes as retryables can take a while
912
testTimeout: 7 * 60 * 1000,
1013
exclude: [...configDefaults.exclude, './src/**/*.unit.test.ts'],

0 commit comments

Comments
 (0)