github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/networks/network_config_helpers.go (about) 1 package networks 2 3 import ( 4 "fmt" 5 6 "github.com/smartcontractkit/chainlink-testing-framework/libs/blockchain" 7 "github.com/smartcontractkit/chainlink-testing-framework/libs/config" 8 ) 9 10 const ( 11 pyroscopeTOML = `[Pyroscope] 12 ServerAddress = '%s' 13 Environment = '%s'` 14 //nolint:gosec //ignoring G101 15 secretTOML = ` 16 [Mercury.Credentials.cred1] 17 URL = '%s' 18 Username = '%s' 19 Password = '%s' 20 ` 21 ) 22 23 // AddNetworksConfig adds EVM network configurations to a base config TOML. Useful for adding networks with default 24 // settings. See AddNetworkDetailedConfig for adding more detailed network configuration. 25 func AddNetworksConfig(baseTOML string, pyroscopeConfig *config.PyroscopeConfig, networks ...blockchain.EVMNetwork) string { 26 networksToml := "" 27 for _, network := range networks { 28 networksToml = fmt.Sprintf("%s\n\n%s", networksToml, network.MustChainlinkTOML("")) 29 } 30 return fmt.Sprintf("%s\n\n%s\n\n%s", baseTOML, pyroscopeSettings(pyroscopeConfig), networksToml) 31 } 32 33 func AddSecretTomlConfig(url, username, password string) string { 34 return fmt.Sprintf(secretTOML, url, username, password) 35 } 36 37 // AddNetworkDetailedConfig adds EVM config to a base TOML. Also takes a detailed network config TOML where values like 38 // using transaction forwarders can be included. 39 // See https://github.com/smartcontractkit/chainlink/blob/develop/docs/CONFIG.md#EVM 40 func AddNetworkDetailedConfig(baseTOML string, pyroscopeConfig *config.PyroscopeConfig, detailedNetworkConfig string, network blockchain.EVMNetwork) string { 41 return fmt.Sprintf("%s\n\n%s\n\n%s", baseTOML, pyroscopeSettings(pyroscopeConfig), network.MustChainlinkTOML(detailedNetworkConfig)) 42 } 43 44 func pyroscopeSettings(config *config.PyroscopeConfig) string { 45 if config == nil || config.Enabled == nil || !*config.Enabled { 46 return "" 47 } 48 return fmt.Sprintf(pyroscopeTOML, *config.ServerUrl, *config.Environment) 49 }