|
|
@ -28,6 +28,7 @@ defmodule Explorer.ChainTest do |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
alias Explorer.{Chain, Etherscan} |
|
|
|
alias Explorer.{Chain, Etherscan} |
|
|
|
|
|
|
|
alias Explorer.Chain.Cache.Block, as: BlockCache |
|
|
|
alias Explorer.Chain.Cache.Transaction, as: TransactionCache |
|
|
|
alias Explorer.Chain.Cache.Transaction, as: TransactionCache |
|
|
|
alias Explorer.Chain.InternalTransaction.Type |
|
|
|
alias Explorer.Chain.InternalTransaction.Type |
|
|
|
|
|
|
|
|
|
|
@ -1475,6 +1476,9 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
describe "indexed_ratio_blocks/0" do |
|
|
|
describe "indexed_ratio_blocks/0" do |
|
|
|
setup do |
|
|
|
setup do |
|
|
|
|
|
|
|
Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Block.child_id()) |
|
|
|
|
|
|
|
Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Block.child_id()) |
|
|
|
|
|
|
|
|
|
|
|
on_exit(fn -> |
|
|
|
on_exit(fn -> |
|
|
|
Application.put_env(:indexer, :first_block, "") |
|
|
|
Application.put_env(:indexer, :first_block, "") |
|
|
|
end) |
|
|
|
end) |
|
|
@ -1482,9 +1486,11 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
test "returns indexed ratio" do |
|
|
|
test "returns indexed ratio" do |
|
|
|
for index <- 5..9 do |
|
|
|
for index <- 5..9 do |
|
|
|
insert(:block, number: index) |
|
|
|
insert(:block, number: index, consensus: true) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BlockCache.estimated_count() |
|
|
|
|
|
|
|
|
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), Decimal.from_float(0.5)) == :eq |
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), Decimal.from_float(0.5)) == :eq |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -1494,10 +1500,12 @@ defmodule Explorer.ChainTest do |
|
|
|
|
|
|
|
|
|
|
|
test "returns 1.0 if fully indexed blocks" do |
|
|
|
test "returns 1.0 if fully indexed blocks" do |
|
|
|
for index <- 0..9 do |
|
|
|
for index <- 0..9 do |
|
|
|
insert(:block, number: index) |
|
|
|
insert(:block, number: index, consensus: true) |
|
|
|
Process.sleep(200) |
|
|
|
Process.sleep(200) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BlockCache.estimated_count() |
|
|
|
|
|
|
|
|
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), 1) == :eq |
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), 1) == :eq |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -1505,10 +1513,12 @@ defmodule Explorer.ChainTest do |
|
|
|
Application.put_env(:indexer, :first_block, "5") |
|
|
|
Application.put_env(:indexer, :first_block, "5") |
|
|
|
|
|
|
|
|
|
|
|
for index <- 5..9 do |
|
|
|
for index <- 5..9 do |
|
|
|
insert(:block, number: index) |
|
|
|
insert(:block, number: index, consensus: true) |
|
|
|
Process.sleep(200) |
|
|
|
Process.sleep(200) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BlockCache.estimated_count() |
|
|
|
|
|
|
|
|
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), 1) == :eq |
|
|
|
assert Decimal.compare(Chain.indexed_ratio_blocks(), 1) == :eq |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|