diff --git a/CHANGELOG.md b/CHANGELOG.md index 83d4caf9ac..6b059f232e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Chore +- [#7789](https://github.com/blockscout/blockscout/pull/7789) - Fix test warnings; Fix name of `MICROSERVICE_ETH_BYTECODE_DB_INTERVAL_BETWEEN_LOOKUPS` env variable - [#7819](https://github.com/blockscout/blockscout/pull/7819) - Add logging for unknown error verification result - [#7781](https://github.com/blockscout/blockscout/pull/7781) - Add `/api/v1/health/liveness` and `/api/v1/health/readiness` diff --git a/apps/block_scout_web/test/block_scout_web/channels/transaction_channel_test.exs b/apps/block_scout_web/test/block_scout_web/channels/transaction_channel_test.exs index 7500560028..ea47cc9f7f 100644 --- a/apps/block_scout_web/test/block_scout_web/channels/transaction_channel_test.exs +++ b/apps/block_scout_web/test/block_scout_web/channels/transaction_channel_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.TransactionChannelTest do use BlockScoutWeb.ChannelCase - alias Explorer.Chain.{Hash, Import, Transaction} + alias Explorer.Chain.Hash alias BlockScoutWeb.Notifier test "subscribed user is notified of new_transaction topic" do diff --git a/apps/block_scout_web/test/block_scout_web/channels/websocket_v2_test.exs b/apps/block_scout_web/test/block_scout_web/channels/websocket_v2_test.exs index 5dc25c183c..918b636cb3 100644 --- a/apps/block_scout_web/test/block_scout_web/channels/websocket_v2_test.exs +++ b/apps/block_scout_web/test/block_scout_web/channels/websocket_v2_test.exs @@ -3,7 +3,7 @@ defmodule BlockScoutWeb.WebsocketV2Test do alias BlockScoutWeb.Notifier alias Explorer.Chain.Events.Subscriber - alias Explorer.Chain.{Address, Import, InternalTransaction, Log, Token, TokenTransfer, Transaction} + alias Explorer.Chain.{Address, Import, Token, TokenTransfer, Transaction} alias Explorer.Repo describe "websocket v2" do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_withdrawal_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_withdrawal_controller_test.exs index a6df1165ae..557c906ac1 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/address_withdrawal_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/address_withdrawal_controller_test.exs @@ -6,7 +6,7 @@ defmodule BlockScoutWeb.AddressWithdrawalControllerTest do import BlockScoutWeb.WeiHelper, only: [format_wei_value: 2] import Mox - alias Explorer.Chain.{Address, Transaction} + alias Explorer.Chain.Address alias Explorer.ExchangeRates.Token setup :verify_on_exit! diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs index de65f335d6..f46da387f7 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs @@ -410,7 +410,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do # these tests that tokens paginates by each parameter separately and by any combination of them test "pagination by address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, name: nil) end |> Enum.reverse() @@ -452,7 +452,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by name and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token) end |> Enum.reverse() @@ -462,7 +462,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by holders and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, holder_count: 1, name: nil) end |> Enum.reverse() @@ -472,7 +472,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by circulating_market_cap and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, circulating_market_cap: 1, name: nil) end |> Enum.reverse() @@ -511,7 +511,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by holders, name and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, holder_count: 1) end |> Enum.reverse() @@ -521,7 +521,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by circulating_market_cap, name and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, circulating_market_cap: 1) end |> Enum.reverse() @@ -531,7 +531,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by circulating_market_cap, holders and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, circulating_market_cap: 1, holder_count: 1, name: nil) end |> Enum.reverse() @@ -551,7 +551,7 @@ defmodule BlockScoutWeb.API.V2.TokenControllerTest do test "pagination by circulating_market_cap, holders, name and address", %{conn: conn} do tokens = - for i <- 0..50 do + for _i <- 0..50 do insert(:token, holder_count: 1, circulating_market_cap: 1) end |> Enum.reverse() diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/transaction_controller_test.exs index 14429b489b..944ee6c283 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/transaction_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/transaction_controller_test.exs @@ -1,9 +1,7 @@ defmodule BlockScoutWeb.API.V2.TransactionControllerTest do use BlockScoutWeb.ConnCase - import EthereumJSONRPC, only: [integer_to_quantity: 1] import Explorer.Chain, only: [hash_to_lower_case_string: 1] - import Mox alias BlockScoutWeb.Models.UserFromAuth alias Explorer.Account.WatchlistAddress @@ -964,36 +962,6 @@ defmodule BlockScoutWeb.API.V2.TransactionControllerTest do assert Address.checksum(transaction.to_address_hash) == json["to"]["hash"] end - defp compare_item(%Transaction{} = transaction, json, wl_names) do - assert to_string(transaction.hash) == json["hash"] - assert transaction.block_number == json["block"] - assert to_string(transaction.value.value) == json["value"] - assert Address.checksum(transaction.from_address_hash) == json["from"]["hash"] - assert Address.checksum(transaction.to_address_hash) == json["to"]["hash"] - - assert json["to"]["watchlist_names"] == - if(wl_names[transaction.to_address_hash], - do: [ - %{ - "display_name" => wl_names[transaction.to_address_hash], - "label" => wl_names[transaction.to_address_hash] - } - ], - else: [] - ) - - assert json["from"]["watchlist_names"] == - if(wl_names[transaction.from_address_hash], - do: [ - %{ - "display_name" => wl_names[transaction.from_address_hash], - "label" => wl_names[transaction.from_address_hash] - } - ], - else: [] - ) - end - defp compare_item(%InternalTransaction{} = internal_tx, json) do assert internal_tx.block_number == json["block"] assert to_string(internal_tx.gas) == json["gas_limit"] @@ -1029,10 +997,26 @@ defmodule BlockScoutWeb.API.V2.TransactionControllerTest do assert Address.checksum(transaction.to_address_hash) == json["to"]["hash"] assert json["to"]["watchlist_names"] == - if(wl_names[transaction.to_address_hash], do: [wl_names[transaction.to_address_hash]], else: []) + if(wl_names[transaction.to_address_hash], + do: [ + %{ + "display_name" => wl_names[transaction.to_address_hash], + "label" => wl_names[transaction.to_address_hash] + } + ], + else: [] + ) assert json["from"]["watchlist_names"] == - if(wl_names[transaction.from_address_hash], do: [wl_names[transaction.from_address_hash]], else: []) + if(wl_names[transaction.from_address_hash], + do: [ + %{ + "display_name" => wl_names[transaction.from_address_hash], + "label" => wl_names[transaction.from_address_hash] + } + ], + else: [] + ) end defp check_paginated_response(first_page_resp, second_page_resp, txs) do diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/withdrawal_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/withdrawal_controller_test.exs index 4645958e92..88320ec50b 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v2/withdrawal_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v2/withdrawal_controller_test.exs @@ -5,7 +5,7 @@ defmodule BlockScoutWeb.API.V2.WithdrawalControllerTest do describe "/withdrawals" do test "empty lists", %{conn: conn} do - request = get(conn, "/api/v2/blocks") + request = get(conn, "/api/v2/withdrawals") assert response = json_response(request, 200) assert response["items"] == [] assert response["next_page_params"] == nil diff --git a/apps/explorer/test/explorer/account/notify/email_test.exs b/apps/explorer/test/explorer/account/notify/email_test.exs index 34e5a57ad6..1163d9e32f 100644 --- a/apps/explorer/test/explorer/account/notify/email_test.exs +++ b/apps/explorer/test/explorer/account/notify/email_test.exs @@ -1,9 +1,6 @@ defmodule Explorer.Account.Notify.EmailTest do use ExUnit.Case - alias Explorer.Chain.Address - alias Explorer.Chain.Transaction - alias Explorer.Account.{ Identity, Watchlist, @@ -47,7 +44,6 @@ defmodule Explorer.Account.Notify.EmailTest do {:ok, from_hash} = string_to_address_hash("0x092D537737E767Dae48c28aE509f34094496f030") {:ok, to_hash} = string_to_address_hash("0xE1F4dd38f00B0D8D4d2b4B5010bE53F2A0b934E5") - to_address = %Address{hash: to_hash} identity = %Identity{ uid: "foo|bar", diff --git a/apps/explorer/test/explorer/chain/address/token_balance_test.exs b/apps/explorer/test/explorer/chain/address/token_balance_test.exs index bab58960fd..9a72837f6a 100644 --- a/apps/explorer/test/explorer/chain/address/token_balance_test.exs +++ b/apps/explorer/test/explorer/chain/address/token_balance_test.exs @@ -3,7 +3,6 @@ defmodule Explorer.Chain.Address.TokenBalanceTest do alias Explorer.Repo alias Explorer.Chain.Address.TokenBalance - alias Explorer.Chain describe "unfetched_token_balances/0" do test "returns only the token balances that have value_fetched_at nil" do diff --git a/apps/explorer/test/explorer/chain/cache/gas_price_oracle_test.exs b/apps/explorer/test/explorer/chain/cache/gas_price_oracle_test.exs index 148b8e8872..630301488a 100644 --- a/apps/explorer/test/explorer/chain/cache/gas_price_oracle_test.exs +++ b/apps/explorer/test/explorer/chain/cache/gas_price_oracle_test.exs @@ -2,7 +2,6 @@ defmodule Explorer.Chain.Cache.GasPriceOracleTest do use Explorer.DataCase alias Explorer.Chain.Cache.GasPriceOracle - alias Explorer.Repo describe "get_average_gas_price/4" do test "returns nil percentile values if no blocks in the DB" do diff --git a/apps/explorer/test/explorer/chain/import/runner/address/token_balances_test.exs b/apps/explorer/test/explorer/chain/import/runner/address/token_balances_test.exs index 15725869bd..40034eb841 100644 --- a/apps/explorer/test/explorer/chain/import/runner/address/token_balances_test.exs +++ b/apps/explorer/test/explorer/chain/import/runner/address/token_balances_test.exs @@ -208,7 +208,7 @@ defmodule Explorer.Chain.Import.Runner.Address.TokenBalancesTest do %{ address_token_balances: [ %TokenBalance{ - address_hash: address_hash, + address_hash: ^address_hash, block_number: ^block_number, token_contract_address_hash: ^token_contract_address_hash, token_id: nil, diff --git a/apps/explorer/test/explorer/chain/import/runner/blocks_test.exs b/apps/explorer/test/explorer/chain/import/runner/blocks_test.exs index ba012aba47..5a06a1a6a1 100644 --- a/apps/explorer/test/explorer/chain/import/runner/blocks_test.exs +++ b/apps/explorer/test/explorer/chain/import/runner/blocks_test.exs @@ -354,10 +354,9 @@ defmodule Explorer.Chain.Import.Runner.BlocksTest do %Ecto.Changeset{valid?: true, changes: block_changes} = Block.changeset(%Block{}, new_block) %Ecto.Changeset{valid?: true, changes: block_changes1} = Block.changeset(%Block{}, new_block1) - result = - Multi.new() - |> Blocks.run([block_changes, block_changes1], options) - |> Repo.transaction() + Multi.new() + |> Blocks.run([block_changes, block_changes1], options) + |> Repo.transaction() assert %{block_number: ^number, block_hash: ^hash} = Repo.one(PendingBlockOperation) end diff --git a/apps/explorer/test/explorer/chain/token_transfer_test.exs b/apps/explorer/test/explorer/chain/token_transfer_test.exs index da4720281a..29165457b7 100644 --- a/apps/explorer/test/explorer/chain/token_transfer_test.exs +++ b/apps/explorer/test/explorer/chain/token_transfer_test.exs @@ -3,7 +3,7 @@ defmodule Explorer.Chain.TokenTransferTest do import Explorer.Factory - alias Explorer.{PagingOptions, Repo} + alias Explorer.PagingOptions alias Explorer.Chain.TokenTransfer doctest Explorer.Chain.TokenTransfer diff --git a/apps/explorer/test/explorer/chain/withdrawal_test.exs b/apps/explorer/test/explorer/chain/withdrawal_test.exs index ebf88f3499..ab797f6172 100644 --- a/apps/explorer/test/explorer/chain/withdrawal_test.exs +++ b/apps/explorer/test/explorer/chain/withdrawal_test.exs @@ -3,7 +3,6 @@ defmodule Explorer.Chain.WithdrawalTest do alias Ecto.Changeset alias Explorer.Chain.Withdrawal - alias Explorer.Chain describe "changeset/2" do test "with valid attributes" do diff --git a/apps/explorer/test/explorer/exchange_rates/token_exchange_rates_test.exs b/apps/explorer/test/explorer/exchange_rates/token_exchange_rates_test.exs index 83dde6424a..9eb6b5189c 100644 --- a/apps/explorer/test/explorer/exchange_rates/token_exchange_rates_test.exs +++ b/apps/explorer/test/explorer/exchange_rates/token_exchange_rates_test.exs @@ -5,7 +5,6 @@ defmodule Explorer.TokenExchangeRatesTest do alias Plug.Conn alias Explorer.Chain.Token - alias Explorer.ExchangeRates alias Explorer.ExchangeRates.TokenExchangeRates @moduletag :capture_log @@ -100,7 +99,7 @@ defmodule Explorer.TokenExchangeRatesTest do base_url: "http://localhost:#{bypass.port}" ) - [_token_with_no_exchange_rate | tokens] = + [_token_with_no_exchange_rate | _tokens] = for _ <- 0..4 do insert(:token) end @@ -180,7 +179,7 @@ defmodule Explorer.TokenExchangeRatesTest do base_url: "http://localhost:#{bypass.port}" ) - [_token_with_no_exchange_rate | tokens] = + [_token_with_no_exchange_rate | _tokens] = for _ <- 0..4 do insert(:token) end diff --git a/apps/indexer/test/indexer/fetcher/coin_balance_on_demand_test.exs b/apps/indexer/test/indexer/fetcher/coin_balance_on_demand_test.exs index 0ae13b304a..d345ecee08 100644 --- a/apps/indexer/test/indexer/fetcher/coin_balance_on_demand_test.exs +++ b/apps/indexer/test/indexer/fetcher/coin_balance_on_demand_test.exs @@ -126,7 +126,7 @@ defmodule Indexer.Fetcher.CoinBalanceOnDemandTest do :timer.sleep(1000) - assert %{value: expected_wei} = Chain.get_coin_balance(address.hash, block_number) + assert %{value: ^expected_wei} = Chain.get_coin_balance(address.hash, block_number) end end diff --git a/apps/indexer/test/indexer/fetcher/pending_block_operations_sanitizer_test.ex b/apps/indexer/test/indexer/fetcher/pending_block_operations_sanitizer_test.exs similarity index 100% rename from apps/indexer/test/indexer/fetcher/pending_block_operations_sanitizer_test.ex rename to apps/indexer/test/indexer/fetcher/pending_block_operations_sanitizer_test.exs diff --git a/apps/indexer/test/indexer/fetcher/withdrawal_test.exs b/apps/indexer/test/indexer/fetcher/withdrawal_test.exs index cfe60e9e4a..f3b13f783a 100644 --- a/apps/indexer/test/indexer/fetcher/withdrawal_test.exs +++ b/apps/indexer/test/indexer/fetcher/withdrawal_test.exs @@ -5,7 +5,6 @@ defmodule Indexer.Fetcher.WithdrawalTest do import Mox import EthereumJSONRPC, only: [integer_to_quantity: 1] - alias Explorer.Chain alias Indexer.Fetcher.Withdrawal setup :verify_on_exit! diff --git a/config/runtime.exs b/config/runtime.exs index e6328f5319..0c28db6180 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -387,8 +387,7 @@ config :explorer, Explorer.Chain.Cache.TransactionActionTokensData, max_cache_size: ConfigHelper.parse_integer_env_var("INDEXER_TX_ACTIONS_MAX_TOKEN_CACHE_SIZE", 100_000) config :explorer, Explorer.Chain.Fetcher.LookUpSmartContractSourcesOnDemand, - fetch_interval: - ConfigHelper.parse_time_env_var("MICROSERVICE_MICROSERVICE_ETH_BYTECODE_DB_INTERVAL_BETWEEN_LOOKUPS", "10m") + fetch_interval: ConfigHelper.parse_time_env_var("MICROSERVICE_ETH_BYTECODE_DB_INTERVAL_BETWEEN_LOOKUPS", "10m") config :explorer, Explorer.Chain.Cache.MinMissingBlockNumber, enabled: !ConfigHelper.parse_bool_env_var("DISABLE_INDEXER")