add test for all supported chains

pull/2662/head
Ayrat Badykov 5 years ago
parent 408de7fd59
commit b1ac8c69ef
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 66
      apps/explorer/test/explorer/exchange_rates/source/coin_gecko_test.exs

@ -34,6 +34,26 @@ defmodule Explorer.ExchangeRates.Source.CoinGeckoTest do
"id": "pocket-arena", "id": "pocket-arena",
"symbol": "poc", "symbol": "poc",
"name": "Pocket Arena" "name": "Pocket Arena"
},
{
"id": "ethereum",
"symbol": "eth",
"name": "Ethereum"
},
{
"id": "rootstock",
"symbol": "rbtc",
"name": "Rootstock RSK"
},
{
"id": "dai",
"symbol": "dai",
"name": "Dai"
},
{
"id": "callisto",
"symbol": "clo",
"name": "Callisto Network"
} }
] ]
""" """
@ -88,15 +108,59 @@ defmodule Explorer.ExchangeRates.Source.CoinGeckoTest do
bypass = Bypass.open() bypass = Bypass.open()
Application.put_env(:explorer, CoinGecko, base_url: "http://localhost:#{bypass.port}") Application.put_env(:explorer, CoinGecko, base_url: "http://localhost:#{bypass.port}")
on_exit(fn ->
Application.put_env(:explorer, :coin, "POA")
end)
{:ok, bypass: bypass} {:ok, bypass: bypass}
end end
test "fetches coin id", %{bypass: bypass} do test "fetches poa coin id by default", %{bypass: bypass} do
Bypass.expect(bypass, "GET", "/coins/list", fn conn -> Bypass.expect(bypass, "GET", "/coins/list", fn conn ->
Conn.resp(conn, 200, @coins_list) Conn.resp(conn, 200, @coins_list)
end) end)
assert CoinGecko.coin_id() == {:ok, "poa-network"} assert CoinGecko.coin_id() == {:ok, "poa-network"}
end end
test "fetches eth coin id", %{bypass: bypass} do
Application.put_env(:explorer, :coin, "ETH")
Bypass.expect(bypass, "GET", "/coins/list", fn conn ->
Conn.resp(conn, 200, @coins_list)
end)
assert CoinGecko.coin_id() == {:ok, "ethereum"}
end
test "fetches rbtc coin id", %{bypass: bypass} do
Application.put_env(:explorer, :coin, "RBTC")
Bypass.expect(bypass, "GET", "/coins/list", fn conn ->
Conn.resp(conn, 200, @coins_list)
end)
assert CoinGecko.coin_id() == {:ok, "rootstock"}
end
test "fetches dai coin id", %{bypass: bypass} do
Application.put_env(:explorer, :coin, "DAI")
Bypass.expect(bypass, "GET", "/coins/list", fn conn ->
Conn.resp(conn, 200, @coins_list)
end)
assert CoinGecko.coin_id() == {:ok, "dai"}
end
test "fetches callisto coin id", %{bypass: bypass} do
Application.put_env(:explorer, :coin, "CLO")
Bypass.expect(bypass, "GET", "/coins/list", fn conn ->
Conn.resp(conn, 200, @coins_list)
end)
assert CoinGecko.coin_id() == {:ok, "callisto"}
end
end end
end end

Loading…
Cancel
Save