fix supply for days

pull/2237/head
Ayrat Badykov 5 years ago
parent 181d0b6f25
commit c3997a1d8a
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 4
      apps/explorer/lib/explorer/chain/supply/rsk.ex
  2. 31
      apps/explorer/test/explorer/chain/supply/rsk_test.exs

@ -68,10 +68,10 @@ defmodule Explorer.Chain.Supply.RSK do
case Map.get(by_day, date) do case Map.get(by_day, date) do
nil -> nil ->
{Map.put(days, date, last), last} {Map.put(days, date, Decimal.sub(total(), last)), last}
value -> value ->
{Map.put(days, date, value.value), value.value} {Map.put(days, date, Decimal.sub(total(), value.value)), value.value}
end end
end) end)
|> elem(0) |> elem(0)

@ -4,7 +4,6 @@ defmodule Explorer.Chain.Supply.RSKTest do
import Mox import Mox
alias Explorer.Chain.Supply.RSK alias Explorer.Chain.Supply.RSK
alias Explorer.Chain.Wei
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
@coin_address "0x0000000000000000000000000000000001000006" @coin_address "0x0000000000000000000000000000000001000006"
@ -45,9 +44,9 @@ defmodule Explorer.Chain.Supply.RSKTest do
assert RSK.supply_for_days(2) == assert RSK.supply_for_days(2) ==
{:ok, {:ok,
%{ %{
date(now, days: -2) => dec(0), date(now, days: -2) => dec(21_000_000),
date(now, days: -1) => dec(0), date(now, days: -1) => dec(21_000_000),
date(now) => dec(0) date(now) => dec(21_000_000)
}} }}
end end
@ -62,9 +61,9 @@ defmodule Explorer.Chain.Supply.RSKTest do
assert RSK.supply_for_days(2) == assert RSK.supply_for_days(2) ==
{:ok, {:ok,
%{ %{
date(now, days: -2) => dec(10), date(now, days: -2) => dec(20_999_990),
date(now, days: -1) => dec(10), date(now, days: -1) => dec(20_999_990),
date(now) => dec(10) date(now) => dec(20_999_990)
}} }}
end end
@ -82,9 +81,9 @@ defmodule Explorer.Chain.Supply.RSKTest do
assert RSK.supply_for_days(2) == assert RSK.supply_for_days(2) ==
{:ok, {:ok,
%{ %{
date(now, days: -2) => dec(10), date(now, days: -2) => dec(20_999_990),
date(now, days: -1) => dec(20), date(now, days: -1) => dec(20_999_980),
date(now) => dec(20) date(now) => dec(20_999_980)
}} }}
end end
@ -105,9 +104,9 @@ defmodule Explorer.Chain.Supply.RSKTest do
assert RSK.supply_for_days(2) == assert RSK.supply_for_days(2) ==
{:ok, {:ok,
%{ %{
date(now, days: -2) => dec(10), date(now, days: -2) => dec(20_999_990),
date(now, days: -1) => dec(20), date(now, days: -1) => dec(20_999_980),
date(now) => dec(20) date(now) => dec(20_999_980)
}} }}
end end
@ -128,9 +127,9 @@ defmodule Explorer.Chain.Supply.RSKTest do
assert RSK.supply_for_days(2) == assert RSK.supply_for_days(2) ==
{:ok, {:ok,
%{ %{
date(now, days: -2) => dec(10), date(now, days: -2) => dec(20_999_990),
date(now, days: -1) => dec(20), date(now, days: -1) => dec(20_999_980),
date(now) => dec(30) date(now) => dec(20_999_970)
}} }}
end end
end end

Loading…
Cancel
Save