Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak committed Jan 16, 2024
1 parent 1f531fd commit deac47c
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit deac47c

Please sign in to comment.