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/workers/import_block_test.exs

38 lines
1.3 KiB

defmodule Explorer.Workers.ImportBlockTest do
use Explorer.DataCase
alias Explorer.Block
alias Explorer.Repo
test "perform/1 imports the requested block number as an integer" do
use_cassette "import_block_perform_1_integer" do
Explorer.Workers.ImportBlock.perform(1)
last_block = Block |> order_by(asc: :number) |> Repo.one
assert last_block.number == 1
end
end
test "perform/1 imports the requested block number as a string" do
use_cassette "import_block_perform_1_string" do
Explorer.Workers.ImportBlock.perform("1")
last_block = Block |> order_by(asc: :number) |> Repo.one
assert last_block.number == 1
end
end
test "perform/1 imports the earliest block" do
use_cassette "import_block_perform_1_earliest" do
Explorer.Workers.ImportBlock.perform("earliest")
last_block = Block |> order_by(asc: :number) |> Repo.one
assert last_block.number == 0
end
end
test "perform/1 when there is alaready a block with the requested hash" do
use_cassette "import_block_perform_1_duplicate" do
insert(:block, hash: "0x52c867bc0a91e573dc39300143c3bead7408d09d45bdb686749f02684ece72f3")
Explorer.Workers.ImportBlock.perform("1")
block_count = Block |> Repo.all |> Enum.count
assert block_count == 1
end
end
end