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/apps/indexer/test/indexer/pending_ops_cleaner_test.exs

34 lines
1.1 KiB

defmodule Indexer.PendingOpsCleanerTest do
use Explorer.DataCase
alias Explorer.Chain.PendingBlockOperation
alias Indexer.PendingOpsCleaner
describe "init/1" do
test "deletes non-consensus pending ops on init" do
block = insert(:block, consensus: false)
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true)
assert Repo.one(from(block in PendingBlockOperation, where: block.block_hash == ^block.hash))
start_supervised!({PendingOpsCleaner, [[interval: :timer.seconds(1)], [name: :PendingOpsTest]]})
Process.sleep(2_000)
assert is_nil(Repo.one(from(block in PendingBlockOperation, where: block.block_hash == ^block.hash)))
end
test "re-schedules deletion" do
start_supervised!({PendingOpsCleaner, [[interval: :timer.seconds(1)], [name: :PendingOpsTest]]})
block = insert(:block, consensus: false)
insert(:pending_block_operation, block_hash: block.hash, fetch_internal_transactions: true)
Process.sleep(2_000)
assert is_nil(Repo.one(from(block in PendingBlockOperation, where: block.block_hash == ^block.hash)))
end
end
end