-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CORE-813] - Add pricefeed config tomls back into the repository (#863)
This restores configurability to the pricefeed daemon while we wait to refactor configs for the daemon.
- v6.0.4-rc2
- v6.0.4-rc1
- v6.0.4-rc0
- v5.2.4-rc0
- v5.0.0-dev0
- release/protocol/v7.0.0
- release/protocol/v7.0.0-dev3
- release/indexer/v7.0.0-dev3
- protocol/v8.0.7
- protocol/v8.0.6
- protocol/v8.0.6-rc0
- protocol/v8.0.5
- protocol/v8.0.4
- protocol/v8.0.3
- protocol/v8.0.2
- protocol/v8.0.1
- protocol/v8.0.1-rc0
- protocol/v8.0.0-rc1
- protocol/v8.0.0-rc0
- protocol/v7.0.5
- protocol/v7.0.4
- protocol/v7.0.3
- protocol/v7.0.2
- protocol/v7.0.1
- protocol/v7.0.0
- protocol/v7.0.0-rc2
- protocol/v7.0.0-rc1
- protocol/v7.0.0-dev7
- protocol/v7.0.0-dev6
- protocol/v7.0.0-dev5
- protocol/v7.0.0-dev4
- protocol/v7.0.0-dev3
- protocol/v7.0.0-dev1
- protocol/v7.0.0-dev0
- protocol/v6.0.9
- protocol/v6.0.8
- protocol/v6.0.8-dev0
- protocol/v6.0.7
- protocol/v6.0.6
- protocol/v6.0.5
- protocol/v6.0.5-dev0
- protocol/v6.0.4
- protocol/v6.0.4-rc2
- protocol/v6.0.4-rc0
- protocol/v6.0.3
- protocol/v6.0.3-rc0
- protocol/v6.0.3-dev0
- protocol/v6.0.2
- protocol/v6.0.1
- protocol/v6.0.0
- protocol/v6.0.0-dev999
- protocol/v5.2.4
- protocol/v5.2.3
- protocol/v5.2.2
- protocol/v5.2.1
- protocol/v5.2.0
- protocol/v5.2.0-rc2
- protocol/v5.2.0-rc1
- protocol/v5.2.0-rc0
- protocol/v5.2.0-dev1
- protocol/v5.2.0-dev0
- protocol/v5.1.1000-dev1001
- protocol/v5.1.1000-dev1000
- protocol/v5.1.999-dev1
- protocol/v5.1.1
- protocol/v5.1.1-dev1
- protocol/v5.1.1-dev0
- protocol/v5.1.0
- protocol/v5.1.0-rc5
- protocol/v5.1.0-rc2
- protocol/v5.1.0-rc1
- protocol/v5.1.0-rc0
- protocol/v5.1.0-dev4
- protocol/v5.1.0-dev3
- protocol/v5.1.0-dev2
- protocol/v5.0.999-dev2
- protocol/v5.0.999-dev1
- protocol/v5.0.999-dev0
- protocol/v5.0.7-rc0
- protocol/v5.0.7-dev0
- protocol/v5.0.6
- protocol/v5.0.6-dev0
- protocol/v5.0.5
- protocol/v5.0.5-dev5
- protocol/v5.0.5-dev4
- protocol/v5.0.5-dev3
- protocol/v5.0.5-dev2
- protocol/v5.0.5-dev1
- protocol/v5.0.5-dev0
- protocol/v5.0.5-chenyao
- protocol/v5.0.4
- protocol/v5.0.4-dev0
- protocol/v5.0.3
- protocol/v5.0.2
- protocol/v5.0.2-rc1
- protocol/v5.0.2-rc0
- protocol/v5.0.2-dev2
- protocol/v5.0.2-dev1
- protocol/v5.0.2-dev0
- protocol/v5.0.1
- protocol/v5.0.1-dev0
- protocol/v5.0.0
- protocol/v5.0.0-rc5
- protocol/v5.0.0-rc4
- protocol/v5.0.0-rc3
- protocol/v5.0.0-rc2
- protocol/v5.0.0-rc1
- protocol/v5.0.0-rc0
- protocol/v5.0.0-dev0
- protocol/v4.1.4
- protocol/v4.1.3
- protocol/v4.1.2
- protocol/v4.1.1
- protocol/v4.1.1-dev3
- protocol/v4.1.1-dev2
- protocol/v4.1.1-dev1
- protocol/v4.1.1-dev0
- protocol/v4.1.0
- protocol/v4.1.0-dev5
- protocol/v4.1.0-dev4
- protocol/v4.1.0-dev3
- protocol/v4.1.0-dev2
- protocol/v4.0.5
- protocol/v4.0.5-dev1
- protocol/v4.0.5-dev0
- protocol/v4.0.4
- protocol/v4.0.4-dev1
- protocol/v4.0.4-dev0
- protocol/v4.0.3
- protocol/v4.0.2
- protocol/v4.0.1
- protocol/v4.0.0
- protocol/v4.0.0-rc4
- protocol/v4.0.0-rc3
- protocol/v4.0.0-rc2
- protocol/v4.0.0-rc1
- protocol/v4.0.0-rc0
- protocol/v4.0.0-dev5
- protocol/v4.0.0-dev4
- protocol/v4.0.0-dev3
- protocol/v4.0.0-dev2
- protocol/v4.0.0-dev1
- protocol/v4.0.0-dev0
- protocol/v3.0.2
- protocol/v3.0.1
- protocol/v3.0.0
- protocol/v3.0.0-rc1
- protocol/v3.0.0-rc0
- protocol/v3.0.0-dev0
- indexer/v8.0.2
- indexer/v8.0.1
- indexer/v8.0.0
- indexer/v8.0.0-rc0
- indexer/v7.0.12
- indexer/v7.0.11
- indexer/v7.0.10
- indexer/v7.0.9
- indexer/v7.0.8
- indexer/v7.0.7
- indexer/v7.0.6
- indexer/v7.0.5
- indexer/v7.0.4
- indexer/v7.0.3
- indexer/v7.0.2
- indexer/v7.0.1
- indexer/v7.0.0
- indexer/v7.0.0-rc1
- indexer/v7.0.0-dev7
- indexer/v7.0.0-dev6
- indexer/v7.0.0-dev5
- indexer/v7.0.0-dev4
- indexer/v7.0.0-dev3
- indexer/v7.0.0-dev2
- indexer/v7.0.0-dev1
- indexer/v6.0.7
- indexer/v6.0.6
- indexer/v6.0.5
- indexer/v6.0.4
- indexer/v6.0.3
- indexer/v6.0.1
- indexer/v6.0.0
- indexer/v5.0.15
- indexer/v5.0.14
- indexer/v5.0.13
- indexer/v5.0.12
- indexer/v5.0.11
- indexer/v5.0.10
- indexer/v5.0.9
- indexer/v5.0.8
- indexer/v5.0.7
- indexer/v5.0.6
- indexer/v5.0.5
- indexer/v5.0.3
- indexer/v5.0.2
- indexer/v5.0.1
- indexer/v5.0.0
- indexer/v5.0.0-rc0
- indexer/v4.1.2
- indexer/v4.1.1
- indexer/v4.0.3
- indexer/v4.0.2
- indexer/v4.0.1
- indexer/v4.0.1-rc3
- indexer/v4.0.1-rc2
- indexer/v4.0.1-rc1
- indexer/v4.0.0
- indexer/v4.0.0-rc2
- indexer/v4.0.0-rc1
- indexer/v4.0.0-rc0
- indexer/v3.0.4
- indexer/v3.0.3
- indexer/v3.0.2
- indexer/v3.0.1
- indexer/v3.0.0
- indexer/v3.0.0-rc2
- indexer/v3.0.0-rc1
- indexer/v3.0.0-rc0
- 5.2.1
Crystal Lemire
authored
Dec 11, 2023
1 parent
0b6a974
commit 8b0e3ad
Showing
15 changed files
with
445 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/configs" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// AddInitCmdPostRunE adds a PostRunE to the `init` subcommand. | ||
func AddInitCmdPostRunE(rootCmd *cobra.Command) { | ||
// Fetch init subcommand. | ||
initCmd, _, err := rootCmd.Find([]string{"init"}) | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
|
||
// Add PostRun to configure required setups after `init`. | ||
initCmd.PostRunE = func(cmd *cobra.Command, args []string) error { | ||
// Get home directory. | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
// Add default pricefeed exchange config toml file if it does not exist. | ||
configs.WriteDefaultPricefeedExchangeToml(clientCtx.HomeDir) | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
protocol/daemons/configs/default_pricefeed_exchange_config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package configs | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"text/template" | ||
|
||
tmos "github.com/cometbft/cometbft/libs/os" | ||
daemonconstants "github.com/dydxprotocol/v4-chain/protocol/daemons/constants" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" | ||
"github.com/pelletier/go-toml" | ||
) | ||
|
||
// Note: any changes to the comments/variables/mapstructure must be reflected in the appropriate | ||
// struct in daemons/pricefeed/client/static_exchange_startup_config.go. | ||
const ( | ||
defaultTomlTemplate = `# This is a TOML config file. | ||
# StaticExchangeStartupConfig represents the mapping of exchanges to the parameters for | ||
# querying from them. | ||
# | ||
# ExchangeId - Unique string identifying an exchange. | ||
# | ||
# IntervalMs - Delays between sending API requests to get exchange market prices - cannot be 0. | ||
# | ||
# TimeoutMs - Max time to wait on an API call to an exchange - cannot be 0. | ||
# | ||
# MaxQueries - Max api calls to get market prices for an exchange to make in a task-loop - | ||
# cannot be 0. For multi-market API exchanges, the behavior will default to 1.{{ range $exchangeId, $element := .}} | ||
[[exchanges]] | ||
ExchangeId = "{{$element.ExchangeId}}" | ||
IntervalMs = {{$element.IntervalMs}} | ||
TimeoutMs = {{$element.TimeoutMs}} | ||
MaxQueries = {{$element.MaxQueries}}{{end}} | ||
` | ||
) | ||
|
||
// GenerateDefaultExchangeTomlString creates the toml file string containing the default configs | ||
// for querying each exchange. | ||
func GenerateDefaultExchangeTomlString() bytes.Buffer { | ||
// Create the template for turning each `parsableExchangeStartupConfig` into a toml map config in | ||
// a stringified toml file. | ||
template, err := template.New("").Parse(defaultTomlTemplate) | ||
// Panic if failure occurs when parsing the template. | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Encode toml string into `defaultExchangeToml` and return if successful. Otherwise, panic. | ||
var defaultExchangeToml bytes.Buffer | ||
err = template.Execute(&defaultExchangeToml, constants.StaticExchangeQueryConfig) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return defaultExchangeToml | ||
} | ||
|
||
// WriteDefaultPricefeedExchangeToml reads in the toml string for the pricefeed client and | ||
// writes said string to the config folder as a toml file if the config file does not exist. | ||
func WriteDefaultPricefeedExchangeToml(homeDir string) { | ||
// Write file into config folder if file does not exist. | ||
configFilePath := getConfigFilePath(homeDir) | ||
if !tmos.FileExists(configFilePath) { | ||
buffer := GenerateDefaultExchangeTomlString() | ||
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0644) | ||
} | ||
} | ||
|
||
// ReadExchangeQueryConfigFile gets a mapping of `exchangeIds` to `ExchangeQueryConfigs` | ||
// where `ExchangeQueryConfig` for querying exchanges for market prices comes from parsing a TOML | ||
// file in the config directory. | ||
// NOTE: if the config file is not found for the price-daemon, return the static exchange query | ||
// config. | ||
func ReadExchangeQueryConfigFile(homeDir string) map[types.ExchangeId]*types.ExchangeQueryConfig { | ||
// Read file for exchange query configurations. | ||
tomlFile, err := os.ReadFile(getConfigFilePath(homeDir)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Unmarshal `tomlFile` into `exchanges` for `exchangeStartupConfigMap`. | ||
exchanges := map[string][]types.ExchangeQueryConfig{} | ||
if err = toml.Unmarshal(tomlFile, &exchanges); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Populate configs for exchanges. | ||
exchangeStartupConfigMap := make(map[types.ExchangeId]*types.ExchangeQueryConfig, len(exchanges)) | ||
for _, exchange := range exchanges["exchanges"] { | ||
// Zero is an invalid configuration value for all parameters. This could also point to the | ||
// configuration file being setup wrong with one or more exchange parameters unset. | ||
if exchange.IntervalMs == 0 || | ||
exchange.TimeoutMs == 0 || | ||
exchange.MaxQueries == 0 { | ||
panic( | ||
fmt.Errorf( | ||
"One or more query config values are unset or are set to zero for exchange with id: '%v'", | ||
exchange.ExchangeId, | ||
), | ||
) | ||
} | ||
|
||
// Insert Key-Value pair into `exchangeStartupConfigMap`. | ||
exchangeStartupConfigMap[exchange.ExchangeId] = &types.ExchangeQueryConfig{ | ||
ExchangeId: exchange.ExchangeId, | ||
IntervalMs: exchange.IntervalMs, | ||
TimeoutMs: exchange.TimeoutMs, | ||
MaxQueries: exchange.MaxQueries, | ||
} | ||
} | ||
|
||
return exchangeStartupConfigMap | ||
} | ||
|
||
// getConfigFilePath returns the path to the pricefeed exchange config file. | ||
func getConfigFilePath(homeDir string) string { | ||
return filepath.Join( | ||
homeDir, | ||
"config", | ||
daemonconstants.PricefeedExchangeConfigFileName, | ||
) | ||
} |
248 changes: 248 additions & 0 deletions
248
protocol/daemons/configs/default_pricefeed_exchange_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
package configs_test | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/dydxprotocol/v4-chain/protocol/daemons/configs" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/constants" | ||
pfconstants "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants/exchange_common" | ||
"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" | ||
|
||
tmos "github.com/cometbft/cometbft/libs/os" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
binanceId = exchange_common.EXCHANGE_ID_BINANCE | ||
filePath = fmt.Sprintf("config/%v", constants.PricefeedExchangeConfigFileName) | ||
) | ||
|
||
const ( | ||
tomlString = `# This is a TOML config file. | ||
# StaticExchangeStartupConfig represents the mapping of exchanges to the parameters for | ||
# querying from them. | ||
# | ||
# ExchangeId - Unique string identifying an exchange. | ||
# | ||
# IntervalMs - Delays between sending API requests to get exchange market prices - cannot be 0. | ||
# | ||
# TimeoutMs - Max time to wait on an API call to an exchange - cannot be 0. | ||
# | ||
# MaxQueries - Max api calls to get market prices for an exchange to make in a task-loop - | ||
# cannot be 0. For multi-market API exchanges, the behavior will default to 1. | ||
[[exchanges]] | ||
ExchangeId = "Binance" | ||
IntervalMs = 2500 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "BinanceUS" | ||
IntervalMs = 2500 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Bitfinex" | ||
IntervalMs = 2500 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Bitstamp" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Bybit" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "CoinbasePro" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 3 | ||
[[exchanges]] | ||
ExchangeId = "CryptoCom" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Gate" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Huobi" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Kraken" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Kucoin" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Mexc" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "Okx" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 1 | ||
[[exchanges]] | ||
ExchangeId = "TestFixedPriceExchange" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 3 | ||
[[exchanges]] | ||
ExchangeId = "TestVolatileExchange" | ||
IntervalMs = 2000 | ||
TimeoutMs = 3000 | ||
MaxQueries = 3 | ||
` | ||
) | ||
|
||
func TestGenerateDefaultExchangeTomlString(t *testing.T) { | ||
defaultConfigStringBuffer := configs.GenerateDefaultExchangeTomlString() | ||
require.Equal( | ||
t, | ||
tomlString, | ||
defaultConfigStringBuffer.String(), | ||
) | ||
} | ||
|
||
func TestWriteDefaultPricefeedExchangeToml(t *testing.T) { | ||
err := os.Mkdir("config", 0700) | ||
require.NoError(t, err) | ||
configs.WriteDefaultPricefeedExchangeToml("") | ||
|
||
buffer, err := os.ReadFile(filePath) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, tomlString, string(buffer[:])) | ||
os.RemoveAll("config") | ||
} | ||
|
||
func TestWriteDefaultPricefeedExchangeToml_FileExists(t *testing.T) { | ||
helloWorld := "Hello World" | ||
|
||
err := os.Mkdir("config", 0700) | ||
require.NoError(t, err) | ||
|
||
tmos.MustWriteFile(filePath, bytes.NewBuffer([]byte(helloWorld)).Bytes(), 0644) | ||
configs.WriteDefaultPricefeedExchangeToml("") | ||
|
||
buffer, err := os.ReadFile(filePath) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, helloWorld, string(buffer[:])) | ||
os.RemoveAll("config") | ||
} | ||
|
||
func TestReadExchangeStartupConfigFile(t *testing.T) { | ||
pwd, _ := os.Getwd() | ||
|
||
tests := map[string]struct { | ||
// parameters | ||
exchangeConfigSourcePath string | ||
doNotWriteFile bool | ||
|
||
// expectations | ||
expectedExchangeId types.ExchangeId | ||
expectedIntervalMsExchange uint32 | ||
expectedTimeoutMsExchange uint32 | ||
expectedMaxQueries uint32 | ||
expectedPanic error | ||
}{ | ||
"valid": { | ||
exchangeConfigSourcePath: "test_data/valid_test.toml", | ||
expectedExchangeId: binanceId, | ||
expectedIntervalMsExchange: pfconstants.StaticExchangeQueryConfig[binanceId].IntervalMs, | ||
expectedTimeoutMsExchange: pfconstants.StaticExchangeQueryConfig[binanceId].TimeoutMs, | ||
expectedMaxQueries: pfconstants.StaticExchangeQueryConfig[binanceId].MaxQueries, | ||
}, | ||
"config file cannot be found": { | ||
exchangeConfigSourcePath: "test_data/notexisting_test.toml", | ||
doNotWriteFile: true, | ||
expectedPanic: fmt.Errorf( | ||
"open %s%s: no such file or directory", | ||
pwd+"/config/", | ||
constants.PricefeedExchangeConfigFileName, | ||
), | ||
}, | ||
"config file cannot be unmarshalled": { | ||
exchangeConfigSourcePath: "test_data/broken_test.toml", | ||
expectedPanic: errors.New("(1, 12): was expecting token [[, but got unclosed table array key instead"), | ||
}, | ||
"config file has malformed values": { | ||
exchangeConfigSourcePath: "test_data/missingvals_test.toml", | ||
expectedPanic: errors.New( | ||
"One or more query config values are unset or are set to zero for exchange with id: 'BinanceUS'", | ||
), | ||
}, | ||
"config file has incorrect values": { | ||
exchangeConfigSourcePath: "test_data/wrongvaltype_test.toml", | ||
expectedPanic: errors.New( | ||
"(3, 1): Can't convert a(string) to uint32", | ||
), | ||
}, | ||
} | ||
|
||
for name, tc := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
if !tc.doNotWriteFile { | ||
err := os.Mkdir("config", 0700) | ||
require.NoError(t, err) | ||
|
||
file, err := os.Open(tc.exchangeConfigSourcePath) | ||
require.NoError(t, err) | ||
|
||
config, err := os.Create(filepath.Join("config", constants.PricefeedExchangeConfigFileName)) | ||
require.NoError(t, err) | ||
_, err = config.ReadFrom(file) | ||
require.NoError(t, err) | ||
} | ||
|
||
if tc.expectedPanic != nil { | ||
require.PanicsWithError( | ||
t, | ||
tc.expectedPanic.Error(), | ||
func() { configs.ReadExchangeQueryConfigFile(pwd) }, | ||
) | ||
|
||
os.RemoveAll("config") | ||
return | ||
} | ||
|
||
exchangeStartupConfigMap := configs.ReadExchangeQueryConfigFile(pwd) | ||
|
||
require.Equal( | ||
t, | ||
&types.ExchangeQueryConfig{ | ||
ExchangeId: tc.expectedExchangeId, | ||
IntervalMs: tc.expectedIntervalMsExchange, | ||
TimeoutMs: tc.expectedTimeoutMsExchange, | ||
MaxQueries: tc.expectedMaxQueries, | ||
}, | ||
exchangeStartupConfigMap[tc.expectedExchangeId], | ||
) | ||
|
||
os.RemoveAll("config") | ||
}) | ||
} | ||
|
||
// In case tests fail and the path was never removed. | ||
os.RemoveAll("config") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[[exchanges] | ||
ExchangeId = "BinanceUS" | ||
IntervalMs = 4_250 | ||
TimeoutMs = 3_000 | ||
MaxQueries = 1 | ||
MaxBufferSize = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[[exchanges]] | ||
ExchangeId = "BinanceUS" | ||
IntervalMs = 4_250 | ||
TimeoutMs = 3_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[[exchanges]] | ||
ExchangeId = "Binance" | ||
IntervalMs = 2_500 | ||
TimeoutMs = 3_000 | ||
MaxQueries = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[[exchanges]] | ||
ExchangeId = "BinanceUS" | ||
IntervalMs = "a" | ||
TimeoutMs = 3_000 | ||
MaxQueries = 1 | ||
MaxBufferSize = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
protocol/testing/containertest/config/pricefeed_exchange_config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[[exchanges]] | ||
ExchangeId = "TestExchange" | ||
IntervalMs = 1000 | ||
TimeoutMs = 1000 | ||
MaxQueries = 33 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters