From 28a7d59c42d867df19f40dad3bcd6b1a16afdefd Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 8 Jul 2024 11:31:00 +0300 Subject: [PATCH] fix: Fix address controller flickering test (#10382) --- .../api/v2/address_controller_test.exs | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs index 6e07605fdf..951095d6ee 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/address_controller_test.exs @@ -71,7 +71,6 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do "creation_tx_hash" => nil, "token" => nil, "coin_balance" => nil, - "exchange_rate" => nil, # todo: added for backward compatibility, remove when frontend unbound from these props "implementation_address" => nil, "implementation_name" => nil, @@ -89,10 +88,37 @@ defmodule BlockScoutWeb.API.V2.AddressControllerTest do } request = get(conn, "/api/v2/addresses/#{Address.checksum(address.hash)}") - assert ^correct_response = json_response(request, 200) + check_response(correct_response, json_response(request, 200)) request = get(conn, "/api/v2/addresses/#{String.downcase(to_string(address.hash))}") - assert ^correct_response = json_response(request, 200) + check_response(correct_response, json_response(request, 200)) + end + + defp check_response(pattern_response, response) do + assert pattern_response["hash"] == response["hash"] + assert pattern_response["is_contract"] == response["is_contract"] + assert pattern_response["is_verified"] == response["is_verified"] + assert pattern_response["name"] == response["name"] + assert pattern_response["private_tags"] == response["private_tags"] + assert pattern_response["public_tags"] == response["public_tags"] + assert pattern_response["watchlist_names"] == response["watchlist_names"] + assert pattern_response["creator_address_hash"] == response["creator_address_hash"] + assert pattern_response["creation_tx_hash"] == response["creation_tx_hash"] + assert pattern_response["token"] == response["token"] + assert pattern_response["coin_balance"] == response["coin_balance"] + assert pattern_response["implementation_address"] == response["implementation_address"] + assert pattern_response["implementation_name"] == response["implementation_name"] + assert pattern_response["implementations"] == response["implementations"] + assert pattern_response["block_number_balance_updated_at"] == response["block_number_balance_updated_at"] + assert pattern_response["has_decompiled_code"] == response["has_decompiled_code"] + assert pattern_response["has_validated_blocks"] == response["has_validated_blocks"] + assert pattern_response["has_logs"] == response["has_logs"] + assert pattern_response["has_tokens"] == response["has_tokens"] + assert pattern_response["has_token_transfers"] == response["has_token_transfers"] + assert pattern_response["watchlist_address_id"] == response["watchlist_address_id"] + assert pattern_response["has_beacon_chain_withdrawals"] == response["has_beacon_chain_withdrawals"] + assert pattern_response["ens_domain_name"] == response["ens_domain_name"] + assert pattern_response["metadata"] == response["metadata"] end test "get EIP-1167 proxy contract info", %{conn: conn} do