Skip to content

Commit

Permalink
move stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc committed Oct 9, 2024
1 parent 68c7899 commit 8c0d960
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/createRollupPrepareDeploymentParamsConfig.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { prepareChainConfig } from './prepareChainConfig';
import { createRollupPrepareDeploymentParamsConfig } from './createRollupPrepareDeploymentParamsConfig';

import { testHelper_createCustomParentChain } from './customChainsTestHelpers';
import { testHelper_createCustomParentChain } from './testHelpers';

const chainId = 69_420n;
const vitalik: `0x${string}` = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';
Expand Down
6 changes: 4 additions & 2 deletions src/createRollupPrepareTransactionRequest.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { createRollupPrepareDeploymentParamsConfig } from './createRollupPrepare
import { createRollupPrepareTransactionRequest } from './createRollupPrepareTransactionRequest';
import { rollupCreatorAddress } from './contracts/RollupCreator';

import { getNitroTestnodePrivateKeyAccounts } from './testHelpers';
import {
getNitroTestnodePrivateKeyAccounts,
testHelper_createCustomParentChain,
} from './testHelpers';
import { registerCustomParentChain } from './chains';
import { testHelper_createCustomParentChain } from './customChainsTestHelpers';
import { getConsensusReleaseByVersion } from './wasmModuleRoot';

const testnodeAccounts = getNitroTestnodePrivateKeyAccounts();
Expand Down
35 changes: 0 additions & 35 deletions src/customChainsTestHelpers.ts

This file was deleted.

35 changes: 33 additions & 2 deletions src/testHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, Client, PublicClient, zeroAddress } from 'viem';
import { privateKeyToAccount, PrivateKeyAccount } from 'viem/accounts';
import { Address, Chain, PublicClient, zeroAddress } from 'viem';
import { PrivateKeyAccount, privateKeyToAccount, generatePrivateKey } from 'viem/accounts';
import { config } from 'dotenv';
import { execSync } from 'node:child_process';

Expand Down Expand Up @@ -179,3 +179,34 @@ export async function createRollupHelper({
createRollupInformation,
};
}

export function testHelper_createCustomParentChain(params?: { id?: number }) {
const chainId = params?.id ?? generateChainId();
const rollupCreator = privateKeyToAccount(generatePrivateKey()).address;
const tokenBridgeCreator = privateKeyToAccount(generatePrivateKey()).address;

return {
id: chainId,
name: `Custom Parent Chain (${chainId})`,
network: `custom-parent-chain-${chainId}`,
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: {
public: {
// have to put a valid rpc here so using arbitrum sepolia
http: ['https://sepolia-rollup.arbitrum.io/rpc'],
},
default: {
// have to put a valid rpc here so using arbitrum sepolia
http: ['https://sepolia-rollup.arbitrum.io/rpc'],
},
},
contracts: {
rollupCreator: { address: rollupCreator },
tokenBridgeCreator: { address: tokenBridgeCreator },
},
} satisfies Chain;
}
2 changes: 1 addition & 1 deletion src/utils/getRollupCreatorAddress.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sepolia } from 'viem/chains';
import { getRollupCreatorAddress } from './getRollupCreatorAddress';
import { registerCustomParentChain } from '../chains';

import { testHelper_createCustomParentChain } from '../customChainsTestHelpers';
import { testHelper_createCustomParentChain } from '../testHelpers';

it(`successfully returns address for Sepolia`, () => {
const client = createPublicClient({
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getTokenBridgeCreatorAddress.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sepolia } from 'viem/chains';
import { getTokenBridgeCreatorAddress } from './getTokenBridgeCreatorAddress';
import { registerCustomParentChain } from '../chains';

import { testHelper_createCustomParentChain } from '../customChainsTestHelpers';
import { testHelper_createCustomParentChain } from '../testHelpers';

it(`successfully returns address for Sepolia`, () => {
const client = createPublicClient({
Expand Down
2 changes: 1 addition & 1 deletion src/validateParentChain.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { validateParentChain } from './types/ParentChain';
import { arbitrumOne, registerCustomParentChain } from './chains';
import { generateChainId } from './utils';

import { testHelper_createCustomParentChain } from './customChainsTestHelpers';
import { testHelper_createCustomParentChain } from './testHelpers';

it(`sucessfully validates arbitrum one`, () => {
const result = validateParentChain(arbitrumOne.id);
Expand Down

0 comments on commit 8c0d960

Please sign in to comment.