From 8c0d9608ffd608ed3bafdd7a74861984c271a86e Mon Sep 17 00:00:00 2001 From: spsjvc Date: Wed, 9 Oct 2024 19:44:41 +0200 Subject: [PATCH] move stuff --- ...PrepareDeploymentParamsConfig.unit.test.ts | 2 +- ...llupPrepareTransactionRequest.unit.test.ts | 6 ++-- src/customChainsTestHelpers.ts | 35 ------------------- src/testHelpers.ts | 35 +++++++++++++++++-- .../getRollupCreatorAddress.unit.test.ts | 2 +- .../getTokenBridgeCreatorAddress.unit.test.ts | 2 +- src/validateParentChain.unit.test.ts | 2 +- 7 files changed, 41 insertions(+), 43 deletions(-) delete mode 100644 src/customChainsTestHelpers.ts diff --git a/src/createRollupPrepareDeploymentParamsConfig.unit.test.ts b/src/createRollupPrepareDeploymentParamsConfig.unit.test.ts index 112977ea..10ccca06 100644 --- a/src/createRollupPrepareDeploymentParamsConfig.unit.test.ts +++ b/src/createRollupPrepareDeploymentParamsConfig.unit.test.ts @@ -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'; diff --git a/src/createRollupPrepareTransactionRequest.unit.test.ts b/src/createRollupPrepareTransactionRequest.unit.test.ts index 172533d6..e026f580 100644 --- a/src/createRollupPrepareTransactionRequest.unit.test.ts +++ b/src/createRollupPrepareTransactionRequest.unit.test.ts @@ -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(); diff --git a/src/customChainsTestHelpers.ts b/src/customChainsTestHelpers.ts deleted file mode 100644 index 20c543c5..00000000 --- a/src/customChainsTestHelpers.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Chain } from 'viem'; -import { generatePrivateKey, privateKeyToAddress } from 'viem/accounts'; - -import { generateChainId } from './utils'; - -export function testHelper_createCustomParentChain(params?: { id?: number }) { - const chainId = params?.id ?? generateChainId(); - const rollupCreator = privateKeyToAddress(generatePrivateKey()); - const tokenBridgeCreator = privateKeyToAddress(generatePrivateKey()); - - 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; -} diff --git a/src/testHelpers.ts b/src/testHelpers.ts index eb8c3893..597bd5c9 100644 --- a/src/testHelpers.ts +++ b/src/testHelpers.ts @@ -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'; @@ -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; +} diff --git a/src/utils/getRollupCreatorAddress.unit.test.ts b/src/utils/getRollupCreatorAddress.unit.test.ts index 2e23ad21..1874c8b1 100644 --- a/src/utils/getRollupCreatorAddress.unit.test.ts +++ b/src/utils/getRollupCreatorAddress.unit.test.ts @@ -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({ diff --git a/src/utils/getTokenBridgeCreatorAddress.unit.test.ts b/src/utils/getTokenBridgeCreatorAddress.unit.test.ts index d6a423bf..82eb11ce 100644 --- a/src/utils/getTokenBridgeCreatorAddress.unit.test.ts +++ b/src/utils/getTokenBridgeCreatorAddress.unit.test.ts @@ -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({ diff --git a/src/validateParentChain.unit.test.ts b/src/validateParentChain.unit.test.ts index 52892f39..a579e936 100644 --- a/src/validateParentChain.unit.test.ts +++ b/src/validateParentChain.unit.test.ts @@ -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);