@ -2,7 +2,7 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
use ExplorerWeb.ConnCase
use ExplorerWeb.ConnCase
alias Explorer.Chain
alias Explorer.Chain
alias Explorer.Chain . { Transaction , Wei }
alias Explorer.Chain.Transaction
describe " balance " do
describe " balance " do
test " with missing address hash " , %{ conn : conn } do
test " with missing address hash " , %{ conn : conn } do
@ -66,17 +66,12 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
" address " = > " #{ address . hash } "
" address " = > " #{ address . hash } "
}
}
expected_balance =
address . fetched_balance
|> Wei . to ( :ether )
|> Decimal . to_string ( :normal )
assert response =
assert response =
conn
conn
|> get ( " /api " , params )
|> get ( " /api " , params )
|> json_response ( 200 )
|> json_response ( 200 )
assert response [ " result " ] == expected_balance
assert response [ " result " ] == " #{ address . fetched_balance . value } "
assert response [ " status " ] == " 1 "
assert response [ " status " ] == " 1 "
assert response [ " message " ] == " OK "
assert response [ " message " ] == " OK "
end
end
@ -100,12 +95,7 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
expected_result =
expected_result =
Enum . map ( addresses , fn address ->
Enum . map ( addresses , fn address ->
expected_balance =
%{ " account " = > " #{ address . hash } " , " balance " = > " #{ address . fetched_balance . value } " }
address . fetched_balance
|> Wei . to ( :ether )
|> Decimal . to_string ( :normal )
%{ " account " = > " #{ address . hash } " , " balance " = > expected_balance }
end )
end )
assert response =
assert response =
@ -185,12 +175,7 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
expected_result =
expected_result =
Enum . map ( addresses , fn address ->
Enum . map ( addresses , fn address ->
expected_balance =
%{ " account " = > " #{ address . hash } " , " balance " = > " #{ address . fetched_balance . value } " }
address . fetched_balance
|> Wei . to ( :ether )
|> Decimal . to_string ( :normal )
%{ " account " = > " #{ address . hash } " , " balance " = > expected_balance }
end )
end )
assert response =
assert response =
@ -213,14 +198,9 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
" address " = > " #{ address1 . hash } , #{ address2_hash } "
" address " = > " #{ address1 . hash } , #{ address2_hash } "
}
}
expected_balance1 =
address1 . fetched_balance
|> Wei . to ( :ether )
|> Decimal . to_string ( :normal )
expected_result = [
expected_result = [
%{ " account " = > address2_hash , " balance " = > " 0 " } ,
%{ " account " = > address2_hash , " balance " = > " 0 " } ,
%{ " account " = > " #{ address1 . hash } " , " balance " = > expected_balance1 }
%{ " account " = > " #{ address1 . hash } " , " balance " = > " #{ address1 . fetched_balance . value } " }
]
]
assert response =
assert response =
@ -266,13 +246,8 @@ defmodule ExplorerWeb.API.RPC.AddressControllerTest do
" address " = > " #{ address . hash } "
" address " = > " #{ address . hash } "
}
}
expected_balance =
address . fetched_balance
|> Wei . to ( :ether )
|> Decimal . to_string ( :normal )
expected_result = [
expected_result = [
%{ " account " = > " #{ address . hash } " , " balance " = > expected_balance }
%{ " account " = > " #{ address . hash } " , " balance " = > " #{ address . fetched_balance . value } " }
]
]
assert response =
assert response =