diff --git a/config/config_test.go b/config/config_test.go index 7960ded..7b187ba 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1133,3 +1133,132 @@ providers = [ _, err = config.ParseConfigs([]string{tmpFile.Name(), tmpFile2.Name()}) require.NoError(t, err) } + +func TestConfigGas(t *testing.T) { + tmpFile, err := ioutil.TempFile("", "price-feeder*.toml") + require.NoError(t, err) + defer os.Remove(tmpFile.Name()) + + gasSet := []byte(` +gas = 1000000 + +[server] +listen_addr = "0.0.0.0:99999" +read_timeout = "20s" +verbose_cors = true +write_timeout = "20s" + +[[currency_pairs]] +base = "ATOM" +quote = "USDT" +providers = [ + "kraken", + "binance", + "huobi" +] + +[[currency_pairs]] +base = "OJO" +quote = "USDT" +providers = [ + "kraken", + "binance", + "huobi" +] + +[[currency_pairs]] +base = "stOSMO" +quote = "OSMO" +providers = [ + "kraken", + "binance", + "huobi" +] + +[account] +address = "ojo15nejfgcaanqpw25ru4arvfd0fwy6j8clccvwx4" +validator = "ojovalcons14rjlkfzp56733j5l5nfk6fphjxymgf8mj04d5p" +chain_id = "ojo-local-testnet" + +[keyring] +backend = "test" +dir = "/Users/username/.ojo" +pass = "keyringPassword" + +[rpc] +tmrpc_endpoint = "http://localhost:26657" +grpc_endpoint = "localhost:9090" +rpc_timeout = "100ms" + +[telemetry] +enabled = false +`) + _, err = tmpFile.Write(gasSet) + require.NoError(t, err) + c, err := config.ParseConfig(tmpFile.Name()) + require.NoError(t, err) + require.Equal(t, c.Gas, uint64(1000000)) +} + +func TestInvalidGas(t *testing.T) { + tmpFile, err := ioutil.TempFile("", "price-feeder*.toml") + require.NoError(t, err) + defer os.Remove(tmpFile.Name()) + + gasSet := []byte(` +[server] +listen_addr = "0.0.0.0:99999" +read_timeout = "20s" +verbose_cors = true +write_timeout = "20s" + +[[currency_pairs]] +base = "ATOM" +quote = "USDT" +providers = [ + "kraken", + "binance", + "huobi" +] + +[[currency_pairs]] +base = "OJO" +quote = "USDT" +providers = [ + "kraken", + "binance", + "huobi" +] + +[[currency_pairs]] +base = "stOSMO" +quote = "OSMO" +providers = [ + "kraken", + "binance", + "huobi" +] + +[account] +address = "ojo15nejfgcaanqpw25ru4arvfd0fwy6j8clccvwx4" +validator = "ojovalcons14rjlkfzp56733j5l5nfk6fphjxymgf8mj04d5p" +chain_id = "ojo-local-testnet" + +[keyring] +backend = "test" +dir = "/Users/username/.ojo" +pass = "keyringPassword" + +[rpc] +tmrpc_endpoint = "http://localhost:26657" +grpc_endpoint = "localhost:9090" +rpc_timeout = "100ms" + +[telemetry] +enabled = false +`) + _, err = tmpFile.Write(gasSet) + require.NoError(t, err) + _, err = config.ParseConfig(tmpFile.Name()) + require.Error(t, err) +}