Skip to content

Commit c21fb80

Browse files
committed
test: debug
1 parent 6ed9caf commit c21fb80

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/integrationTestHelpers/anvilHarness.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mkdtempSync, writeFileSync } from 'node:fs';
1+
import { chmodSync, mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
22
import { tmpdir } from 'node:os';
33
import { join } from 'node:path';
44

@@ -77,6 +77,12 @@ let cleanupHookRegistered = false;
7777
let teardownStarted = false;
7878
let l1RpcCachingProxy: RpcCachingProxy | undefined;
7979

80+
function prepareNitroRuntimeDir(runtimeDir: string) {
81+
chmodSync(runtimeDir, 0o777);
82+
mkdirSync(join(runtimeDir, 'nitro-data'), { recursive: true, mode: 0o777 });
83+
chmodSync(join(runtimeDir, 'nitro-data'), 0o777);
84+
}
85+
8086
export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
8187
if (envPromise) {
8288
return envPromise;
@@ -97,6 +103,7 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
97103
cleanupStaleHarnessNetworks();
98104

99105
runtimeDir = mkdtempSync(join(tmpdir(), 'chain-sdk-int-test'));
106+
prepareNitroRuntimeDir(runtimeDir);
100107
dockerNetworkName = `chain-sdk-int-test-net-${Date.now()}`;
101108
createSourceDockerNetwork(dockerNetworkName);
102109

@@ -221,7 +228,7 @@ export async function setupAnvilTestStack(): Promise<AnvilTestStack> {
221228
l2NodeConfig.node!['batch-poster']!.enable = false;
222229
l2NodeConfig.node!.staker!.enable = false;
223230
const nodeConfigPath = join(runtimeDir, 'source-l2-node-config.json');
224-
writeFileSync(nodeConfigPath, JSON.stringify(l2NodeConfig, null, 2));
231+
writeFileSync(nodeConfigPath, JSON.stringify(l2NodeConfig, null, 2), { mode: 0o644 });
225232

226233
// Starting L2 node (Nitro)
227234
console.log('Starting L2 Nitro node...');

src/integrationTestHelpers/rpcCachingProxy.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { once } from 'node:events';
12
import { createServer, IncomingHttpHeaders } from 'node:http';
23
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
34
import { dirname } from 'node:path';
@@ -220,10 +221,17 @@ export async function startRpcCachingProxy(
220221
}
221222
});
222223

223-
server.listen(8449, '0.0.0.0');
224+
server.listen(0, '0.0.0.0');
225+
await once(server, 'listening');
226+
227+
const address = server.address();
228+
if (!address || typeof address === 'string') {
229+
server.close();
230+
throw new Error('RPC caching proxy failed to resolve a listening TCP port.');
231+
}
224232

225233
return {
226-
proxyUrl: `http://host.docker.internal:8449`,
234+
proxyUrl: `http://host.docker.internal:${address.port}`,
227235
getSummaryLines: () => [
228236
'RPC proxy cache summary',
229237
` invalidated on startup: ${stats.cacheInvalidated ? 'yes' : 'no'}`,

0 commit comments

Comments
 (0)