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
nil ->
{Map.put(days, date, last), last}
{Map.put(days, date, Decimal.sub(total(), last)), last}
value ->
{Map.put(days, date, value.value), value.value}
{Map.put(days, date, Decimal.sub(total(), value.value)), value.value}
end
end)
|> elem(0)

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

Loading…
Cancel
Save