Skip to content

Commit

Permalink
refactor: move overrides for test to function (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored May 30, 2024
1 parent a7fd6ce commit 8b4bc71
Showing 1 changed file with 35 additions and 47 deletions.
82 changes: 35 additions & 47 deletions src/createRollupPrepareDeploymentParamsConfig.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { it, expect } from 'vitest';
import { createPublicClient, http } from 'viem';
import { Address, createPublicClient, http } from 'viem';

import { arbitrumOne, arbitrumSepolia } from './chains';
import { prepareChainConfig } from './prepareChainConfig';
Expand All @@ -8,6 +8,32 @@ import { createRollupPrepareDeploymentParamsConfig } from './createRollupPrepare
const chainId = 69_420n;
const vitalik: `0x${string}` = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';

function getOverrides({ owner, chainId }: { owner: Address; chainId: bigint }) {
return {
owner,
chainId,
chainConfig: prepareChainConfig({
chainId: Number(chainId),
arbitrum: {
InitialChainOwner: owner,
InitialArbOSVersion: 30,
DataAvailabilityCommittee: true,
},
}),
confirmPeriodBlocks: 4200n,
extraChallengeTimeBlocks: 5n,
loserStakeEscrow: '0x0000000000000000000000000000000000000001',
sequencerInboxMaxTimeVariation: {
delayBlocks: 200n,
delaySeconds: 5n,
futureBlocks: 100n,
futureSeconds: 1n,
},
stakeToken: '0x0000000000000000000000000000000000000002',
wasmModuleRoot: '0xWasmModuleRoot',
} as const;
}

it('creates config for a chain on top of arbitrum one with defaults', () => {
const arbitrumOneClient = createPublicClient({
chain: arbitrumOne,
Expand All @@ -29,29 +55,10 @@ it('creates config for a chain on top of arbitrum one with overrides', () => {
});

expect(
createRollupPrepareDeploymentParamsConfig(arbitrumOneClient, {
owner: vitalik,
chainId,
chainConfig: prepareChainConfig({
chainId: 69_420,
arbitrum: {
InitialChainOwner: vitalik,
InitialArbOSVersion: 30,
DataAvailabilityCommittee: true,
},
}),
confirmPeriodBlocks: 4200n,
extraChallengeTimeBlocks: 5n,
loserStakeEscrow: '0x0000000000000000000000000000000000000001',
sequencerInboxMaxTimeVariation: {
delayBlocks: 200n,
delaySeconds: 5n,
futureBlocks: 100n,
futureSeconds: 1n,
},
stakeToken: '0x0000000000000000000000000000000000000002',
wasmModuleRoot: '0xWasmModuleRoot',
}),
createRollupPrepareDeploymentParamsConfig(
arbitrumOneClient,
getOverrides({ owner: vitalik, chainId }),
),
).toMatchSnapshot();
});

Expand All @@ -76,28 +83,9 @@ it('creates config for a chain on top of arbitrum sepolia with overrides', () =>
});

expect(
createRollupPrepareDeploymentParamsConfig(arbitrumSepoliaClient, {
owner: vitalik,
chainId,
chainConfig: prepareChainConfig({
chainId: 69_420,
arbitrum: {
InitialChainOwner: vitalik,
InitialArbOSVersion: 30,
DataAvailabilityCommittee: true,
},
}),
confirmPeriodBlocks: 4200n,
extraChallengeTimeBlocks: 5n,
loserStakeEscrow: '0x0000000000000000000000000000000000000001',
sequencerInboxMaxTimeVariation: {
delayBlocks: 200n,
delaySeconds: 5n,
futureBlocks: 100n,
futureSeconds: 1n,
},
stakeToken: '0x0000000000000000000000000000000000000002',
wasmModuleRoot: '0xWasmModuleRoot',
}),
createRollupPrepareDeploymentParamsConfig(
arbitrumSepoliaClient,
getOverrides({ owner: vitalik, chainId }),
),
).toMatchSnapshot();
});

0 comments on commit 8b4bc71

Please sign in to comment.