88 type BesuGenesisService ,
99} from "../genesis/besu-genesis.service.ts" ;
1010import {
11- __testing as genesisTesting ,
1211 type HexAddress ,
1312 type PromptOverrides ,
1413 promptForGenesisConfig ,
@@ -24,6 +23,9 @@ const SECOND_CHAIN_ID = 1;
2423const SECOND_BLOCK_TIME = 2 ;
2524const EVM_STACK_SIZE = 4096 ;
2625const CONTRACT_SIZE_LIMIT = 10_000 ;
26+ const NEGATIVE_PRESET_INT = - 1 ;
27+ const NEGATIVE_BIG_VALUE = "-1" ;
28+ const NON_NUMERIC_BIG_VALUE = "not-a-number" ;
2729
2830const withCancel = < T > ( value : T ) => {
2931 const promise = Promise . resolve ( value ) as Promise < T > & { cancel : ( ) => void } ;
@@ -250,12 +252,12 @@ describe("promptForGenesisConfig", () => {
250252 faucetAddress : faucet ,
251253 preset : {
252254 algorithm : ALGORITHM . IBFTv2 ,
253- chainId : - 1 ,
254- secondsPerBlock : - 2 ,
255- gasLimit : "-5" ,
256- gasPrice : - 1 ,
257- evmStackSize : - 3 ,
258- contractSizeLimit : - 4 ,
255+ chainId : NEGATIVE_PRESET_INT ,
256+ secondsPerBlock : NEGATIVE_PRESET_INT ,
257+ gasLimit : NEGATIVE_BIG_VALUE ,
258+ gasPrice : NEGATIVE_PRESET_INT ,
259+ evmStackSize : NEGATIVE_PRESET_INT ,
260+ contractSizeLimit : NEGATIVE_PRESET_INT ,
259261 } ,
260262 validatorAddresses : validators ,
261263 } )
@@ -273,7 +275,7 @@ describe("promptForGenesisConfig", () => {
273275 chainId : 1 ,
274276 secondsPerBlock : 1 ,
275277 gasLimit : "1000" ,
276- gasPrice : - 1 ,
278+ gasPrice : NEGATIVE_PRESET_INT ,
277279 evmStackSize : 2048 ,
278280 contractSizeLimit : 100_000 ,
279281 } ,
@@ -312,7 +314,7 @@ describe("promptForGenesisConfig", () => {
312314 algorithm : ALGORITHM . IBFTv2 ,
313315 chainId : 1 ,
314316 secondsPerBlock : 1 ,
315- gasLimit : "not-a-number" ,
317+ gasLimit : NON_NUMERIC_BIG_VALUE ,
316318 gasPrice : 0 ,
317319 evmStackSize : 2048 ,
318320 contractSizeLimit : 100_000 ,
@@ -321,23 +323,4 @@ describe("promptForGenesisConfig", () => {
321323 } )
322324 ) . rejects . toThrow ( "Gas limit must be a positive integer." ) ;
323325 } ) ;
324-
325- test ( "ensure helpers validate preset values" , ( ) => {
326- expect ( genesisTesting . ensurePositiveInteger ( 5 , "Value" ) ) . toBe ( 5 ) ;
327- expect ( genesisTesting . ensureNonNegativeInteger ( 0 , "Zero" ) ) . toBe ( 0 ) ;
328- expect ( genesisTesting . ensurePositiveBigIntString ( "100" , "Big" ) ) . toBe ( "100" ) ;
329-
330- expect ( ( ) => genesisTesting . ensurePositiveInteger ( 0 , "Value" ) ) . toThrow (
331- "Value must be a positive integer."
332- ) ;
333- expect ( ( ) => genesisTesting . ensureNonNegativeInteger ( - 1 , "Zero" ) ) . toThrow (
334- "Zero must be a non-negative integer."
335- ) ;
336- expect ( ( ) => genesisTesting . ensurePositiveBigIntString ( "0" , "Big" ) ) . toThrow (
337- "Big must be a positive integer."
338- ) ;
339- expect ( ( ) =>
340- genesisTesting . ensurePositiveBigIntString ( "bad" , "Big" )
341- ) . toThrow ( "Big must be a positive integer." ) ;
342- } ) ;
343326} ) ;
0 commit comments