Fix tests warning; Fix env name

pull/7789/head
Nikita Pozdniakov 1 year ago
parent 2c5f629777
commit e1fad11684
No known key found for this signature in database
GPG Key ID: F344106F9804FE5F
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/test/block_scout_web/channels/transaction_channel_test.exs
  3. 2
      apps/block_scout_web/test/block_scout_web/channels/websocket_v2_test.exs
  4. 2
      apps/block_scout_web/test/block_scout_web/controllers/address_withdrawal_controller_test.exs
  5. 16
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/token_controller_test.exs
  6. 52
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/transaction_controller_test.exs
  7. 2
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/withdrawal_controller_test.exs
  8. 4
      apps/explorer/test/explorer/account/notify/email_test.exs
  9. 1
      apps/explorer/test/explorer/chain/address/token_balance_test.exs
  10. 1
      apps/explorer/test/explorer/chain/cache/gas_price_oracle_test.exs
  11. 2
      apps/explorer/test/explorer/chain/import/runner/address/token_balances_test.exs
  12. 7
      apps/explorer/test/explorer/chain/import/runner/blocks_test.exs
  13. 2
      apps/explorer/test/explorer/chain/token_transfer_test.exs
  14. 1
      apps/explorer/test/explorer/chain/withdrawal_test.exs
  15. 5
      apps/explorer/test/explorer/exchange_rates/token_exchange_rates_test.exs
  16. 2
      apps/indexer/test/indexer/fetcher/coin_balance_on_demand_test.exs
  17. 0
      apps/indexer/test/indexer/fetcher/pending_block_operations_sanitizer_test.exs
  18. 1
      apps/indexer/test/indexer/fetcher/withdrawal_test.exs
  19. 3
      config/runtime.exs

@ -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`

@ -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

@ -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

@ -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!

@ -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()

@ -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

@ -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

@ -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",

@ -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

@ -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

@ -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,

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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!

@ -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")

Loading…
Cancel
Save