|
|
|
@ -6,7 +6,8 @@ defmodule Explorer.Chain.Import.Runner.StakingPoolsTest do |
|
|
|
|
|
|
|
|
|
describe "run/1" do |
|
|
|
|
test "insert new pools list" do |
|
|
|
|
pools = [ |
|
|
|
|
pools = |
|
|
|
|
[pool1, pool2, pool3] = [ |
|
|
|
|
%{ |
|
|
|
|
address_hash: %Explorer.Chain.Hash{ |
|
|
|
|
byte_count: 20, |
|
|
|
@ -23,7 +24,7 @@ defmodule Explorer.Chain.Import.Runner.StakingPoolsTest do |
|
|
|
|
bytes: <<187, 202, 168, 212, 130, 137, 187, 31, 252, 249, 128, 141, 154, 164, 177, 210, 21, 5, 76, 120>> |
|
|
|
|
}, |
|
|
|
|
retries_count: 1, |
|
|
|
|
staked_amount: 0, |
|
|
|
|
staked_amount: 25, |
|
|
|
|
was_banned_count: 0, |
|
|
|
|
was_validator_count: 1 |
|
|
|
|
}, |
|
|
|
@ -46,7 +47,7 @@ defmodule Explorer.Chain.Import.Runner.StakingPoolsTest do |
|
|
|
|
bytes: <<117, 223, 66, 56, 58, 254, 107, 245, 25, 74, 168, 250, 14, 155, 61, 95, 158, 134, 148, 65>> |
|
|
|
|
}, |
|
|
|
|
retries_count: 1, |
|
|
|
|
staked_amount: 0, |
|
|
|
|
staked_amount: 25, |
|
|
|
|
was_banned_count: 0, |
|
|
|
|
was_validator_count: 1 |
|
|
|
|
}, |
|
|
|
@ -80,6 +81,17 @@ defmodule Explorer.Chain.Import.Runner.StakingPoolsTest do |
|
|
|
|
|
|
|
|
|
assert {:ok, %{insert_staking_pools: list}} = run_changes(pools) |
|
|
|
|
assert Enum.count(list) == Enum.count(pools) |
|
|
|
|
|
|
|
|
|
saved_list = |
|
|
|
|
Explorer.Chain.Address.Name |
|
|
|
|
|> Repo.all() |
|
|
|
|
|> Enum.reduce(%{}, fn pool, acc -> |
|
|
|
|
Map.put(acc, pool.address_hash, pool) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
assert saved_list[pool1.address_hash].metadata["staked_ratio"] == 0.5 |
|
|
|
|
assert saved_list[pool2.address_hash].metadata["staked_ratio"] == 0.5 |
|
|
|
|
assert saved_list[pool3.address_hash].metadata["staked_ratio"] == 0.0 |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|