11import { execFile , execFileSync } from 'node:child_process' ;
2- import { mkdtempSync , rmSync } from 'node:fs' ;
3- import { tmpdir } from 'node:os' ;
2+ import { rmSync } from 'node:fs' ;
43import { join } from 'node:path' ;
54
65import { createPublicClient , http } from 'viem' ;
76
87import { testConstants } from './constants' ;
98
10- const cachedNitroContractsImageByTag : Record < string , string > = { } ;
11-
129function sleep ( ms : number ) {
1310 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
1411}
@@ -47,43 +44,19 @@ export function getNitroContractsImage(): string {
4744 const imageTag = `chain-sdk-nitro-contracts:${ sanitizeDockerTagPart (
4845 testConstants . DEFAULT_NITRO_CONTRACTS_REF ,
4946 ) } `;
50- const cachedImage = cachedNitroContractsImageByTag [ imageTag ] ;
51- if ( cachedImage ) {
52- return cachedImage ;
53- }
5447
5548 try {
5649 docker ( [ 'image' , 'inspect' , imageTag ] ) ;
5750 } catch {
58- const tempDir = mkdtempSync ( join ( tmpdir ( ) , 'chain-sdk-nitro-contracts-' ) ) ;
59- const repoDir = join ( tempDir , 'repo' ) ;
51+ const nitroContractsDir = join ( process . cwd ( ) , 'nitro-contracts' ) ;
6052 const dockerfilePath = join ( process . cwd ( ) , 'nitro-contracts' , 'Dockerfile' ) ;
61-
62- try {
63- runCommand ( 'git' , [
64- 'clone' ,
65- '--recurse-submodules' ,
66- '--shallow-submodules' ,
67- '--depth' ,
68- '1' ,
69- '--branch' ,
70- testConstants . DEFAULT_NITRO_CONTRACTS_BRANCH ,
71- '--single-branch' ,
72- testConstants . DEFAULT_NITRO_CONTRACTS_REPO_URL ,
73- repoDir ,
74- ] ) ;
75-
76- docker ( [ 'build' , '-f' , dockerfilePath , '-t' , imageTag , repoDir ] ) ;
77- } finally {
78- rmSync ( tempDir , { recursive : true , force : true } ) ;
79- }
53+ docker ( [ 'build' , '-f' , dockerfilePath , '-t' , imageTag , nitroContractsDir ] ) ;
8054 }
8155
82- cachedNitroContractsImageByTag [ imageTag ] = imageTag ;
8356 return imageTag ;
8457}
8558
86- export function createSourceDockerNetwork ( networkName : string ) {
59+ export function createDockerNetwork ( networkName : string ) {
8760 docker ( [ 'network' , 'create' , networkName ] ) ;
8861}
8962
@@ -133,7 +106,9 @@ export async function waitForRpc(params: {
133106 if ( Date . now ( ) >= deadline ) {
134107 const containerContext =
135108 failIfContainerExited && getContainerStatus ( failIfContainerExited )
136- ? ` (container ${ failIfContainerExited } status: ${ getContainerStatus ( failIfContainerExited ) } )`
109+ ? ` (container ${ failIfContainerExited } status: ${ getContainerStatus (
110+ failIfContainerExited ,
111+ ) } )`
137112 : '' ;
138113 const logs =
139114 failIfContainerExited && getContainerStatus ( failIfContainerExited ) !== 'running'
@@ -235,7 +210,7 @@ export function cleanupStaleHarnessNetworks() {
235210 }
236211}
237212
238- export function startSourceL1AnvilContainer ( params : {
213+ export function startL1AnvilContainer ( params : {
239214 containerName : string ;
240215 networkName : string ;
241216 l1RpcPort : number ;
@@ -273,7 +248,7 @@ export function startSourceL1AnvilContainer(params: {
273248 ] ) ;
274249}
275250
276- export function startSourceL2NitroContainer ( params : {
251+ export function startL2NitroContainer ( params : {
277252 containerName : string ;
278253 networkName : string ;
279254 l2RpcPort : number ;
@@ -293,7 +268,7 @@ export function startSourceL2NitroContainer(params: {
293268 `${ params . runtimeDir } :/runtime` ,
294269 params . nitroImage ,
295270 '--conf.file' ,
296- '/runtime/source- l2-node-config.json' ,
271+ '/runtime/l2-node-config.json' ,
297272 '--persistent.chain' ,
298273 '/runtime/nitro-data' ,
299274 '--ensure-rollup-deployment=false' ,
0 commit comments