From b8e184f8389b14b2dceba9033d6eeff48ff9fda9 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 9 Nov 2020 19:57:08 +0300 Subject: [PATCH] Add tests --- apps/explorer/lib/explorer/chain.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 1d3b426f2a..5b4fad9a33 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2447,6 +2447,21 @@ defmodule Explorer.Chain do iex> Explorer.Chain.missing_block_number_ranges(2..0) [1..1] + if range starts with non-consensus block in the middle of the chain, it returns missing numbers. + + iex> insert(:block, number: 12859383, consensus: true) + iex> insert(:block, number: 12859384, consensus: false) + iex> insert(:block, number: 12859386, consensus: true) + iex> Explorer.Chain.missing_block_number_ranges(12859384..12859385) + [12859384..12859385] + + if range starts with missing block in the middle of the chain, it returns missing numbers. + + iex> insert(:block, number: 12859383, consensus: true) + iex> insert(:block, number: 12859386, consensus: true) + iex> Explorer.Chain.missing_block_number_ranges(12859384..12859385) + [12859384..12859385] + """ @spec missing_block_number_ranges(Range.t()) :: [Range.t()] def missing_block_number_ranges(range)