use reverse order

pull/2075/head
Ayrat Badykov 6 years ago
parent b91af4c181
commit 9f0acb82ca
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 1
      apps/explorer/lib/explorer/chain/blocks_cache.ex
  2. 5
      apps/explorer/test/explorer/chain/blocks_cache_test.exs

@ -60,6 +60,7 @@ defmodule Explorer.Chain.BlocksCache do
numbers
|> Enum.sort()
|> Enum.reverse()
|> Enum.map(fn number ->
ConCache.get(@cache_name, number)
end)

@ -33,10 +33,11 @@ defmodule Explorer.Chain.BlocksCacheTest do
new_block = insert(:block, number: 70)
BlocksCache.update(new_block)
new_blocks = blocks |> List.replace_at(0, new_block.number) |> Enum.sort()
new_blocks = blocks |> List.replace_at(0, new_block.number) |> Enum.sort() |> Enum.reverse()
assert Enum.map(BlocksCache.blocks(), & &1.number) == new_blocks
end
test "adds missing element" do
block1 = insert(:block, number: 10)
block2 = insert(:block, number: 4)
@ -67,7 +68,7 @@ defmodule Explorer.Chain.BlocksCacheTest do
BlocksCache.rewrite_cache(new_blocks)
assert BlocksCache.blocks() == [block1, block2]
assert BlocksCache.blocks() == [block2, block1]
end
end
end

Loading…
Cancel
Save