From 125b540871fce2a0baf98bd8d2e8b4d5fce648ad Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Tue, 17 Apr 2018 17:04:25 -0500 Subject: [PATCH] Increase credo and formatter columns to 120 --- .credo.exs | 2 +- .formatter.exs | 3 +- apps/explorer/config/prod.exs | 3 +- apps/explorer/lib/explorer/chain.ex | 12 +-- .../lib/explorer/workers/refresh_balance.ex | 3 +- apps/explorer/mix.exs | 3 +- .../test/explorer/chain/block_test.exs | 9 +-- .../test/explorer/chain/credit_test.exs | 6 +- .../test/explorer/chain/debit_test.exs | 6 +- .../test/explorer/chain/statistics_test.exs | 3 +- apps/explorer/test/explorer/chain_test.exs | 57 +++++-------- .../exchange_rates/exchange_rates_test.exs | 6 +- .../importers/block_importer_test.exs | 3 +- .../internal_transaction_importer_test.exs | 6 +- .../importers/receipt_importer_test.exs | 32 ++------ .../importers/transaction_importer_test.exs | 79 +++++-------------- .../explorer/workers/import_balance_test.exs | 3 +- .../import_internal_transaction_test.exs | 8 +- .../explorer/workers/import_receipt_test.exs | 8 +- .../workers/import_transaction_test.exs | 26 ++---- apps/explorer_web/lib/explorer_web/chain.ex | 3 +- .../controllers/block_controller.ex | 3 +- apps/explorer_web/lib/explorer_web/router.ex | 3 +- apps/explorer_web/mix.exs | 3 +- ...dress_transaction_from_controller_test.exs | 18 ++--- ...address_transaction_to_controller_test.exs | 18 ++--- .../controllers/block_controller_test.exs | 3 +- .../block_transaction_controller_test.exs | 3 +- .../controllers/chain_controller_test.exs | 3 +- .../transaction_controller_test.exs | 3 +- 30 files changed, 104 insertions(+), 234 deletions(-) diff --git a/.credo.exs b/.credo.exs index d970755679..248a2c9038 100644 --- a/.credo.exs +++ b/.credo.exs @@ -81,7 +81,7 @@ {Credo.Check.Design.TagFIXME}, {Credo.Check.Readability.FunctionNames}, {Credo.Check.Readability.LargeNumbers}, - {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 100}, + {Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 120}, {Credo.Check.Readability.ModuleAttributeNames}, {Credo.Check.Readability.ModuleDoc}, {Credo.Check.Readability.ModuleNames}, diff --git a/.formatter.exs b/.formatter.exs index 51047bc330..e1266c5057 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -6,5 +6,6 @@ "apps/*/{config,lib,test}/**/*.{ex,exs}", "mix.exs", "{config}/**/*.{ex,exs}" - ] + ], + line_length: 120 ] diff --git a/apps/explorer/config/prod.exs b/apps/explorer/config/prod.exs index 4f639639d1..df59624f0c 100644 --- a/apps/explorer/config/prod.exs +++ b/apps/explorer/config/prod.exs @@ -43,8 +43,7 @@ config :exq, queues: [ {"blocks", String.to_integer(System.get_env("EXQ_BLOCKS_CONCURRENCY") || "1")}, {"default", String.to_integer(System.get_env("EXQ_CONCURRENCY") || "1")}, - {"internal_transactions", - String.to_integer(System.get_env("EXQ_INTERNAL_TRANSACTIONS_CONCURRENCY") || "1")}, + {"internal_transactions", String.to_integer(System.get_env("EXQ_INTERNAL_TRANSACTIONS_CONCURRENCY") || "1")}, {"receipts", String.to_integer(System.get_env("EXQ_RECEIPTS_CONCURRENCY") || "1")}, {"transactions", String.to_integer(System.get_env("EXQ_TRANSACTIONS_CONCURRENCY") || "1")} ] diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 87b07f08f0..6ecacbf563 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -58,8 +58,9 @@ defmodule Explorer.Chain do * `:pagination` - pagination params to pass to scrivener. """ @spec block_to_transactions(Block.t()) :: %Scrivener.Page{entries: [Transaction.t()]} - @spec block_to_transactions(Block.t(), [necessity_by_association_option | pagination_option]) :: - %Scrivener.Page{entries: [Transaction.t()]} + @spec block_to_transactions(Block.t(), [necessity_by_association_option | pagination_option]) :: %Scrivener.Page{ + entries: [Transaction.t()] + } def block_to_transactions(%Block{id: block_id}, options \\ []) when is_list(options) do necessity_by_association = Keyword.get(options, :necessity_by_association, %{}) pagination = Keyword.get(options, :pagination, %{}) @@ -405,10 +406,9 @@ defmodule Explorer.Chain do then the `t:Explorer.Chain.InternalTransaction.t/0` will not be included in the list. """ - @spec transactions_recently_before_id(id :: non_neg_integer, [necessity_by_association_option]) :: - [ - Transaction.t() - ] + @spec transactions_recently_before_id(id :: non_neg_integer, [necessity_by_association_option]) :: [ + Transaction.t() + ] def transactions_recently_before_id(id, options \\ []) when is_list(options) do necessity_by_association = Keyword.get(options, :necessity_by_association, %{}) diff --git a/apps/explorer/lib/explorer/workers/refresh_balance.ex b/apps/explorer/lib/explorer/workers/refresh_balance.ex index c32960cb55..cadf0e1931 100644 --- a/apps/explorer/lib/explorer/workers/refresh_balance.ex +++ b/apps/explorer/lib/explorer/workers/refresh_balance.ex @@ -22,8 +22,7 @@ defmodule Explorer.Workers.RefreshBalance do def refreshing(table) do query = "REFRESH MATERIALIZED VIEW CONCURRENTLY #{table}%" - result = - SQL.query!(Repo, "SELECT TRUE FROM pg_stat_activity WHERE query ILIKE '$#{query}'", []) + result = SQL.query!(Repo, "SELECT TRUE FROM pg_stat_activity WHERE query ILIKE '$#{query}'", []) Enum.count(result.rows) > 0 end diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index 556b2f4c5e..ce64454425 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -46,8 +46,7 @@ defmodule Explorer.Mixfile do defp elixirc_paths, do: ["lib"] # Specifies extra applications to start per environment - defp extra_applications(:prod), - do: [:phoenix_pubsub_redis, :exq, :exq_ui | extra_applications()] + defp extra_applications(:prod), do: [:phoenix_pubsub_redis, :exq, :exq_ui | extra_applications()] defp extra_applications(:dev), do: [:exq, :exq_ui | extra_applications()] defp extra_applications(_), do: extra_applications() diff --git a/apps/explorer/test/explorer/chain/block_test.exs b/apps/explorer/test/explorer/chain/block_test.exs index 5442515376..da09d4000d 100644 --- a/apps/explorer/test/explorer/chain/block_test.exs +++ b/apps/explorer/test/explorer/chain/block_test.exs @@ -19,8 +19,7 @@ defmodule Explorer.Chain.BlockTest do test "with duplicate information" do insert(:block, hash: "0x0") - {:error, changeset} = - %Block{} |> Block.changeset(params_for(:block, hash: "0x0")) |> Repo.insert() + {:error, changeset} = %Block{} |> Block.changeset(params_for(:block, hash: "0x0")) |> Repo.insert() refute changeset.valid? assert changeset.errors == [hash: {"has already been taken", []}] @@ -29,8 +28,7 @@ defmodule Explorer.Chain.BlockTest do test "rejects duplicate blocks with mixed case" do insert(:block, hash: "0xa") - {:error, changeset} = - %Block{} |> Block.changeset(params_for(:block, hash: "0xA")) |> Repo.insert() + {:error, changeset} = %Block{} |> Block.changeset(params_for(:block, hash: "0xA")) |> Repo.insert() refute changeset.valid? assert changeset.errors == [hash: {"has already been taken", []}] @@ -48,8 +46,7 @@ defmodule Explorer.Chain.BlockTest do insert(:block, number: 1) insert(:block, number: 5) - assert Block |> Block.latest() |> Repo.all() == - Block |> order_by(desc: :number) |> Repo.all() + assert Block |> Block.latest() |> Repo.all() == Block |> order_by(desc: :number) |> Repo.all() end end end diff --git a/apps/explorer/test/explorer/chain/credit_test.exs b/apps/explorer/test/explorer/chain/credit_test.exs index ec1ea530b5..1fb1fb059f 100644 --- a/apps/explorer/test/explorer/chain/credit_test.exs +++ b/apps/explorer/test/explorer/chain/credit_test.exs @@ -28,8 +28,7 @@ defmodule Explorer.Chain.CreditTest do recipient = insert(:address) sender = insert(:address) - transaction = - insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) + transaction = insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) insert(:receipt, transaction: transaction, status: 1) address_id = sender.id @@ -42,8 +41,7 @@ defmodule Explorer.Chain.CreditTest do recipient = insert(:address) sender = insert(:address) - transaction = - insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) + transaction = insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) insert(:receipt, transaction: transaction, status: 1) address_id = recipient.id diff --git a/apps/explorer/test/explorer/chain/debit_test.exs b/apps/explorer/test/explorer/chain/debit_test.exs index 884a961c89..7d89e85ab9 100644 --- a/apps/explorer/test/explorer/chain/debit_test.exs +++ b/apps/explorer/test/explorer/chain/debit_test.exs @@ -28,8 +28,7 @@ defmodule Explorer.Chain.DebitTest do recipient = insert(:address) sender = insert(:address) - transaction = - insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) + transaction = insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) insert(:receipt, transaction: transaction, status: 1) address_id = sender.id @@ -42,8 +41,7 @@ defmodule Explorer.Chain.DebitTest do recipient = insert(:address) sender = insert(:address) - transaction = - insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) + transaction = insert(:transaction, value: 21, to_address_id: recipient.id, from_address_id: sender.id) insert(:receipt, transaction: transaction, status: 1) address_id = recipient.id diff --git a/apps/explorer/test/explorer/chain/statistics_test.exs b/apps/explorer/test/explorer/chain/statistics_test.exs index adb1d43152..f0171f5072 100644 --- a/apps/explorer/test/explorer/chain/statistics_test.exs +++ b/apps/explorer/test/explorer/chain/statistics_test.exs @@ -69,8 +69,7 @@ defmodule Explorer.Chain.StatisticsTest do inserted_at = validation_time |> Timex.shift(seconds: 5) insert(:block, timestamp: validation_time, inserted_at: inserted_at) - assert %Statistics{lag: %Duration{seconds: 5, megaseconds: 0, microseconds: 0}} = - Statistics.fetch() + assert %Statistics{lag: %Duration{seconds: 5, megaseconds: 0, microseconds: 0}} = Statistics.fetch() end test "returns the number of blocks inserted in the last minute" do diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index 6a5f06f957..c9b8b583d7 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -92,8 +92,7 @@ defmodule Explorer.ChainTest do insert(:block_transaction, block_id: block_id, transaction_id: transaction_id) end) - [%Transaction{id: first_transaction_id}, %Transaction{id: second_transaction_id}] = - transactions + [%Transaction{id: first_transaction_id}, %Transaction{id: second_transaction_id}] = transactions assert %Scrivener.Page{ entries: [%Transaction{id: ^first_transaction_id}], @@ -144,8 +143,7 @@ defmodule Explorer.ChainTest do assert block.number < max_block_number - assert Chain.confirmations(block, max_block_number: max_block_number) == - max_block_number - block.number + assert Chain.confirmations(block, max_block_number: max_block_number) == max_block_number - block.number end end @@ -188,18 +186,15 @@ defmodule Explorer.ChainTest do end test ":gwei unit" do - assert Chain.gas_price(%Transaction{gas_price: Decimal.new(1)}, :gwei) == - Decimal.new("1e-9") + assert Chain.gas_price(%Transaction{gas_price: Decimal.new(1)}, :gwei) == Decimal.new("1e-9") assert Chain.gas_price(%Transaction{gas_price: Decimal.new("1e9")}, :gwei) == Decimal.new(1) end test ":ether unit" do - assert Chain.gas_price(%Transaction{gas_price: Decimal.new(1)}, :ether) == - Decimal.new("1e-18") + assert Chain.gas_price(%Transaction{gas_price: Decimal.new(1)}, :ether) == Decimal.new("1e-18") - assert Chain.gas_price(%Transaction{gas_price: Decimal.new("1e18")}, :ether) == - Decimal.new(1) + assert Chain.gas_price(%Transaction{gas_price: Decimal.new("1e18")}, :ether) == Decimal.new(1) end end @@ -230,13 +225,11 @@ defmodule Explorer.ChainTest do test "with transactions with receipt required without receipt does not return transaction" do address = %Address{id: from_address_id} = insert(:address) - %Transaction{id: transaction_id_with_receipt} = - insert(:transaction, from_address_id: from_address_id) + %Transaction{id: transaction_id_with_receipt} = insert(:transaction, from_address_id: from_address_id) insert(:receipt, transaction_id: transaction_id_with_receipt) - %Transaction{id: transaction_id_without_receipt} = - insert(:transaction, from_address_id: from_address_id) + %Transaction{id: transaction_id_without_receipt} = insert(:transaction, from_address_id: from_address_id) assert %Scrivener.Page{ entries: [%Transaction{id: ^transaction_id_with_receipt, receipt: %Receipt{}}], @@ -273,8 +266,7 @@ defmodule Explorer.ChainTest do adddress = %Address{id: from_address_id} = insert(:address) transactions = insert_list(2, :transaction, from_address_id: from_address_id) - [%Transaction{id: oldest_transaction_id}, %Transaction{id: newest_transaction_id}] = - transactions + [%Transaction{id: oldest_transaction_id}, %Transaction{id: newest_transaction_id}] = transactions assert %Scrivener.Page{ entries: [%Transaction{id: ^newest_transaction_id}], @@ -290,8 +282,7 @@ defmodule Explorer.ChainTest do page_size: 1, total_entries: 2, total_pages: 2 - } = - Chain.from_address_to_transactions(adddress, pagination: %{page: 2, page_size: 1}) + } = Chain.from_address_to_transactions(adddress, pagination: %{page: 2, page_size: 1}) end end @@ -321,8 +312,7 @@ defmodule Explorer.ChainTest do end test "with transaction with receipt required without receipt returns {:error, :not_found}" do - %Transaction{hash: hash_with_receipt, id: transaction_id_with_receipt} = - insert(:transaction) + %Transaction{hash: hash_with_receipt, id: transaction_id_with_receipt} = insert(:transaction) insert(:receipt, transaction_id: transaction_id_with_receipt) @@ -479,13 +469,11 @@ defmodule Explorer.ChainTest do test "with transactions with receipt required without receipt does not return transaction" do address = %Address{id: to_address_id} = insert(:address) - %Transaction{id: transaction_id_with_receipt} = - insert(:transaction, to_address_id: to_address_id) + %Transaction{id: transaction_id_with_receipt} = insert(:transaction, to_address_id: to_address_id) insert(:receipt, transaction_id: transaction_id_with_receipt) - %Transaction{id: transaction_id_without_receipt} = - insert(:transaction, to_address_id: to_address_id) + %Transaction{id: transaction_id_without_receipt} = insert(:transaction, to_address_id: to_address_id) assert %Scrivener.Page{ entries: [%Transaction{id: ^transaction_id_with_receipt, receipt: %Receipt{}}], @@ -522,8 +510,7 @@ defmodule Explorer.ChainTest do adddress = %Address{id: to_address_id} = insert(:address) transactions = insert_list(2, :transaction, to_address_id: to_address_id) - [%Transaction{id: oldest_transaction_id}, %Transaction{id: newest_transaction_id}] = - transactions + [%Transaction{id: oldest_transaction_id}, %Transaction{id: newest_transaction_id}] = transactions assert %Scrivener.Page{ entries: [%Transaction{id: ^newest_transaction_id}], @@ -643,11 +630,9 @@ defmodule Explorer.ChainTest do insert(:receipt, transaction_id: id) end) - assert length(Chain.transactions_recently_before_id(last_transaction_id, pending: true)) == - 8 + assert length(Chain.transactions_recently_before_id(last_transaction_id, pending: true)) == 8 - assert length(Chain.transactions_recently_before_id(last_transaction_id, pending: false)) == - 10 + assert length(Chain.transactions_recently_before_id(last_transaction_id, pending: false)) == 10 assert length(Chain.transactions_recently_before_id(last_transaction_id)) == 10 end @@ -761,8 +746,7 @@ defmodule Explorer.ChainTest do Chain.update_balance(hash, 88) - assert {:ok, %Address{balance_updated_at: balance_updated_at}} = - Chain.hash_to_address("0xtwizzlers") + assert {:ok, %Address{balance_updated_at: balance_updated_at}} = Chain.hash_to_address("0xtwizzlers") refute is_nil(balance_updated_at) end @@ -782,18 +766,15 @@ defmodule Explorer.ChainTest do end test "with InternalTransaction.t with :gwei" do - assert Chain.value(%InternalTransaction{value: Decimal.new(1)}, :gwei) == - Decimal.new("1e-9") + assert Chain.value(%InternalTransaction{value: Decimal.new(1)}, :gwei) == Decimal.new("1e-9") assert Chain.value(%InternalTransaction{value: Decimal.new("1e9")}, :gwei) == Decimal.new(1) end test "with InternalTransaction.t with :ether" do - assert Chain.value(%InternalTransaction{value: Decimal.new(1)}, :ether) == - Decimal.new("1e-18") + assert Chain.value(%InternalTransaction{value: Decimal.new(1)}, :ether) == Decimal.new("1e-18") - assert Chain.value(%InternalTransaction{value: Decimal.new("1e18")}, :ether) == - Decimal.new(1) + assert Chain.value(%InternalTransaction{value: Decimal.new("1e18")}, :ether) == Decimal.new(1) end test "with Transaction.t with :wei" do diff --git a/apps/explorer/test/explorer/exchange_rates/exchange_rates_test.exs b/apps/explorer/test/explorer/exchange_rates/exchange_rates_test.exs index 8f3b80a0d0..d6102c96ed 100644 --- a/apps/explorer/test/explorer/exchange_rates/exchange_rates_test.exs +++ b/apps/explorer/test/explorer/exchange_rates/exchange_rates_test.exs @@ -62,8 +62,7 @@ defmodule Explorer.ExchangeRatesTest do id = expected_rate.id state = %{} - assert {:noreply, ^state} = - ExchangeRates.handle_info({nil, {id, {:ok, expected_rate}}}, state) + assert {:noreply, ^state} = ExchangeRates.handle_info({nil, {id, {:ok, expected_rate}}}, state) assert [{^id, ^expected_rate}] = :ets.lookup(ExchangeRates.table_name(), id) end @@ -75,8 +74,7 @@ defmodule Explorer.ExchangeRatesTest do expect(TestSource, :fetch_exchange_rate, fn "failed-ticker" -> {:ok, %Rate{}} end) set_mox_global() - assert {:noreply, ^state} = - ExchangeRates.handle_info({nil, {ticker, {:error, "some error"}}}, state) + assert {:noreply, ^state} = ExchangeRates.handle_info({nil, {ticker, {:error, "some error"}}}, state) assert_receive {_, {^ticker, {:ok, _}}} end diff --git a/apps/explorer/test/explorer/importers/block_importer_test.exs b/apps/explorer/test/explorer/importers/block_importer_test.exs index 94e167d82c..3db5a80652 100644 --- a/apps/explorer/test/explorer/importers/block_importer_test.exs +++ b/apps/explorer/test/explorer/importers/block_importer_test.exs @@ -14,8 +14,7 @@ defmodule Explorer.BlockImporterTest do BlockImporter.import("0xc4f0d") block = Block |> order_by(desc: :inserted_at) |> Repo.one() - assert block.hash == - "0x16cb43ccfb7875c14eb3f03bdc098e4af053160544270594fa429d256cbca64e" + assert block.hash == "0x16cb43ccfb7875c14eb3f03bdc098e4af053160544270594fa429d256cbca64e" end end end diff --git a/apps/explorer/test/explorer/importers/internal_transaction_importer_test.exs b/apps/explorer/test/explorer/importers/internal_transaction_importer_test.exs index dc29b3e648..e755c75cac 100644 --- a/apps/explorer/test/explorer/importers/internal_transaction_importer_test.exs +++ b/apps/explorer/test/explorer/importers/internal_transaction_importer_test.exs @@ -29,8 +29,7 @@ defmodule Explorer.InternalTransactionImporterTest do InternalTransactionImporter.import(transaction.hash) - last_internal_transaction = - InternalTransaction |> order_by(desc: :index) |> limit(1) |> Repo.one() + last_internal_transaction = InternalTransaction |> order_by(desc: :index) |> limit(1) |> Repo.one() assert last_internal_transaction.index == 1 end @@ -46,8 +45,7 @@ defmodule Explorer.InternalTransactionImporterTest do InternalTransactionImporter.import(transaction.hash) - last_internal_transaction = - InternalTransaction |> order_by(desc: :index) |> limit(1) |> Repo.one() + last_internal_transaction = InternalTransaction |> order_by(desc: :index) |> limit(1) |> Repo.one() assert last_internal_transaction.call_type == "create" end diff --git a/apps/explorer/test/explorer/importers/receipt_importer_test.exs b/apps/explorer/test/explorer/importers/receipt_importer_test.exs index b5115e08af..580839f256 100644 --- a/apps/explorer/test/explorer/importers/receipt_importer_test.exs +++ b/apps/explorer/test/explorer/importers/receipt_importer_test.exs @@ -13,9 +13,7 @@ defmodule Explorer.ReceiptImporterTest do ) use_cassette "transaction_importer_import_1_receipt" do - ReceiptImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + ReceiptImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") receipt = Receipt |> preload([:transaction]) |> Repo.one() assert receipt.transaction == transaction @@ -29,9 +27,7 @@ defmodule Explorer.ReceiptImporterTest do ) use_cassette "transaction_importer_import_1_receipt" do - ReceiptImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + ReceiptImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") receipt = Receipt |> preload([:transaction]) |> Repo.one() log = Log |> preload(receipt: :transaction) |> Repo.one() @@ -48,9 +44,7 @@ defmodule Explorer.ReceiptImporterTest do address = insert(:address, hash: "0x353fe3ffbf77edef7f9c352c47965a38c07e837c") use_cassette "transaction_importer_import_1_receipt" do - ReceiptImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + ReceiptImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") log = Log |> preload([:address]) |> Repo.one() assert log.address == address @@ -64,9 +58,7 @@ defmodule Explorer.ReceiptImporterTest do ) use_cassette "transaction_importer_import_1_failed" do - ReceiptImporter.import( - "0x2532864dc2e0d0bc2dfabf4685c0c03dbdbe9cf67ebc593fc82d41087ab71435" - ) + ReceiptImporter.import("0x2532864dc2e0d0bc2dfabf4685c0c03dbdbe9cf67ebc593fc82d41087ab71435") receipt = Repo.one(Receipt) assert receipt.status == 0 @@ -80,9 +72,7 @@ defmodule Explorer.ReceiptImporterTest do ) use_cassette "transaction_importer_import_1_out_of_gas" do - ReceiptImporter.import( - "0x702e518267b0a57e4cb44b9db100afe4d7115f2d2650466a8c376f3dbb77eb35" - ) + ReceiptImporter.import("0x702e518267b0a57e4cb44b9db100afe4d7115f2d2650466a8c376f3dbb77eb35") receipt = Repo.one(Receipt) assert receipt.status == 0 @@ -99,9 +89,7 @@ defmodule Explorer.ReceiptImporterTest do insert(:receipt, transaction: transaction) use_cassette "transaction_importer_import_1_receipt" do - ReceiptImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + ReceiptImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") assert Repo.all(Receipt) |> Enum.count() == 1 end @@ -109,9 +97,7 @@ defmodule Explorer.ReceiptImporterTest do test "does not import a receipt for a nonexistent transaction" do use_cassette "transaction_importer_import_1_receipt" do - ReceiptImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + ReceiptImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") assert Repo.all(Receipt) |> Enum.count() == 0 end @@ -124,9 +110,7 @@ defmodule Explorer.ReceiptImporterTest do ) use_cassette "transaction_importer_import_1_pending" do - ReceiptImporter.import( - "0xde791cfcde3900d4771e5fcf8c11dc305714118df7aa7e42f84576e64dbf6246" - ) + ReceiptImporter.import("0xde791cfcde3900d4771e5fcf8c11dc305714118df7aa7e42f84576e64dbf6246") assert Repo.all(Receipt) |> Enum.count() == 0 end diff --git a/apps/explorer/test/explorer/importers/transaction_importer_test.exs b/apps/explorer/test/explorer/importers/transaction_importer_test.exs index d62d9cf6f9..9e97a1d97e 100644 --- a/apps/explorer/test/explorer/importers/transaction_importer_test.exs +++ b/apps/explorer/test/explorer/importers/transaction_importer_test.exs @@ -40,14 +40,11 @@ defmodule Explorer.TransactionImporterTest do describe "import/1" do test "imports and saves a transaction to the database" do use_cassette "transaction_importer_import_saves_the_transaction" do - TransactionImporter.import( - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" - ) + TransactionImporter.import("0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291") transaction = Transaction |> order_by(desc: :inserted_at) |> Repo.one() - assert transaction.hash == - "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" + assert transaction.hash == "0xdc3a0dfd0bbffd5eabbe40fb13afbe35ac5f5c030bff148f3e50afe32974b291" end end @@ -59,9 +56,7 @@ defmodule Explorer.TransactionImporterTest do gas: 5 ) - TransactionImporter.import( - "0x170baac4eca26076953370dd603c68eab340c0135b19b585010d3158a5dbbf23" - ) + TransactionImporter.import("0x170baac4eca26076953370dd603c68eab340c0135b19b585010d3158a5dbbf23") transaction = Transaction |> order_by(desc: :inserted_at) |> Repo.one() @@ -77,15 +72,11 @@ defmodule Explorer.TransactionImporterTest do hash: "0xfce13392435a8e7dab44c07d482212efb9dc39a9bea1915a9ead308b55a617f9" ) - TransactionImporter.import( - "0x64d851139325479c3bb7ccc6e6ab4cde5bc927dce6810190fe5d770a4c1ac333" - ) + TransactionImporter.import("0x64d851139325479c3bb7ccc6e6ab4cde5bc927dce6810190fe5d770a4c1ac333") transaction = Transaction - |> Repo.get_by( - hash: "0x64d851139325479c3bb7ccc6e6ab4cde5bc927dce6810190fe5d770a4c1ac333" - ) + |> Repo.get_by(hash: "0x64d851139325479c3bb7ccc6e6ab4cde5bc927dce6810190fe5d770a4c1ac333") block_transaction = BlockTransaction |> Repo.get_by(transaction_id: transaction.id) @@ -95,15 +86,11 @@ defmodule Explorer.TransactionImporterTest do test "when there is no block it does not save a block transaction" do use_cassette "transaction_importer_txn_without_block" do - TransactionImporter.import( - "0xc6aa189827c14880f012a65292f7add7b5310094f8773a3d85b66303039b9dcf" - ) + TransactionImporter.import("0xc6aa189827c14880f012a65292f7add7b5310094f8773a3d85b66303039b9dcf") transaction = Transaction - |> Repo.get_by( - hash: "0xc6aa189827c14880f012a65292f7add7b5310094f8773a3d85b66303039b9dcf" - ) + |> Repo.get_by(hash: "0xc6aa189827c14880f012a65292f7add7b5310094f8773a3d85b66303039b9dcf") block_transaction = BlockTransaction |> Repo.get_by(transaction_id: transaction.id) @@ -113,15 +100,11 @@ defmodule Explorer.TransactionImporterTest do test "creates a from address" do use_cassette "transaction_importer_creates_a_from_address" do - TransactionImporter.import( - "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d" - ) + TransactionImporter.import("0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d") transaction = Transaction - |> Repo.get_by( - hash: "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d" - ) + |> Repo.get_by(hash: "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d") address = Address |> Repo.get_by(hash: "0xa5b4b372112ab8dbbb48c8d0edd89227e24ec785") @@ -133,15 +116,11 @@ defmodule Explorer.TransactionImporterTest do insert(:address, hash: "0xa5b4b372112ab8dbbb48c8d0edd89227e24ec785") use_cassette "transaction_importer_creates_a_from_address" do - TransactionImporter.import( - "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d" - ) + TransactionImporter.import("0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d") transaction = Transaction - |> Repo.get_by( - hash: "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d" - ) + |> Repo.get_by(hash: "0xc445f5410912458c480d992dd93355ae3dad64d9f65db25a3cf43a9c609a2e0d") address = Address |> Repo.get_by(hash: "0xa5b4b372112ab8dbbb48c8d0edd89227e24ec785") @@ -151,15 +130,11 @@ defmodule Explorer.TransactionImporterTest do test "creates a to address" do use_cassette "transaction_importer_creates_a_to_address" do - TransactionImporter.import( - "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + TransactionImporter.import("0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") transaction = Transaction - |> Repo.get_by( - hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + |> Repo.get_by(hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") address = Address |> Repo.get_by(hash: "0x24e5b8528fe83257d5fe3497ef616026713347f8") @@ -171,15 +146,11 @@ defmodule Explorer.TransactionImporterTest do insert(:address, hash: "0x24e5b8528fe83257d5fe3497ef616026713347f8") use_cassette "transaction_importer_creates_a_to_address" do - TransactionImporter.import( - "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + TransactionImporter.import("0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") transaction = Transaction - |> Repo.get_by( - hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + |> Repo.get_by(hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") address = Address |> Repo.get_by(hash: "0x24e5b8528fe83257d5fe3497ef616026713347f8") @@ -189,15 +160,11 @@ defmodule Explorer.TransactionImporterTest do test "creates a to address using creates when to is nil" do use_cassette "transaction_importer_creates_a_to_address_from_creates" do - TransactionImporter.import( - "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + TransactionImporter.import("0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") transaction = Transaction - |> Repo.get_by( - hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + |> Repo.get_by(hash: "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") address = Address |> Repo.get_by(hash: "0x24e5b8528fe83257d5fe3497ef616026713347f8") @@ -208,9 +175,7 @@ defmodule Explorer.TransactionImporterTest do test "processes a map of transaction attributes" do insert(:block, hash: "0xtakis") - TransactionImporter.import( - Map.merge(@raw_transaction, %{"hash" => "0xmunchos", "blockHash" => "0xtakis"}) - ) + TransactionImporter.import(Map.merge(@raw_transaction, %{"hash" => "0xmunchos", "blockHash" => "0xtakis"})) last_transaction = Transaction |> order_by(desc: :inserted_at) |> limit(1) |> Repo.one() @@ -218,9 +183,7 @@ defmodule Explorer.TransactionImporterTest do end test "gets balances for addresses" do - TransactionImporter.import( - "0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c" - ) + TransactionImporter.import("0xdc533d4227734a7cacd75a069e8dc57ac571b865ed97bae5ea4cb74b54145f4c") from_address = Address |> Repo.get_by(hash: "0xb2867180771b196518651c174c9240d5e8bd0ecd") to_address = Address |> Repo.get_by(hash: "0x24e5b8528fe83257d5fe3497ef616026713347f8") @@ -245,9 +208,7 @@ defmodule Explorer.TransactionImporterTest do test "downloads a transaction" do use_cassette "transaction_importer_download_transaction" do raw_transaction = - TransactionImporter.download_transaction( - "0x170baac4eca26076953370dd603c68eab340c0135b19b585010d3158a5dbbf23" - ) + TransactionImporter.download_transaction("0x170baac4eca26076953370dd603c68eab340c0135b19b585010d3158a5dbbf23") assert(raw_transaction["from"] == "0xbe96ef1d056c97323e210fd0dd818aa027e57143") end diff --git a/apps/explorer/test/explorer/workers/import_balance_test.exs b/apps/explorer/test/explorer/workers/import_balance_test.exs index a62db89f56..f7b340cdd4 100644 --- a/apps/explorer/test/explorer/workers/import_balance_test.exs +++ b/apps/explorer/test/explorer/workers/import_balance_test.exs @@ -32,8 +32,7 @@ defmodule Explorer.Workers.ImportBalanceTest do expected_balance = Decimal.new(66) - assert {:ok, %Address{balance: ^expected_balance}} = - Chain.hash_to_address("0xskateboards") + assert {:ok, %Address{balance: ^expected_balance}} = Chain.hash_to_address("0xskateboards") end end end diff --git a/apps/explorer/test/explorer/workers/import_internal_transaction_test.exs b/apps/explorer/test/explorer/workers/import_internal_transaction_test.exs index 26e920ce0b..c84ba424ea 100644 --- a/apps/explorer/test/explorer/workers/import_internal_transaction_test.exs +++ b/apps/explorer/test/explorer/workers/import_internal_transaction_test.exs @@ -9,9 +9,7 @@ defmodule Explorer.Workers.ImportInternalTransactionTest do test "does not import the internal transactions when no transaction with the hash exists" do use_cassette "import_internal_transaction_perform_1" do assert_raise Ecto.NoResultsError, fn -> - ImportInternalTransaction.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportInternalTransaction.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") end end end @@ -23,9 +21,7 @@ defmodule Explorer.Workers.ImportInternalTransactionTest do ) use_cassette "import_internal_transaction_perform_1" do - ImportInternalTransaction.perform( - "0x051e031f05b3b3a5ff73e1189c36e3e2a41fd1c2d9772b2c75349e22ed4d3f68" - ) + ImportInternalTransaction.perform("0x051e031f05b3b3a5ff73e1189c36e3e2a41fd1c2d9772b2c75349e22ed4d3f68") internal_transaction_count = InternalTransaction |> Repo.all() |> Enum.count() assert internal_transaction_count == 2 diff --git a/apps/explorer/test/explorer/workers/import_receipt_test.exs b/apps/explorer/test/explorer/workers/import_receipt_test.exs index 496b2bf819..2e260762fe 100644 --- a/apps/explorer/test/explorer/workers/import_receipt_test.exs +++ b/apps/explorer/test/explorer/workers/import_receipt_test.exs @@ -8,9 +8,7 @@ defmodule Explorer.Workers.ImportReceiptTest do describe "perform/1" do test "does not import a receipt when no transaction with the hash exists" do use_cassette "import_receipt_perform_1" do - ImportReceipt.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportReceipt.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") assert Repo.one(Receipt) == nil end @@ -23,9 +21,7 @@ defmodule Explorer.Workers.ImportReceiptTest do ) use_cassette "import_receipt_perform_1" do - ImportReceipt.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportReceipt.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") receipt_count = Receipt |> Repo.all() |> Enum.count() assert receipt_count == 1 diff --git a/apps/explorer/test/explorer/workers/import_transaction_test.exs b/apps/explorer/test/explorer/workers/import_transaction_test.exs index d7203b0b8f..790c98ad6a 100644 --- a/apps/explorer/test/explorer/workers/import_transaction_test.exs +++ b/apps/explorer/test/explorer/workers/import_transaction_test.exs @@ -12,15 +12,12 @@ defmodule Explorer.Workers.ImportTransactionTest do test "imports the requested transaction hash" do use_cassette "import_transaction_perform_1" do with_mock Exq, enqueue: fn _, _, _, _ -> :ok end do - ImportTransaction.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportTransaction.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") end transaction = Transaction |> Repo.one() - assert transaction.hash == - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" + assert transaction.hash == "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" end end @@ -32,9 +29,7 @@ defmodule Explorer.Workers.ImportTransactionTest do use_cassette "import_transaction_perform_1" do with_mock Exq, enqueue: fn _, _, _, _ -> :ok end do - ImportTransaction.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportTransaction.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") end transaction_count = Transaction |> Repo.all() |> Enum.count() @@ -52,9 +47,7 @@ defmodule Explorer.Workers.ImportTransactionTest do use_cassette "import_transaction_perform_1" do with_mock Exq, enqueue: fn _, _, _, _ -> insert(:receipt, transaction: transaction) end do with_mock ImportInternalTransaction, perform_later: fn _ -> :ok end do - ImportTransaction.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportTransaction.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") receipt = Repo.one(Receipt) refute is_nil(receipt) @@ -98,9 +91,7 @@ defmodule Explorer.Workers.ImportTransactionTest do with_mock Exq, enqueue: fn _, _, _, _ -> :ok end do with_mock ImportInternalTransaction, perform_later: fn _ -> insert(:internal_transaction, transaction: transaction) end do - ImportTransaction.perform( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportTransaction.perform("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") internal_transaction = Repo.one(InternalTransaction) refute is_nil(internal_transaction) @@ -145,14 +136,11 @@ defmodule Explorer.Workers.ImportTransactionTest do hash: "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" ) end do - ImportTransaction.perform_later( - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" - ) + ImportTransaction.perform_later("0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926") transaction = Repo.one(Transaction) - assert transaction.hash == - "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" + assert transaction.hash == "0xf9a0959d5ccde33ec5221ddba1c6d7eaf9580a8d3512c7a1a60301362a98f926" end end end diff --git a/apps/explorer_web/lib/explorer_web/chain.ex b/apps/explorer_web/lib/explorer_web/chain.ex index 7dfccf1d3b..b513852c75 100644 --- a/apps/explorer_web/lib/explorer_web/chain.ex +++ b/apps/explorer_web/lib/explorer_web/chain.ex @@ -5,8 +5,7 @@ defmodule ExplorerWeb.Chain do import Explorer.Chain, only: [hash_to_address: 1, hash_to_transaction: 1, number_to_block: 1] - @spec from_param(String.t()) :: - {:ok, Address.t() | Transaction.t() | Block.t()} | {:error, :not_found} + @spec from_param(String.t()) :: {:ok, Address.t() | Transaction.t() | Block.t()} | {:error, :not_found} def from_param(param) def from_param(hash) when byte_size(hash) > 42 do diff --git a/apps/explorer_web/lib/explorer_web/controllers/block_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/block_controller.ex index de9d5bfa6f..18f8d39e29 100644 --- a/apps/explorer_web/lib/explorer_web/controllers/block_controller.ex +++ b/apps/explorer_web/lib/explorer_web/controllers/block_controller.ex @@ -4,8 +4,7 @@ defmodule ExplorerWeb.BlockController do alias Explorer.Chain def index(conn, params) do - blocks = - Chain.list_blocks(necessity_by_association: %{transactions: :optional}, pagination: params) + blocks = Chain.list_blocks(necessity_by_association: %{transactions: :optional}, pagination: params) render(conn, "index.html", blocks: blocks) end diff --git a/apps/explorer_web/lib/explorer_web/router.ex b/apps/explorer_web/lib/explorer_web/router.ex index 42cd8a3b4c..a127242e6d 100644 --- a/apps/explorer_web/lib/explorer_web/router.ex +++ b/apps/explorer_web/lib/explorer_web/router.ex @@ -40,8 +40,7 @@ defmodule ExplorerWeb.Router do end pipeline :jasmine do - if Mix.env() != :prod, - do: plug(Jasmine, js_files: ["js/test.js"], css_files: ["css/test.css"]) + if Mix.env() != :prod, do: plug(Jasmine, js_files: ["js/test.js"], css_files: ["css/test.css"]) end pipeline :api do diff --git a/apps/explorer_web/mix.exs b/apps/explorer_web/mix.exs index b9229ca2f8..bcfde155e4 100644 --- a/apps/explorer_web/mix.exs +++ b/apps/explorer_web/mix.exs @@ -46,8 +46,7 @@ defmodule ExplorerWeb.Mixfile do defp elixirc_paths, do: ["lib"] # Specifies extra applications to start per environment - defp extra_applications(:prod), - do: [:phoenix_pubsub_redis, :exq, :exq_ui | extra_applications()] + defp extra_applications(:prod), do: [:phoenix_pubsub_redis, :exq, :exq_ui | extra_applications()] defp extra_applications(:dev), do: [:exq, :exq_ui | extra_applications()] defp extra_applications(_), do: extra_applications() diff --git a/apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs index d3bf358d14..20822fe276 100644 --- a/apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/address_transaction_from_controller_test.exs @@ -18,13 +18,11 @@ defmodule ExplorerWeb.AddressTransactionFromControllerTest do block = insert(:block) insert(:block_transaction, transaction: transaction, block: block) - conn = - get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) - transaction_hash_divs = - Floki.find(html, "td.transactions__column--hash div.transactions__hash a") + transaction_hash_divs = Floki.find(html, "td.transactions__column--hash div.transactions__hash a") assert length(transaction_hash_divs) == 1 @@ -43,8 +41,7 @@ defmodule ExplorerWeb.AddressTransactionFromControllerTest do insert(:to_address, transaction: transaction, address: address) insert(:from_address, transaction: transaction, address: other_address) - conn = - get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -58,8 +55,7 @@ defmodule ExplorerWeb.AddressTransactionFromControllerTest do insert(:to_address, transaction: transaction, address: address) insert(:from_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -73,8 +69,7 @@ defmodule ExplorerWeb.AddressTransactionFromControllerTest do address = insert(:address) insert(:to_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -88,8 +83,7 @@ defmodule ExplorerWeb.AddressTransactionFromControllerTest do address = insert(:address) insert(:from_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_from_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 diff --git a/apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs index b969da3bee..e813d99dfe 100644 --- a/apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/address_transaction_to_controller_test.exs @@ -18,14 +18,12 @@ defmodule ExplorerWeb.AddressTransactionToControllerTest do block = insert(:block) insert(:block_transaction, transaction: transaction, block: block) - conn = - get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 1 - transaction_hash_divs = - Floki.find(html, "td.transactions__column--hash div.transactions__hash a") + transaction_hash_divs = Floki.find(html, "td.transactions__column--hash div.transactions__hash a") assert length(transaction_hash_divs) == 1 @@ -44,8 +42,7 @@ defmodule ExplorerWeb.AddressTransactionToControllerTest do insert(:to_address, transaction: transaction, address: other_address) insert(:from_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -59,8 +56,7 @@ defmodule ExplorerWeb.AddressTransactionToControllerTest do insert(:to_address, transaction: transaction, address: address) insert(:from_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -74,8 +70,7 @@ defmodule ExplorerWeb.AddressTransactionToControllerTest do address = insert(:address) insert(:to_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 @@ -89,8 +84,7 @@ defmodule ExplorerWeb.AddressTransactionToControllerTest do address = insert(:address) insert(:from_address, transaction: transaction, address: address) - conn = - get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) + conn = get(conn, address_transaction_to_path(ExplorerWeb.Endpoint, :index, :en, address.hash)) assert html = html_response(conn, 200) assert html |> Floki.find("tbody tr") |> length == 0 diff --git a/apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs index d92f81c120..69983660c9 100644 --- a/apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/block_controller_test.exs @@ -17,8 +17,7 @@ defmodule ExplorerWeb.BlockControllerTest do describe "GET index/2" do test "returns all blocks", %{conn: conn} do - block_ids = - insert_list(4, :block) |> Enum.map(fn block -> block.number end) |> Enum.reverse() + block_ids = insert_list(4, :block) |> Enum.map(fn block -> block.number end) |> Enum.reverse() conn = get(conn, "/en/blocks") assert conn.assigns.blocks |> Enum.map(fn block -> block.number end) == block_ids diff --git a/apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs index daec2ac446..32e9fd9ab7 100644 --- a/apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/block_transaction_controller_test.exs @@ -30,8 +30,7 @@ defmodule ExplorerWeb.BlockTransactionControllerTest do assert html = html_response(conn, 200) - transaction_hash_divs = - Floki.find(html, "td.transactions__column--hash div.transactions__hash a") + transaction_hash_divs = Floki.find(html, "td.transactions__column--hash div.transactions__hash a") assert length(transaction_hash_divs) == 1 diff --git a/apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs index 2420335f53..73fd9506b3 100644 --- a/apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/chain_controller_test.exs @@ -1,8 +1,7 @@ defmodule ExplorerWeb.ChainControllerTest do use ExplorerWeb.ConnCase - import ExplorerWeb.Router.Helpers, - only: [chain_path: 3, block_path: 4, transaction_path: 4, address_path: 4] + import ExplorerWeb.Router.Helpers, only: [chain_path: 3, block_path: 4, transaction_path: 4, address_path: 4] describe "GET index/2 without a locale" do test "redirects to the en locale", %{conn: conn} do diff --git a/apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs b/apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs index 27ad4f635e..fd134f49fd 100644 --- a/apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs +++ b/apps/explorer_web/test/explorer_web/controllers/transaction_controller_test.exs @@ -77,8 +77,7 @@ defmodule ExplorerWeb.TransactionControllerTest do assert html |> Floki.find("div.transaction__header h3") |> Floki.text() == transaction.hash - assert html |> Floki.find("span.transaction__item--primary a") |> Floki.text() == - to_string(block.number) + assert html |> Floki.find("span.transaction__item--primary a") |> Floki.text() == to_string(block.number) end test "returns a transaction without associated block data", %{conn: conn} do