account
Никита Поздняков 3 years ago committed by Viktor Baranov
parent b55a965b26
commit 7bf89d3bd3
  1. 4
      apps/explorer/lib/explorer/accounts/notifier/summary.ex
  2. 3
      apps/explorer/test/explorer/accounts/notify/email_test.exs
  3. 12
      apps/explorer/test/explorer/accounts/notify/notify_test.exs
  4. 58
      apps/explorer/test/explorer/accounts/notify/summary_test.exs
  5. 4
      apps/explorer/test/support/factory.ex

@ -90,7 +90,7 @@ defmodule Explorer.Accounts.Notifier.Summary do
block_number: transaction.block_number, block_number: transaction.block_number,
amount: amount(transaction), amount: amount(transaction),
tx_fee: fee(transaction), tx_fee: fee(transaction),
name: Application.get_env(:explorer, :coin_name), name: Application.get_env(:explorer, :coin),
subject: "Coin transaction", subject: "Coin transaction",
type: "COIN" type: "COIN"
} }
@ -105,7 +105,7 @@ defmodule Explorer.Accounts.Notifier.Summary do
block_number: transaction.block_number, block_number: transaction.block_number,
amount: amount(transaction), amount: amount(transaction),
tx_fee: fee(transaction), tx_fee: fee(transaction),
name: Application.get_env(:explorer, :coin_name), name: Application.get_env(:explorer, :coin),
subject: "Contract creation", subject: "Contract creation",
type: "COIN" type: "COIN"
} }

@ -1,9 +1,7 @@
defmodule Explorer.Accounts.Notify.EmailTest do defmodule Explorer.Accounts.Notify.EmailTest do
use ExUnit.Case use ExUnit.Case
alias Explorer.Chain
alias Explorer.Chain.Address alias Explorer.Chain.Address
alias Explorer.Chain.Hash
alias Explorer.Chain.Transaction alias Explorer.Chain.Transaction
alias Explorer.Accounts.{ alias Explorer.Accounts.{
@ -48,7 +46,6 @@ defmodule Explorer.Accounts.Notify.EmailTest do
transaction_hash = %Transaction{hash: tx_hash} transaction_hash = %Transaction{hash: tx_hash}
{:ok, from_hash} = string_to_address_hash("0x092D537737E767Dae48c28aE509f34094496f030") {:ok, from_hash} = string_to_address_hash("0x092D537737E767Dae48c28aE509f34094496f030")
from_address_hash = %Address{hash: from_hash}
{:ok, to_hash} = string_to_address_hash("0xE1F4dd38f00B0D8D4d2b4B5010bE53F2A0b934E5") {:ok, to_hash} = string_to_address_hash("0xE1F4dd38f00B0D8D4d2b4B5010bE53F2A0b934E5")
to_address = %Address{hash: to_hash} to_address = %Address{hash: to_hash}

@ -7,7 +7,7 @@ defmodule Explorer.Accounts.Notify.NotifyTest do
alias Explorer.Accounts.Notifier.Notify alias Explorer.Accounts.Notifier.Notify
alias Explorer.Accounts.{WatchlistAddress, WatchlistNotification} alias Explorer.Accounts.{WatchlistAddress, WatchlistNotification}
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.{Address, Token, TokenTransfer, Transaction, Wei} alias Explorer.Chain.{Transaction, Wei}
alias Explorer.Repo alias Explorer.Repo
setup do setup do
@ -59,14 +59,14 @@ defmodule Explorer.Accounts.Notify.NotifyTest do
address: address address: address
} = insert(:account_watchlist_address) } = insert(:account_watchlist_address)
watchlist_address = Repo.preload(wa, :address, watchlist: :identity) _watchlist_address = Repo.preload(wa, :address, watchlist: :identity)
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: _tx_hash
} = with_block(insert(:transaction, to_address: address)) } = with_block(insert(:transaction, to_address: address))
{_, fee} = Chain.fee(tx, :gwei) {_, fee} = Chain.fee(tx, :gwei)

@ -6,7 +6,7 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
alias Explorer.Accounts.Notifier.Summary alias Explorer.Accounts.Notifier.Summary
alias Explorer.Chain alias Explorer.Chain
alias Explorer.Chain.{Address, Token, TokenTransfer, Transaction, Wei} alias Explorer.Chain.{TokenTransfer, Transaction, Wei}
alias Explorer.Repo alias Explorer.Repo
describe "call" do describe "call" do
@ -41,9 +41,9 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
test "Pending Coin transaction (w/o block)" do test "Pending Coin transaction (w/o block)" do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
hash: tx_hash hash: _tx_hash
} = insert(:transaction) } = insert(:transaction)
assert Summary.process(tx) == [] assert Summary.process(tx) == []
@ -57,8 +57,8 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: tx_hash
} = } =
:transaction :transaction
@ -88,15 +88,15 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
test "ERC-20 Token transfer" do test "ERC-20 Token transfer" do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: _tx_hash
} = with_block(insert(:transaction)) } = with_block(insert(:transaction))
transfer = transfer =
%TokenTransfer{ %TokenTransfer{
amount: amount, amount: _amount,
block_number: block_number, block_number: block_number,
from_address: from_address, from_address: from_address,
to_address: to_address, to_address: to_address,
@ -137,15 +137,15 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: _tx_hash
} = with_block(insert(:transaction)) } = with_block(insert(:transaction))
transfer = transfer =
%TokenTransfer{ %TokenTransfer{
amount: amount, amount: _amount,
block_number: block_number, block_number: block_number,
from_address: from_address, from_address: from_address,
to_address: to_address to_address: to_address
@ -166,8 +166,6 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
decimals = Decimal.new(Integer.pow(10, token_decimals)) decimals = Decimal.new(Integer.pow(10, token_decimals))
amount = Decimal.div(transfer.amount, decimals)
assert Summary.process(transfer) == [ assert Summary.process(transfer) == [
%Summary{ %Summary{
amount: 0, amount: 0,
@ -189,15 +187,15 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: _tx_hash
} = with_block(insert(:transaction)) } = with_block(insert(:transaction))
transfer = transfer =
%TokenTransfer{ %TokenTransfer{
amount: amount, amount: _amount,
block_number: block_number, block_number: block_number,
from_address: from_address, from_address: from_address,
to_address: to_address to_address: to_address
@ -218,8 +216,6 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
decimals = Decimal.new(Integer.pow(10, token_decimals)) decimals = Decimal.new(Integer.pow(10, token_decimals))
amount = Decimal.div(transfer.amount, decimals)
assert Summary.process(transfer) == [ assert Summary.process(transfer) == [
%Summary{ %Summary{
amount: 0, amount: 0,
@ -241,15 +237,15 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
tx = tx =
%Transaction{ %Transaction{
from_address: from_address, from_address: _from_address,
to_address: to_address, to_address: _to_address,
block_number: block_number, block_number: _block_number,
hash: tx_hash hash: _tx_hash
} = with_block(insert(:transaction)) } = with_block(insert(:transaction))
transfer = transfer =
%TokenTransfer{ %TokenTransfer{
amount: amount, amount: _amount,
block_number: block_number, block_number: block_number,
from_address: from_address, from_address: from_address,
to_address: to_address to_address: to_address
@ -271,8 +267,6 @@ defmodule Explorer.Accounts.Notify.SummaryTest do
decimals = Decimal.new(Integer.pow(10, token_decimals)) decimals = Decimal.new(Integer.pow(10, token_decimals))
amount = Decimal.div(transfer.amount, decimals)
assert Summary.process(transfer) == [ assert Summary.process(transfer) == [
%Summary{ %Summary{
amount: 0, amount: 0,

@ -12,10 +12,8 @@ defmodule Explorer.Factory do
User, User,
UserContact, UserContact,
Identity, Identity,
TagAddress,
Watchlist, Watchlist,
WatchlistAddress, WatchlistAddress
WatchlistNotification
} }
alias Explorer.Admin.Administrator alias Explorer.Admin.Administrator

Loading…
Cancel
Save