Merge remote-tracking branch 'origin/master' into vb-current-token-balances-fetcher

pull/3214/head
Victor Baranov 4 years ago
commit 1d5b95d310
  1. 198
      apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs

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

Loading…
Cancel
Save