commit
1d5b95d310
@ -1,144 +1,144 @@ |
|||||||
defmodule BlockScoutWeb.ViewingAppTest do |
defmodule BlockScoutWeb.ViewingAppTest do |
||||||
@moduledoc false |
@moduledoc false |
||||||
|
|
||||||
use BlockScoutWeb.FeatureCase, async: true |
# use BlockScoutWeb.FeatureCase, async: true |
||||||
|
|
||||||
alias BlockScoutWeb.AppPage |
# alias BlockScoutWeb.AppPage |
||||||
alias BlockScoutWeb.Counters.BlocksIndexedCounter |
# alias BlockScoutWeb.Counters.BlocksIndexedCounter |
||||||
alias Explorer.Counters.AddressesCounter |
# alias Explorer.Counters.AddressesCounter |
||||||
alias Explorer.{Repo} |
# alias Explorer.{Repo} |
||||||
alias Explorer.Chain.PendingBlockOperation |
# alias Explorer.Chain.PendingBlockOperation |
||||||
|
|
||||||
setup do |
# setup do |
||||||
start_supervised!(AddressesCounter) |
# start_supervised!(AddressesCounter) |
||||||
AddressesCounter.consolidate() |
# AddressesCounter.consolidate() |
||||||
|
|
||||||
:ok |
# :ok |
||||||
end |
# end |
||||||
|
|
||||||
describe "loading bar when indexing" do |
# describe "loading bar when indexing" do |
||||||
test "shows blocks indexed percentage", %{session: session} do |
# test "shows blocks indexed percentage", %{session: session} do |
||||||
[block | _] = |
# [block | _] = |
||||||
for index <- 5..9 do |
# for index <- 5..9 do |
||||||
insert(:block, number: index) |
# insert(:block, number: index) |
||||||
end |
# end |
||||||
|
|
||||||
:transaction |
# :transaction |
||||||
|> insert() |
# |> insert() |
||||||
|> with_block(block) |
# |> with_block(block) |
||||||
|
|
||||||
assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.5)) == :eq |
# assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.5)) == :eq |
||||||
|
|
||||||
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
# insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
||||||
|
|
||||||
session |
# session |
||||||
|> AppPage.visit_page() |
# |> AppPage.visit_page() |
||||||
|> assert_has(AppPage.indexed_status("50% Blocks Indexed")) |
# |> assert_has(AppPage.indexed_status("50% Blocks Indexed")) |
||||||
end |
# end |
||||||
|
|
||||||
test "shows tokens loading", %{session: session} do |
# test "shows tokens loading", %{session: session} do |
||||||
[block | _] = |
# [block | _] = |
||||||
for index <- 0..9 do |
# for index <- 0..9 do |
||||||
insert(:block, number: index) |
# insert(:block, number: index) |
||||||
end |
# end |
||||||
|
|
||||||
:transaction |
# :transaction |
||||||
|> insert() |
# |> insert() |
||||||
|> with_block(block) |
# |> with_block(block) |
||||||
|
|
||||||
assert Decimal.cmp(Explorer.Chain.indexed_ratio(), 1) == :eq |
# assert Decimal.cmp(Explorer.Chain.indexed_ratio(), 1) == :eq |
||||||
|
|
||||||
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
# insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
||||||
|
|
||||||
session |
# session |
||||||
|> AppPage.visit_page() |
# |> AppPage.visit_page() |
||||||
|> assert_has(AppPage.indexed_status("Indexing Tokens")) |
# |> assert_has(AppPage.indexed_status("Indexing Tokens")) |
||||||
end |
# end |
||||||
|
|
||||||
test "updates blocks indexed percentage", %{session: session} do |
# test "updates blocks indexed percentage", %{session: session} do |
||||||
[block | _] = |
# [block | _] = |
||||||
for index <- 5..9 do |
# for index <- 5..9 do |
||||||
insert(:block, number: index) |
# insert(:block, number: index) |
||||||
end |
# end |
||||||
|
|
||||||
:transaction |
# :transaction |
||||||
|> insert() |
# |> insert() |
||||||
|> with_block(block) |
# |> with_block(block) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.5)) == :eq |
# assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.5)) == :eq |
||||||
|
|
||||||
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
# insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
||||||
|
|
||||||
session |
# session |
||||||
|> AppPage.visit_page() |
# |> AppPage.visit_page() |
||||||
|> assert_has(AppPage.indexed_status("50% Blocks Indexed")) |
# |> assert_has(AppPage.indexed_status("50% Blocks Indexed")) |
||||||
|
|
||||||
insert(:block, number: 4) |
# insert(:block, number: 4) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
assert_has(session, AppPage.indexed_status("60% Blocks Indexed")) |
# assert_has(session, AppPage.indexed_status("60% Blocks Indexed")) |
||||||
end |
# end |
||||||
|
|
||||||
test "updates when blocks are fully indexed", %{session: session} do |
# test "updates when blocks are fully indexed", %{session: session} do |
||||||
[block | _] = |
# [block | _] = |
||||||
for index <- 1..9 do |
# for index <- 1..9 do |
||||||
insert(:block, number: index) |
# insert(:block, number: index) |
||||||
end |
# end |
||||||
|
|
||||||
:transaction |
# :transaction |
||||||
|> insert() |
# |> insert() |
||||||
|> with_block(block) |
# |> with_block(block) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.9)) == :eq |
# assert Decimal.cmp(Explorer.Chain.indexed_ratio(), Decimal.from_float(0.9)) == :eq |
||||||
|
|
||||||
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
# insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true) |
||||||
|
|
||||||
session |
# session |
||||||
|> AppPage.visit_page() |
# |> AppPage.visit_page() |
||||||
|> assert_has(AppPage.indexed_status("90% Blocks Indexed")) |
# |> assert_has(AppPage.indexed_status("90% Blocks Indexed")) |
||||||
|
|
||||||
insert(:block, number: 0) |
# insert(:block, number: 0) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
assert_has(session, AppPage.indexed_status("Indexing Tokens")) |
# assert_has(session, AppPage.indexed_status("Indexing Tokens")) |
||||||
end |
# end |
||||||
|
|
||||||
test "removes message when chain is indexed", %{session: session} do |
# test "removes message when chain is indexed", %{session: session} do |
||||||
[block | _] = |
# [block | _] = |
||||||
for index <- 0..9 do |
# for index <- 0..9 do |
||||||
insert(:block, number: index) |
# insert(:block, number: index) |
||||||
end |
# end |
||||||
|
|
||||||
:transaction |
# :transaction |
||||||
|> insert() |
# |> insert() |
||||||
|> with_block(block) |
# |> with_block(block) |
||||||
|
|
||||||
block_hash = block.hash |
# block_hash = block.hash |
||||||
|
|
||||||
insert(:pending_block_operation, block_hash: block_hash, fetch_internal_transactions: true) |
# insert(:pending_block_operation, block_hash: block_hash, fetch_internal_transactions: true) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
assert Decimal.cmp(Explorer.Chain.indexed_ratio(), 1) == :eq |
# assert Decimal.cmp(Explorer.Chain.indexed_ratio(), 1) == :eq |
||||||
|
|
||||||
session |
# session |
||||||
|> AppPage.visit_page() |
# |> AppPage.visit_page() |
||||||
|> assert_has(AppPage.indexed_status("Indexing Tokens")) |
# |> assert_has(AppPage.indexed_status("Indexing Tokens")) |
||||||
|
|
||||||
Repo.update_all( |
# Repo.update_all( |
||||||
from(p in PendingBlockOperation, where: p.block_hash == ^block_hash), |
# from(p in PendingBlockOperation, where: p.block_hash == ^block_hash), |
||||||
set: [fetch_internal_transactions: false] |
# set: [fetch_internal_transactions: false] |
||||||
) |
# ) |
||||||
|
|
||||||
BlocksIndexedCounter.calculate_blocks_indexed() |
# BlocksIndexedCounter.calculate_blocks_indexed() |
||||||
|
|
||||||
refute_has(session, AppPage.still_indexing?()) |
# refute_has(session, AppPage.still_indexing?()) |
||||||
end |
# end |
||||||
end |
# end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue