Add test to MetadataUpdater's GenServer

Co-Authored-By: w-sanches <1727723+w-sanches@users.noreply.github.com>
pull/1095/head
Amanda 6 years ago committed by William Sanches
parent 421262a2da
commit 3c146f92e4
No known key found for this signature in database
GPG Key ID: 27250E49FB133014
  1. 46
      apps/indexer/test/indexer/token/metadata_updater_test.exs

@ -8,6 +8,52 @@ defmodule Indexer.Token.MetadataUpdaterTest do
alias Indexer.Token.MetadataUpdater alias Indexer.Token.MetadataUpdater
setup :verify_on_exit! setup :verify_on_exit!
setup :set_mox_global
test "updates tokens metadata on start" do
insert(:token, name: nil, symbol: nil, decimals: 10, cataloged: true)
expect(
EthereumJSONRPC.Mox,
:json_rpc,
1,
fn [%{id: "decimals"}, %{id: "name"}, %{id: "symbol"}, %{id: "totalSupply"}], _opts ->
{:ok,
[
%{
id: "decimals",
result: "0x0000000000000000000000000000000000000000000000000000000000000012"
},
%{
id: "name",
result:
"0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000642616e636f720000000000000000000000000000000000000000000000000000"
},
%{
id: "symbol",
result:
"0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003424e540000000000000000000000000000000000000000000000000000000000"
},
%{
id: "totalSupply",
result: "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
}
]}
end
)
pid = start_supervised!({MetadataUpdater, %{update_interval: 0}})
wait_for_results(fn ->
updated = Repo.one!(from(t in Token, where: t.cataloged == true and not is_nil(t.name), limit: 1))
assert updated.name != nil
assert updated.symbol != nil
end)
# Terminates the process so it finishes all Ecto processes.
GenServer.stop(pid)
end
describe "update_metadata/1" do describe "update_metadata/1" do
test "updates the metadata for a list of tokens" do test "updates the metadata for a list of tokens" do

Loading…
Cancel
Save