From a47978477b8d9379de6166c1a081ea3bccea9fcc Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Tue, 2 Oct 2018 09:05:42 -0500 Subject: [PATCH] Failing regression test for #843 --- apps/explorer/test/explorer/chain_test.exs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index 285f2a8523..a45d543424 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -536,10 +536,20 @@ defmodule Explorer.ChainTest do describe "hashes_to_addresses/1" do test "with existing addresses" do - address1_attrs = %{hash: "0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed"} - address2_attrs = %{hash: "0x6aaeb6053f3e94c9b9a09f33669435e7ef1beaed"} - address1 = insert(:address, address1_attrs) - address2 = insert(:address, address2_attrs) + address1 = insert(:address, hash: "0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed") + address2 = insert(:address, hash: "0x6aaeb6053f3e94c9b9a09f33669435e7ef1beaed") + # in opposite of insertion order, to check that ordering matches ordering of arguments + # regression test for https://github.com/poanetwork/blockscout/issues/843 + hashes = [address2.hash, address1.hash] + + [found_address1, found_address2] = Explorer.Chain.hashes_to_addresses(hashes) + + %Explorer.Chain.Address{hash: found_hash1} = found_address1 + %Explorer.Chain.Address{hash: found_hash2} = found_address2 + + assert found_hash1 == address2.hash + assert found_hash2 == address1.hash + hashes = [address1.hash, address2.hash] [found_address1, found_address2] = Explorer.Chain.hashes_to_addresses(hashes)