Failing regression test for #1266

When the max block number exceeds the search range by more than 1 it
causes extra ranges to be calculated and they depend on the max block
number instead of the search range.
pull/1273/head
Luke Imhoff 6 years ago
parent 331b4ed26a
commit 07cb543948
  1. 111
      apps/explorer/test/explorer/chain_test.exs

@ -2191,6 +2191,117 @@ defmodule Explorer.ChainTest do
end end
end end
describe "missing_block_number_ranges/1" do
# 0000
test "0..0 without blocks" do
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0001
test "0..0 with block 3" do
insert(:block, number: 3)
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0010
test "0..0 with block 2" do
insert(:block, number: 2)
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0011
test "0..0 with blocks 2,3" do
Enum.each([2, 3], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0100
test "0..0 with block 1" do
insert(:block, number: 1)
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0101
test "0..0 with blocks 1,3" do
Enum.each([1, 3], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 0111
test "0..0 with blocks 1..3" do
Enum.each(1..3, &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == [0..0]
end
# 1000
test "0..0 with block 0" do
insert(:block, number: 0)
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1001
test "0..0 with blocks 0,3" do
Enum.each([0, 3], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1010
test "0..0 with blocks 0,2" do
Enum.each([0, 2], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1011
test "0..0 with blocks 0,2,3" do
Enum.each([0, 2, 3], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1100
test "0..0 with blocks 0..1" do
Enum.each(0..1, &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1101
test "0..0 with blocks 0,1,3" do
Enum.each([0, 1, 3], &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1110
test "0..0 with blocks 0..2" do
Enum.each(0..2, &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
# 1111
test "0..0 with blocks 0..3" do
Enum.each(0..2, &insert(:block, number: &1))
assert Chain.missing_block_number_ranges(0..0) == []
end
test "0..2 with block 1" do
insert(:block, number: 1)
assert Chain.missing_block_number_ranges(0..2) == [0..0, 2..2]
end
end
describe "recent_collated_transactions/1" do describe "recent_collated_transactions/1" do
test "with no collated transactions it returns an empty list" do test "with no collated transactions it returns an empty list" do
assert [] == Explorer.Chain.recent_collated_transactions() assert [] == Explorer.Chain.recent_collated_transactions()

Loading…
Cancel
Save