Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/test/explorer/skipped_blocks_test.exs

53 lines
1.4 KiB

defmodule Explorer.SkippedBlocksTest do
use Explorer.DataCase
alias Explorer.Block
alias Explorer.Repo
alias Explorer.SkippedBlocks
describe "fetch/0" do
test "inserts a missing block into the database" do
insert(:block, %{number: 2})
use_cassette "skipped_block_fetch" do
SkippedBlocks.fetch()
blocks = Block |> order_by(asc: :number) |> Repo.all |> Enum.map(fn(block) -> block.number end)
assert blocks == [1, 2]
end
end
end
describe "get_skipped_blocks/0 when there are no blocks" do
test "returns no blocks" do
assert SkippedBlocks.get_skipped_blocks() == []
end
end
describe "get_skipped_blocks/0 when there are no skipped blocks" do
test "returns no blocks" do
insert(:block, %{number: 1})
assert SkippedBlocks.get_skipped_blocks() == []
end
end
describe "get_skipped_blocks/0 when a block has been skipped" do
test "returns no blocks" do
insert(:block, %{number: 2})
assert SkippedBlocks.get_skipped_blocks() == [1]
end
end
describe "get_last_block_number/0 when there are no blocks" do
test "returns zero" do
assert SkippedBlocks.get_last_block_number() == 0
end
end
describe "get_last_block_number/0 when there is a block" do
test "returns the number of the block" do
insert(:block, %{number: 1})
assert SkippedBlocks.get_last_block_number() == 1
end
end
end