Skip to content

Commit 50e6aae

Browse files
committed
test: use fixed accounts in the harness
1 parent 6cff42a commit 50e6aae

File tree

4 files changed

+1615
-17
lines changed

4 files changed

+1615
-17
lines changed

src/integrationTestHelpers/anvil-rpc-cache.json

Lines changed: 1596 additions & 0 deletions
Large diffs are not rendered by default.

src/integrationTestHelpers/anvilHarness.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,10 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
361361
const l1RpcUrlWithCaching = l1RpcCachingProxy.proxyUrl;
362362

363363
const harnessDeployer = createAccount(testConstants.DEPLOYER_PRIVATE_KEY);
364-
const l2BlockAdvancerAccount = createAccount();
365-
const l3BlockAdvancerAccount = createAccount();
366-
const batchPosterAccount = createAccount();
367-
const validatorAccount = createAccount();
364+
const l2BlockAdvancerAccount = createAccount(testConstants.L2_BLOCK_ADVANCER_PRIVATE_KEY);
365+
const l3BlockAdvancerAccount = createAccount(testConstants.L3_BLOCK_ADVANCER_PRIVATE_KEY);
366+
const batchPosterAccount = createAccount(testConstants.BATCH_POSTER_PRIVATE_KEY);
367+
const validatorAccount = createAccount(testConstants.VALIDATOR_PRIVATE_KEY);
368368

369369
// Starting L1 node (Anvil)
370370
l1ContainerName = `chain-sdk-int-test-l1-${Date.now()}`;

src/integrationTestHelpers/constants.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
import { Address } from 'viem';
1+
import { Hex } from 'viem';
22
import { ethers } from 'ethers';
33

44
export const testConstants = {
55
ANVIL_IMAGE: 'ghcr.io/foundry-rs/foundry:v1.3.1',
66
NITRO_IMAGE: 'offchainlabs/nitro-node:v3.9.5-66e42c4',
77
INT_TEST_CONTRACTS_IMAGE:
88
'ghcr.io/offchainlabs/chain-sdk-int-test-contracts:v3.2.0-2f747c7-v1.2.5-5975d8f73608',
9-
DEPLOYER_PRIVATE_KEY:
10-
'0x490d84b7602e4b470af4f86a3ad095607a8bb5a4fa8ba148f41fcfd236b4fdf5' as Address,
9+
DEPLOYER_PRIVATE_KEY: '0x490d84b7602e4b470af4f86a3ad095607a8bb5a4fa8ba148f41fcfd236b4fdf5' as Hex,
10+
L2_BLOCK_ADVANCER_PRIVATE_KEY:
11+
'0x1be2b93dfbeb7e7f7e9d8dc2b86d660ad12916f2f5234c89c5aa9e64c664d995' as Hex,
12+
L3_BLOCK_ADVANCER_PRIVATE_KEY:
13+
'0x5ae2006c037bd89ae1c7fa257e29758078354351ccdd7cc3c6841425d7d309da' as Hex,
14+
BATCH_POSTER_PRIVATE_KEY:
15+
'0x1317581cf78ace289eb730b715c4feca96ff4a60b1378273a8b46cece8bcf80d' as Hex,
16+
VALIDATOR_PRIVATE_KEY:
17+
'0x6d3ba9c3b5f1cef024c7965ee3854269b679ebc486876872582951ba25ffdea9' as Hex,
1118
L2_CHAIN_ID: 421_337,
1219
L3_CHAIN_ID: 421_338,
1320
L1_RPC_PORT: 9545,

src/integrationTestHelpers/rpcCachingProxy.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,28 +106,25 @@ function isCacheFile(value: unknown): value is CacheFile {
106106
);
107107
}
108108

109-
function loadCacheData(params: { cacheFilePath: string; metadata: CacheMetadata }): {
110-
cache: CacheData;
111-
cacheInvalidated: boolean;
112-
} {
109+
function loadCacheData(params: { cacheFilePath: string; metadata: CacheMetadata }): CacheData {
113110
const { cacheFilePath, metadata } = params;
114111

115112
if (!existsSync(cacheFilePath)) {
116113
writeCacheFile(cacheFilePath, { metadata, entries: {} });
117-
return { cache: {}, cacheInvalidated: false };
114+
return {};
118115
}
119116

120117
try {
121118
const parsed = JSON.parse(readFileSync(cacheFilePath, 'utf8')) as unknown;
122119
if (isCacheFile(parsed) && parsed.metadata.forkBlockNumber === metadata.forkBlockNumber) {
123-
return { cache: parsed.entries, cacheInvalidated: false };
120+
return parsed.entries;
124121
}
125122
} catch {
126123
// Reset invalid cache files below.
127124
}
128125

129126
writeCacheFile(cacheFilePath, { metadata, entries: {} });
130-
return { cache: {}, cacheInvalidated: true };
127+
return {};
131128
}
132129

133130
export async function startRpcCachingProxy(
@@ -137,10 +134,9 @@ export async function startRpcCachingProxy(
137134
): Promise<RpcCachingProxy> {
138135
mkdirSync(dirname(cacheFilePath), { recursive: true });
139136

140-
const { cache, cacheInvalidated } = loadCacheData({ cacheFilePath, metadata });
137+
const cache = loadCacheData({ cacheFilePath, metadata });
141138

142139
const stats = {
143-
cacheInvalidated,
144140
cacheHits: 0,
145141
cacheMisses: 0,
146142
requests: 0,
@@ -242,7 +238,6 @@ export async function startRpcCachingProxy(
242238
proxyUrl: `http://host.docker.internal:${address.port}`,
243239
getSummaryLines: () => [
244240
'RPC proxy cache summary',
245-
` invalidated on startup: ${stats.cacheInvalidated ? 'yes' : 'no'}`,
246241
` requests: ${stats.requests}`,
247242
` cache hits: ${stats.cacheHits}`,
248243
` cache misses: ${stats.cacheMisses}`,

0 commit comments

Comments
 (0)