@@ -136,6 +136,7 @@ describe("CLI command bootstrap", () => {
136136 const promptCalls : [ string , number | undefined , number ] [ ] = [ ] ;
137137 const textPromptCalls : [ string , string ] [ ] = [ ] ;
138138 let loadAllocationsPath : string | undefined ;
139+ let loadAbisPath : string | undefined ;
139140 let outputInvocation :
140141 | {
141142 type : OutputType ;
@@ -199,6 +200,10 @@ describe("CLI command bootstrap", () => {
199200 [ expectedAddress ( FAUCET_INDEX ) ] : { balance : "0x01" as const } ,
200201 } satisfies Record < string , BesuAllocAccount > ) ;
201202 } ,
203+ loadAbis : ( path : string ) => {
204+ loadAbisPath = path ;
205+ return Promise . resolve ( [ ] ) ;
206+ } ,
202207 outputResult : async ( type , payload ) => {
203208 outputInvocation = { type, payload } ;
204209 await realOutputResult ( type , payload ) ;
@@ -225,11 +230,13 @@ describe("CLI command bootstrap", () => {
225230 expect ( output ) . toContain ( "Static Nodes" ) ;
226231 expect ( output ) . toContain ( GENESIS_MARKER ) ;
227232 expect ( loadAllocationsPath ) . toBe ( "/tmp/alloc.json" ) ;
233+ expect ( loadAbisPath ) . toBeUndefined ( ) ;
228234 expect ( outputInvocation ?. type ) . toBe ( "screen" ) ;
229235 expect ( outputInvocation ?. payload . staticNodes ) . toEqual ( [
230236 expectedStaticNodeUri ( FIRST_VALIDATOR_INDEX ) ,
231237 expectedStaticNodeUri ( SECOND_VALIDATOR_INDEX ) ,
232238 ] ) ;
239+ expect ( outputInvocation ?. payload . abiArtifacts ) . toEqual ( [ ] ) ;
233240 expect ( outputInvocation ?. payload . artifactNames ) . toEqual ( {
234241 faucetPrefix : DEFAULT_FAUCET_PREFIX ,
235242 validatorPrefix : DEFAULT_POD_PREFIX ,
@@ -238,6 +245,57 @@ describe("CLI command bootstrap", () => {
238245 } ) ;
239246 } ) ;
240247
248+ test ( "runBootstrap loads ABI artifacts when directory provided" , async ( ) => {
249+ const factory = createFactoryStub ( ) ;
250+ const abiArtifacts = [
251+ {
252+ configMapName : "abi-demo" ,
253+ fileName : "Demo.json" ,
254+ contents : `${ JSON . stringify ( { name : "Demo" } , null , 2 ) } \n` ,
255+ } ,
256+ ] ;
257+ let capturedPayload : OutputPayload | undefined ;
258+ let capturedAbiPath : string | undefined ;
259+
260+ const deps : BootstrapDependencies = {
261+ factory,
262+ promptForCount : ( ) => Promise . resolve ( EXPECTED_DEFAULT_VALIDATOR ) ,
263+ promptForGenesis : async ( _service , { faucetAddress } ) => ( {
264+ algorithm : ALGORITHM . QBFT ,
265+ config : {
266+ chainId : 1 ,
267+ faucetWalletAddress : faucetAddress ,
268+ gasLimit : "0x1" ,
269+ secondsPerBlock : 2 ,
270+ } ,
271+ genesis : { config : { } , extraData : "0x" } as any ,
272+ } ) ,
273+ promptForText : passthroughTextPrompt ,
274+ service : { } as any ,
275+ loadAllocations : ( ) =>
276+ Promise . resolve ( { } as Record < string , BesuAllocAccount > ) ,
277+ loadAbis : ( path : string ) => {
278+ capturedAbiPath = path ;
279+ return Promise . resolve ( abiArtifacts ) ;
280+ } ,
281+ outputResult : ( _type , payload ) => {
282+ capturedPayload = payload ;
283+ return Promise . resolve ( ) ;
284+ } ,
285+ } ;
286+
287+ await runBootstrap (
288+ {
289+ abiDirectory : " /opt/abis " ,
290+ acceptDefaults : true ,
291+ } ,
292+ deps
293+ ) ;
294+
295+ expect ( capturedAbiPath ) . toBe ( "/opt/abis" ) ;
296+ expect ( capturedPayload ?. abiArtifacts ) . toEqual ( abiArtifacts ) ;
297+ } ) ;
298+
241299 test ( "createCliCommand wires metadata" , ( ) => {
242300 const command = createCliCommand ( ) ;
243301 expect ( command . name ( ) ) . toBe ( "network-bootstrapper" ) ;
@@ -278,6 +336,7 @@ describe("CLI command bootstrap", () => {
278336 service : { } as any ,
279337 loadAllocations : ( ) =>
280338 Promise . resolve ( { } satisfies Record < string , BesuAllocAccount > ) ,
339+ loadAbis : ( ) => Promise . resolve ( [ ] ) ,
281340 outputResult : async ( type , payload ) => {
282341 await realOutputResult ( type , payload ) ;
283342 } ,
@@ -345,6 +404,7 @@ describe("CLI command bootstrap", () => {
345404 service : { } as any ,
346405 loadAllocations : ( ) =>
347406 Promise . resolve ( { } satisfies Record < string , BesuAllocAccount > ) ,
407+ loadAbis : ( ) => Promise . resolve ( [ ] ) ,
348408 outputResult : ( _type , payload ) => {
349409 capturedPayload = payload ;
350410 return Promise . resolve ( ) ;
@@ -426,6 +486,7 @@ describe("CLI command bootstrap", () => {
426486 service : { } as any ,
427487 loadAllocations : ( ) =>
428488 Promise . resolve ( { } satisfies Record < string , BesuAllocAccount > ) ,
489+ loadAbis : ( ) => Promise . resolve ( [ ] ) ,
429490 outputResult : ( _type , payload ) => {
430491 capturedPayload = payload ;
431492 return Promise . resolve ( ) ;
@@ -494,6 +555,7 @@ describe("CLI command bootstrap", () => {
494555 service : { } as any ,
495556 loadAllocations : ( ) =>
496557 Promise . resolve ( { } satisfies Record < string , BesuAllocAccount > ) ,
558+ loadAbis : ( ) => Promise . resolve ( [ ] ) ,
497559 outputResult : async ( ) => {
498560 // no-op for test
499561 } ,
@@ -576,6 +638,7 @@ describe("CLI command bootstrap", () => {
576638 service : { } as any ,
577639 loadAllocations : ( ) =>
578640 Promise . resolve ( { } satisfies Record < string , BesuAllocAccount > ) ,
641+ loadAbis : ( ) => Promise . resolve ( [ ] ) ,
579642 outputResult : ( type ) => {
580643 capturedOutputType = type ;
581644 return Promise . resolve ( ) ;
@@ -624,6 +687,7 @@ describe("CLI command bootstrap", () => {
624687 const factory = createFactoryStub ( ) ;
625688 let promptCountInvocations = 0 ;
626689 let loadAllocationsInvoked = false ;
690+ let loadAbisInvoked = false ;
627691
628692 const deps : BootstrapDependencies = {
629693 factory,
@@ -662,6 +726,10 @@ describe("CLI command bootstrap", () => {
662726 loadAllocationsInvoked = true ;
663727 return Promise . resolve ( { } as Record < string , BesuAllocAccount > ) ;
664728 } ,
729+ loadAbis : ( ) => {
730+ loadAbisInvoked = true ;
731+ return Promise . resolve ( [ ] ) ;
732+ } ,
665733 outputResult : ( _type , payload ) => {
666734 expect ( payload . validators ) . toHaveLength ( EXPECTED_DEFAULT_VALIDATOR ) ;
667735 expect ( payload . artifactNames ) . toEqual ( {
@@ -683,5 +751,6 @@ describe("CLI command bootstrap", () => {
683751
684752 expect ( promptCountInvocations ) . toBe ( 0 ) ;
685753 expect ( loadAllocationsInvoked ) . toBe ( false ) ;
754+ expect ( loadAbisInvoked ) . toBe ( false ) ;
686755 } ) ;
687756} ) ;
0 commit comments