@@ -551,12 +551,26 @@ func chainSetupFromCompilations(fuzzer *Fuzzer, testChain *chain.TestChain) (*ex
551551 // Create a set of target contracts for easy lookup
552552 targetContracts := make (map [string ]bool )
553553 targetContractBalances := make (map [string ]* config.ContractBalance )
554+ targetContractInitFunctions := make (map [string ]string )
554555
555556 for i , name := range fuzzer .config .Fuzzing .TargetContracts {
556557 targetContracts [name ] = true
557558 if i < len (fuzzer .config .Fuzzing .TargetContractsBalances ) {
558559 targetContractBalances [name ] = fuzzer .config .Fuzzing .TargetContractsBalances [i ]
559560 }
561+
562+ // Map init functions by contract name
563+ if fuzzer .config .Fuzzing .UseInitFunctions {
564+ initFunction := "" // Default: no initialization
565+ if i < len (fuzzer .config .Fuzzing .TargetContractsInitFunctions ) && fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ] != "" {
566+ // Use explicit per-contract config
567+ initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ]
568+ } else if len (fuzzer .config .Fuzzing .TargetContractsInitFunctions ) == 1 {
569+ // If only one init function specified (like "setUp") apply it to all contracts
570+ initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [0 ]
571+ }
572+ targetContractInitFunctions [name ] = initFunction
573+ }
560574 }
561575 // Add contracts from the deployment order
562576 for _ , name := range fuzzer .deploymentOrder {
@@ -569,31 +583,37 @@ func chainSetupFromCompilations(fuzzer *Fuzzer, testChain *chain.TestChain) (*ex
569583 } else {
570584 balances = append (balances , & config.ContractBalance {Int : * big .NewInt (0 )})
571585 }
586+ // Add init function for target contracts, empty for libraries/predeployed
587+ if initFunc , ok := targetContractInitFunctions [name ]; ok {
588+ initFunctions = append (initFunctions , initFunc )
589+ } else {
590+ initFunctions = append (initFunctions , "" )
591+ }
572592 }
573593 }
574594 } else {
575595 contractsToDeploy = append (contractsToDeploy , fuzzer .config .Fuzzing .TargetContracts ... )
576596 balances = append (balances , fuzzer .config .Fuzzing .TargetContractsBalances ... )
577- }
578-
579- // Process target contracts init functions
580- targetContractsCount := len (fuzzer .config .Fuzzing .TargetContracts )
581- initConfigCount := len (fuzzer .config .Fuzzing .TargetContractsInitFunctions )
582597
583- // Add initialization functions for target contracts
584- for i := 0 ; i < targetContractsCount ; i ++ {
585- initFunction := "" // Default: no initialization
586-
587- if fuzzer .config .Fuzzing .UseInitFunctions {
588- if i < initConfigCount && fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ] != "" {
589- // Use explicit per-contract config
590- initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ]
591- } else if len (fuzzer .config .Fuzzing .TargetContractsInitFunctions ) == 1 {
592- // If only one init function specified (like "setUp") apply it to all contracts
593- initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [0 ]
598+ // Process target contracts init functions
599+ targetContractsCount := len (fuzzer .config .Fuzzing .TargetContracts )
600+ initConfigCount := len (fuzzer .config .Fuzzing .TargetContractsInitFunctions )
601+
602+ // Add initialization functions for target contracts
603+ for i := 0 ; i < targetContractsCount ; i ++ {
604+ initFunction := "" // Default: no initialization
605+
606+ if fuzzer .config .Fuzzing .UseInitFunctions {
607+ if i < initConfigCount && fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ] != "" {
608+ // Use explicit per-contract config
609+ initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [i ]
610+ } else if len (fuzzer .config .Fuzzing .TargetContractsInitFunctions ) == 1 {
611+ // If only one init function specified (like "setUp") apply it to all contracts
612+ initFunction = fuzzer .config .Fuzzing .TargetContractsInitFunctions [0 ]
613+ }
594614 }
615+ initFunctions = append (initFunctions , initFunction )
595616 }
596- initFunctions = append (initFunctions , initFunction )
597617 }
598618
599619 deployedContractAddr := make (map [string ]common.Address )
@@ -706,7 +726,7 @@ func chainSetupFromCompilations(fuzzer *Fuzzer, testChain *chain.TestChain) (*ex
706726 // Create and send the transaction
707727 destAddr := contractAddr
708728 msg := calls .NewCallMessage (fuzzer .deployer , & destAddr , 0 , big .NewInt (0 ),
709- fuzzer . config . Fuzzing . BlockGasLimit , nil , nil , nil , callData )
729+ blockGasLimit , nil , nil , nil , callData )
710730 msg .FillFromTestChainProperties (testChain )
711731
712732 // Debug log after creating the message
0 commit comments