|
|
@ -1,4 +1,4 @@ |
|
|
|
defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
defmodule BlockScoutWeb.Account.Api.V2.UserControllerTest do |
|
|
|
use BlockScoutWeb.ConnCase |
|
|
|
use BlockScoutWeb.ConnCase |
|
|
|
|
|
|
|
|
|
|
|
alias Explorer.Account.{ |
|
|
|
alias Explorer.Account.{ |
|
|
@ -19,11 +19,11 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
{:ok, user: user, conn: Plug.Test.init_test_session(conn, current_user: user)} |
|
|
|
{:ok, user: user, conn: Plug.Test.init_test_session(conn, current_user: user)} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "Test account/api/v1/user" do |
|
|
|
describe "Test account/api/v2/user" do |
|
|
|
test "get user info", %{conn: conn, user: user} do |
|
|
|
test "get user info", %{conn: conn, user: user} do |
|
|
|
result_conn = |
|
|
|
result_conn = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/info") |
|
|
|
|> get("/api/account/v2/user/info") |
|
|
|
|> doc(description: "Get info about user") |
|
|
|
|> doc(description: "Get info about user") |
|
|
|
|
|
|
|
|
|
|
|
assert json_response(result_conn, 200) == %{ |
|
|
|
assert json_response(result_conn, 200) == %{ |
|
|
@ -37,7 +37,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
test "post private address tag", %{conn: conn} do |
|
|
|
test "post private address tag", %{conn: conn} do |
|
|
|
tag_address_response = |
|
|
|
tag_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post("/api/account/v1/user/tags/address", %{ |
|
|
|
|> post("/api/account/v2/user/tags/address", %{ |
|
|
|
"address_hash" => "0x3e9ac8f16c92bc4f093357933b5befbf1e16987b", |
|
|
|
"address_hash" => "0x3e9ac8f16c92bc4f093357933b5befbf1e16987b", |
|
|
|
"name" => "MyName" |
|
|
|
"name" => "MyName" |
|
|
|
}) |
|
|
|
}) |
|
|
@ -45,7 +45,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/address/0x3e9ac8f16c92bc4f093357933b5befbf1e16987b") |
|
|
|
|> get("/api/account/v2/tags/address/0x3e9ac8f16c92bc4f093357933b5befbf1e16987b") |
|
|
|
|> doc(description: "Get tags for address") |
|
|
|
|> doc(description: "Get tags for address") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
@ -69,11 +69,11 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/tags/address", build(:tag_address)) |
|
|
|
|> post("/api/account/v2/user/tags/address", build(:tag_address)) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/tags/address", build(:tag_address)) |
|
|
|
|> post("/api/account/v2/user/tags/address", build(:tag_address)) |
|
|
|
|> json_response(422) |
|
|
|
|> json_response(422) |
|
|
|
|
|
|
|
|
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
@ -103,12 +103,12 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
tag_address_response = |
|
|
|
tag_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post("/api/account/v1/user/tags/address", address_tag) |
|
|
|
|> post("/api/account/v2/user/tags/address", address_tag) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
_response = |
|
|
|
_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/address") |
|
|
|
|> get("/api/account/v2/user/tags/address") |
|
|
|
|> json_response(200) == [tag_address_response] |
|
|
|
|> json_response(200) == [tag_address_response] |
|
|
|
|
|
|
|
|
|
|
|
assert tag_address_response["address_hash"] == address_tag["address_hash"] |
|
|
|
assert tag_address_response["address_hash"] == address_tag["address_hash"] |
|
|
@ -119,7 +119,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
new_tag_address_response = |
|
|
|
new_tag_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put("/api/account/v1/user/tags/address/#{tag_address_response["id"]}", new_address_tag) |
|
|
|
|> put("/api/account/v2/user/tags/address/#{tag_address_response["id"]}", new_address_tag) |
|
|
|
|> doc(description: "Edit private address tag") |
|
|
|
|> doc(description: "Edit private address tag") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
@ -137,7 +137,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.map(zipped, fn {addr, name} -> |
|
|
|
Enum.map(zipped, fn {addr, name} -> |
|
|
|
id = |
|
|
|
id = |
|
|
|
(conn |
|
|
|
(conn |
|
|
|
|> post("/api/account/v1/user/tags/address", %{ |
|
|
|
|> post("/api/account/v2/user/tags/address", %{ |
|
|
|
"address_hash" => addr, |
|
|
|
"address_hash" => addr, |
|
|
|
"name" => name |
|
|
|
"name" => name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -164,7 +164,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert Enum.all?(created, fn {addr, map_tag, _} -> |
|
|
|
assert Enum.all?(created, fn {addr, map_tag, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/address/#{addr}") |
|
|
|
|> get("/api/account/v2/tags/address/#{addr}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tags"] == [map_tag] |
|
|
|
response["personal_tags"] == [map_tag] |
|
|
@ -172,9 +172,10 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/address") |
|
|
|
|> get("/api/account/v2/user/tags/address") |
|
|
|
|> doc(description: "Get private addresses tags") |
|
|
|
|> doc(description: "Get private addresses tags") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|> Map.get("items") |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
end |
|
|
|
end |
|
|
@ -188,7 +189,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.map(zipped, fn {addr, name} -> |
|
|
|
Enum.map(zipped, fn {addr, name} -> |
|
|
|
id = |
|
|
|
id = |
|
|
|
(conn |
|
|
|
(conn |
|
|
|
|> post("/api/account/v1/user/tags/address", %{ |
|
|
|
|> post("/api/account/v2/user/tags/address", %{ |
|
|
|
"address_hash" => addr, |
|
|
|
"address_hash" => addr, |
|
|
|
"name" => name |
|
|
|
"name" => name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -215,7 +216,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert Enum.all?(created, fn {addr, map_tag, _} -> |
|
|
|
assert Enum.all?(created, fn {addr, map_tag, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/address/#{addr}") |
|
|
|
|> get("/api/account/v2/tags/address/#{addr}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tags"] == [map_tag] |
|
|
|
response["personal_tags"] == [map_tag] |
|
|
@ -223,32 +224,31 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/address") |
|
|
|
|> get("/api/account/v2/user/tags/address") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|> Map.get("items") |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
|
|
|
|
|
|
|
|
{_, _, %{"id" => id}} = Enum.at(created, 0) |
|
|
|
{_, _, %{"id" => id}} = Enum.at(created, 0) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/tags/address/#{id}") |
|
|
|
|> delete("/api/account/v2/user/tags/address/#{id}") |
|
|
|
|> doc("Delete private address tag") |
|
|
|
|> doc("Delete private address tag") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(Enum.drop(created, 1), fn {_, _, %{"id" => id}} -> |
|
|
|
assert Enum.all?(Enum.drop(created, 1), fn {_, _, %{"id" => id}} -> |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> delete("/api/account/v1/user/tags/address/#{id}") |
|
|
|
|> delete("/api/account/v2/user/tags/address/#{id}") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |> get("/api/account/v2/user/tags/address") |> json_response(200) |> Map.get("items") == [] |
|
|
|
|> get("/api/account/v1/user/tags/address") |
|
|
|
|
|
|
|
|> json_response(200) == [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {addr, _, _} -> |
|
|
|
assert Enum.all?(created, fn {addr, _, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/address/#{addr}") |
|
|
|
|> get("/api/account/v2/tags/address/#{addr}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tags"] == [] |
|
|
|
response["personal_tags"] == [] |
|
|
@ -260,7 +260,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
tx_hash = to_string(insert(:transaction).hash) |
|
|
|
tx_hash = to_string(insert(:transaction).hash) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", %{ |
|
|
|
|> post("/api/account/v2/user/tags/transaction", %{ |
|
|
|
"transaction_hash" => tx_hash_non_existing, |
|
|
|
"transaction_hash" => tx_hash_non_existing, |
|
|
|
"name" => "MyName" |
|
|
|
"name" => "MyName" |
|
|
|
}) |
|
|
|
}) |
|
|
@ -269,7 +269,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
tag_transaction_response = |
|
|
|
tag_transaction_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", %{ |
|
|
|
|> post("/api/account/v2/user/tags/transaction", %{ |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"name" => "MyName" |
|
|
|
"name" => "MyName" |
|
|
|
}) |
|
|
|
}) |
|
|
@ -277,7 +277,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/transaction/#{tx_hash}") |
|
|
|
|> get("/api/account/v2/tags/transaction/#{tx_hash}") |
|
|
|
|> doc(description: "Get tags for transaction") |
|
|
|
|> doc(description: "Get tags for transaction") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
@ -301,11 +301,11 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", build(:tag_transaction)) |
|
|
|
|> post("/api/account/v2/user/tags/transaction", build(:tag_transaction)) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", build(:tag_transaction)) |
|
|
|
|> post("/api/account/v2/user/tags/transaction", build(:tag_transaction)) |
|
|
|
|> json_response(422) |
|
|
|
|> json_response(422) |
|
|
|
|
|
|
|
|
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
@ -335,12 +335,12 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
tag_response = |
|
|
|
tag_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", tx_tag) |
|
|
|
|> post("/api/account/v2/user/tags/transaction", tx_tag) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
_response = |
|
|
|
_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/transaction") |
|
|
|
|> get("/api/account/v2/user/tags/transaction") |
|
|
|
|> json_response(200) == [tag_response] |
|
|
|
|> json_response(200) == [tag_response] |
|
|
|
|
|
|
|
|
|
|
|
assert tag_response["address_hash"] == tx_tag["address_hash"] |
|
|
|
assert tag_response["address_hash"] == tx_tag["address_hash"] |
|
|
@ -351,7 +351,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
new_tag_response = |
|
|
|
new_tag_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put("/api/account/v1/user/tags/transaction/#{tag_response["id"]}", new_tx_tag) |
|
|
|
|> put("/api/account/v2/user/tags/transaction/#{tag_response["id"]}", new_tx_tag) |
|
|
|
|> doc(description: "Edit private transaction tag") |
|
|
|
|> doc(description: "Edit private transaction tag") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
@ -369,7 +369,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.map(zipped, fn {tx_hash, name} -> |
|
|
|
Enum.map(zipped, fn {tx_hash, name} -> |
|
|
|
id = |
|
|
|
id = |
|
|
|
(conn |
|
|
|
(conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", %{ |
|
|
|
|> post("/api/account/v2/user/tags/transaction", %{ |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"name" => name |
|
|
|
"name" => name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -381,7 +381,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert Enum.all?(created, fn {tx_hash, map_tag, _} -> |
|
|
|
assert Enum.all?(created, fn {tx_hash, map_tag, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/transaction/#{tx_hash}") |
|
|
|
|> get("/api/account/v2/tags/transaction/#{tx_hash}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tx_tag"] == map_tag |
|
|
|
response["personal_tx_tag"] == map_tag |
|
|
@ -389,9 +389,10 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/transaction") |
|
|
|
|> get("/api/account/v2/user/tags/transaction") |
|
|
|
|> doc(description: "Get private transactions tags") |
|
|
|
|> doc(description: "Get private transactions tags") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|> Map.get("items") |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
end |
|
|
|
end |
|
|
@ -405,7 +406,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.map(zipped, fn {tx_hash, name} -> |
|
|
|
Enum.map(zipped, fn {tx_hash, name} -> |
|
|
|
id = |
|
|
|
id = |
|
|
|
(conn |
|
|
|
(conn |
|
|
|
|> post("/api/account/v1/user/tags/transaction", %{ |
|
|
|
|> post("/api/account/v2/user/tags/transaction", %{ |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"transaction_hash" => tx_hash, |
|
|
|
"name" => name |
|
|
|
"name" => name |
|
|
|
}) |
|
|
|
}) |
|
|
@ -417,15 +418,15 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert Enum.all?(created, fn {tx_hash, map_tag, _} -> |
|
|
|
assert Enum.all?(created, fn {tx_hash, map_tag, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/transaction/#{tx_hash}") |
|
|
|
|> get("/api/account/v2/tags/transaction/#{tx_hash}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tx_tag"] == map_tag |
|
|
|
response["personal_tx_tag"] == map_tag |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
response = |
|
|
|
%{"items" => response, "next_page_params" => nil} = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/tags/transaction") |
|
|
|
|> get("/api/account/v2/user/tags/transaction") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
|
assert Enum.all?(created, fn {_, _, map} -> map in response end) |
|
|
@ -433,24 +434,24 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
{_, _, %{"id" => id}} = Enum.at(created, 0) |
|
|
|
{_, _, %{"id" => id}} = Enum.at(created, 0) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/tags/transaction/#{id}") |
|
|
|
|> delete("/api/account/v2/user/tags/transaction/#{id}") |
|
|
|
|> doc("Delete private transaction tag") |
|
|
|
|> doc("Delete private transaction tag") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(Enum.drop(created, 1), fn {_, _, %{"id" => id}} -> |
|
|
|
assert Enum.all?(Enum.drop(created, 1), fn {_, _, %{"id" => id}} -> |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> delete("/api/account/v1/user/tags/transaction/#{id}") |
|
|
|
|> delete("/api/account/v2/user/tags/transaction/#{id}") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/tags/transaction") |
|
|
|
|> get("/api/account/v2/user/tags/transaction") |
|
|
|
|> json_response(200) == [] |
|
|
|
|> json_response(200) == %{"items" => [], "next_page_params" => nil} |
|
|
|
|
|
|
|
|
|
|
|
assert Enum.all?(created, fn {addr, _, _} -> |
|
|
|
assert Enum.all?(created, fn {addr, _, _} -> |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/tags/transaction/#{addr}") |
|
|
|
|> get("/api/account/v2/tags/transaction/#{addr}") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
response["personal_tx_tag"] == nil |
|
|
|
response["personal_tx_tag"] == nil |
|
|
@ -463,7 +464,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response = |
|
|
|
post_watchlist_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Add address to watch list") |
|
|
|
|> doc(description: "Add address to watch list") |
|
|
@ -474,7 +475,8 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response = conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(0) |
|
|
|
get_watchlist_address_response = |
|
|
|
|
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(0) |
|
|
|
|
|
|
|
|
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
@ -487,20 +489,21 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map_1 |
|
|
|
watchlist_address_map_1 |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response_1_0 = |
|
|
|
get_watchlist_address_response_1_0 = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> get("/api/account/v1/user/watchlist") |
|
|
|
|> get("/api/account/v2/user/watchlist") |
|
|
|
|> doc(description: "Get addresses from watchlists") |
|
|
|
|> doc(description: "Get addresses from watchlists") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|> Map.get("items") |
|
|
|
|> Enum.at(1) |
|
|
|
|> Enum.at(1) |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response_1_1 = |
|
|
|
get_watchlist_address_response_1_1 = |
|
|
|
conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(0) |
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(0) |
|
|
|
|
|
|
|
|
|
|
|
assert get_watchlist_address_response_1_0 == get_watchlist_address_response |
|
|
|
assert get_watchlist_address_response_1_0 == get_watchlist_address_response |
|
|
|
|
|
|
|
|
|
|
@ -531,11 +534,11 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/watchlist", build(:watchlist_address)) |
|
|
|
|> post("/api/account/v2/user/watchlist", build(:watchlist_address)) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post("/api/account/v1/user/watchlist", build(:watchlist_address)) |
|
|
|
|> post("/api/account/v2/user/watchlist", build(:watchlist_address)) |
|
|
|
|> json_response(422) |
|
|
|
|> json_response(422) |
|
|
|
|
|
|
|
|
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
|
Application.put_env(:explorer, Explorer.Account, old_env) |
|
|
@ -566,7 +569,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response = |
|
|
|
post_watchlist_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -576,7 +579,8 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response = conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(0) |
|
|
|
get_watchlist_address_response = |
|
|
|
|
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(0) |
|
|
|
|
|
|
|
|
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
@ -589,16 +593,16 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map_1 |
|
|
|
watchlist_address_map_1 |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response_1_0 = |
|
|
|
get_watchlist_address_response_1_0 = |
|
|
|
conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(1) |
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(1) |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response_1_1 = |
|
|
|
get_watchlist_address_response_1_1 = |
|
|
|
conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(0) |
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(0) |
|
|
|
|
|
|
|
|
|
|
|
assert get_watchlist_address_response_1_0 == get_watchlist_address_response |
|
|
|
assert get_watchlist_address_response_1_0 == get_watchlist_address_response |
|
|
|
|
|
|
|
|
|
|
@ -614,15 +618,15 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert get_watchlist_address_response_1_1["id"] == post_watchlist_address_response_1["id"] |
|
|
|
assert get_watchlist_address_response_1_1["id"] == post_watchlist_address_response_1["id"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/watchlist/#{get_watchlist_address_response_1_1["id"]}") |
|
|
|
|> delete("/api/account/v2/user/watchlist/#{get_watchlist_address_response_1_1["id"]}") |
|
|
|
|> doc(description: "Delete address from watchlist by id") |
|
|
|
|> doc(description: "Delete address from watchlist by id") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/watchlist/#{get_watchlist_address_response_1_0["id"]}") |
|
|
|
|> delete("/api/account/v2/user/watchlist/#{get_watchlist_address_response_1_0["id"]}") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |> get("/api/account/v1/user/watchlist") |> json_response(200) == [] |
|
|
|
assert conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") == [] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "put watchlist address", %{conn: conn} do |
|
|
|
test "put watchlist address", %{conn: conn} do |
|
|
@ -631,7 +635,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response = |
|
|
|
post_watchlist_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -641,7 +645,8 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["notification_methods"] == watchlist_address_map["notification_methods"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
assert post_watchlist_address_response["address_hash"] == watchlist_address_map["address_hash"] |
|
|
|
|
|
|
|
|
|
|
|
get_watchlist_address_response = conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |> Enum.at(0) |
|
|
|
get_watchlist_address_response = |
|
|
|
|
|
|
|
conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |> Enum.at(0) |
|
|
|
|
|
|
|
|
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["notification_settings"] == watchlist_address_map["notification_settings"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
|
assert get_watchlist_address_response["name"] == watchlist_address_map["name"] |
|
|
@ -654,7 +659,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
put_watchlist_address_response = |
|
|
|
put_watchlist_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put( |
|
|
|
|> put( |
|
|
|
"/api/account/v1/user/watchlist/#{post_watchlist_address_response["id"]}", |
|
|
|
"/api/account/v2/user/watchlist/#{post_watchlist_address_response["id"]}", |
|
|
|
new_watchlist_address_map |
|
|
|
new_watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Edit watchlist address") |
|
|
|
|> doc(description: "Edit watchlist address") |
|
|
@ -675,7 +680,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response = |
|
|
|
post_watchlist_address_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -687,7 +692,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Example of error on creating watchlist address") |
|
|
|
|> doc(description: "Example of error on creating watchlist address") |
|
|
@ -698,14 +703,14 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
post_watchlist_address_response_1 = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
new_watchlist_address_map |
|
|
|
new_watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> put( |
|
|
|
|> put( |
|
|
|
"/api/account/v1/user/watchlist/#{post_watchlist_address_response_1["id"]}", |
|
|
|
"/api/account/v2/user/watchlist/#{post_watchlist_address_response_1["id"]}", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Example of error on editing watchlist address") |
|
|
|
|> doc(description: "Example of error on editing watchlist address") |
|
|
@ -717,7 +722,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -726,7 +731,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map_1 |
|
|
|
watchlist_address_map_1 |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -761,7 +766,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|> Enum.sort(fn x1, x2 -> Decimal.compare(x1, x2) in [:gt, :eq] end) |
|
|
|
|> Enum.sort(fn x1, x2 -> Decimal.compare(x1, x2) in [:gt, :eq] end) |
|
|
|
|> Enum.take(150) |
|
|
|
|> Enum.take(150) |
|
|
|
|
|
|
|
|
|
|
|
[wa2, wa1] = conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |
|
|
|
[wa2, wa1] = conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |
|
|
|
|
|
|
|
|
|
|
|
assert wa1["tokens_fiat_value"] |> Decimal.new() |> Decimal.round(13) == |
|
|
|
assert wa1["tokens_fiat_value"] |> Decimal.new() |> Decimal.round(13) == |
|
|
|
values |> Enum.reduce(Decimal.new(0), fn x, acc -> Decimal.add(x, acc) end) |> Decimal.round(13) |
|
|
|
values |> Enum.reduce(Decimal.new(0), fn x, acc -> Decimal.add(x, acc) end) |> Decimal.round(13) |
|
|
@ -781,7 +786,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/watchlist", |
|
|
|
"/api/account/v2/user/watchlist", |
|
|
|
watchlist_address_map |
|
|
|
watchlist_address_map |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -808,7 +813,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
token_contract_address_hash: token.contract_address_hash |
|
|
|
token_contract_address_hash: token.contract_address_hash |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
[wa1] = conn |> get("/api/account/v1/user/watchlist") |> json_response(200) |
|
|
|
[wa1] = conn |> get("/api/account/v2/user/watchlist") |> json_response(200) |> Map.get("items") |
|
|
|
|
|
|
|
|
|
|
|
assert wa1["tokens_fiat_value"] |> Decimal.new() |> Decimal.round(13) == |
|
|
|
assert wa1["tokens_fiat_value"] |> Decimal.new() |> Decimal.round(13) == |
|
|
|
values |> Enum.reduce(Decimal.new(0), fn x, acc -> Decimal.add(x, acc) end) |> Decimal.round(13) |
|
|
|
values |> Enum.reduce(Decimal.new(0), fn x, acc -> Decimal.add(x, acc) end) |> Decimal.round(13) |
|
|
@ -821,7 +826,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_api_key_response = |
|
|
|
post_api_key_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/api_keys", |
|
|
|
"/api/account/v2/user/api_keys", |
|
|
|
%{"name" => "test"} |
|
|
|
%{"name" => "test"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Add api key") |
|
|
|
|> doc(description: "Add api key") |
|
|
@ -835,7 +840,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.each(0..2, fn _x -> |
|
|
|
Enum.each(0..2, fn _x -> |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/api_keys", |
|
|
|
"/api/account/v2/user/api_keys", |
|
|
|
%{"name" => "test"} |
|
|
|
%{"name" => "test"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -843,14 +848,14 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/api_keys", |
|
|
|
"/api/account/v2/user/api_keys", |
|
|
|
%{"name" => "test"} |
|
|
|
%{"name" => "test"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Example of error on creating api key") |
|
|
|
|> doc(description: "Example of error on creating api key") |
|
|
|
|> json_response(422) == %{"errors" => %{"name" => ["Max 3 keys per account"]}} |
|
|
|
|> json_response(422) == %{"errors" => %{"name" => ["Max 3 keys per account"]}} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/api_keys") |
|
|
|
|> get("/api/account/v2/user/api_keys") |
|
|
|
|> doc(description: "Get api keys list") |
|
|
|
|> doc(description: "Get api keys list") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.count() == 3 |
|
|
|
|> Enum.count() == 3 |
|
|
@ -860,7 +865,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_api_key_response = |
|
|
|
post_api_key_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/api_keys", |
|
|
|
"/api/account/v2/user/api_keys", |
|
|
|
%{"name" => "test"} |
|
|
|
%{"name" => "test"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -871,7 +876,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
put_api_key_response = |
|
|
|
put_api_key_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put( |
|
|
|
|> put( |
|
|
|
"/api/account/v1/user/api_keys/#{post_api_key_response["api_key"]}", |
|
|
|
"/api/account/v2/user/api_keys/#{post_api_key_response["api_key"]}", |
|
|
|
%{"name" => "test_1"} |
|
|
|
%{"name" => "test_1"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Edit api key") |
|
|
|
|> doc(description: "Edit api key") |
|
|
@ -881,7 +886,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert put_api_key_response["name"] == "test_1" |
|
|
|
assert put_api_key_response["name"] == "test_1" |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/api_keys") |
|
|
|
|> get("/api/account/v2/user/api_keys") |
|
|
|
|> json_response(200) == [put_api_key_response] |
|
|
|
|> json_response(200) == [put_api_key_response] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -889,7 +894,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_api_key_response = |
|
|
|
post_api_key_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/api_keys", |
|
|
|
"/api/account/v2/user/api_keys", |
|
|
|
%{"name" => "test"} |
|
|
|
%{"name" => "test"} |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -898,17 +903,17 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_api_key_response["api_key"] |
|
|
|
assert post_api_key_response["api_key"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/api_keys") |
|
|
|
|> get("/api/account/v2/user/api_keys") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.count() == 1 |
|
|
|
|> Enum.count() == 1 |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/api_keys/#{post_api_key_response["api_key"]}") |
|
|
|
|> delete("/api/account/v2/user/api_keys/#{post_api_key_response["api_key"]}") |
|
|
|
|> doc(description: "Delete api key") |
|
|
|
|> doc(description: "Delete api key") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/api_keys") |
|
|
|
|> get("/api/account/v2/user/api_keys") |
|
|
|
|> json_response(200) == [] |
|
|
|
|> json_response(200) == [] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -918,7 +923,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_custom_abi_response = |
|
|
|
post_custom_abi_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/custom_abis", |
|
|
|
"/api/account/v2/user/custom_abis", |
|
|
|
custom_abi |
|
|
|
custom_abi |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Add custom abi") |
|
|
|
|> doc(description: "Add custom abi") |
|
|
@ -934,7 +939,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
Enum.each(0..14, fn _x -> |
|
|
|
Enum.each(0..14, fn _x -> |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/custom_abis", |
|
|
|
"/api/account/v2/user/custom_abis", |
|
|
|
build(:custom_abi) |
|
|
|
build(:custom_abi) |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -942,14 +947,14 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/custom_abis", |
|
|
|
"/api/account/v2/user/custom_abis", |
|
|
|
build(:custom_abi) |
|
|
|
build(:custom_abi) |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Example of error on creating custom abi") |
|
|
|
|> doc(description: "Example of error on creating custom abi") |
|
|
|
|> json_response(422) == %{"errors" => %{"name" => ["Max 15 ABIs per account"]}} |
|
|
|
|> json_response(422) == %{"errors" => %{"name" => ["Max 15 ABIs per account"]}} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/custom_abis") |
|
|
|
|> get("/api/account/v2/user/custom_abis") |
|
|
|
|> doc(description: "Get custom abis list") |
|
|
|
|> doc(description: "Get custom abis list") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.count() == 15 |
|
|
|
|> Enum.count() == 15 |
|
|
@ -961,7 +966,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_custom_abi_response = |
|
|
|
post_custom_abi_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/custom_abis", |
|
|
|
"/api/account/v2/user/custom_abis", |
|
|
|
custom_abi |
|
|
|
custom_abi |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -976,7 +981,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
put_custom_abi_response = |
|
|
|
put_custom_abi_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put( |
|
|
|
|> put( |
|
|
|
"/api/account/v1/user/custom_abis/#{post_custom_abi_response["id"]}", |
|
|
|
"/api/account/v2/user/custom_abis/#{post_custom_abi_response["id"]}", |
|
|
|
custom_abi_1 |
|
|
|
custom_abi_1 |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Edit custom abi") |
|
|
|
|> doc(description: "Edit custom abi") |
|
|
@ -988,7 +993,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert put_custom_abi_response["abi"] == custom_abi_1["abi"] |
|
|
|
assert put_custom_abi_response["abi"] == custom_abi_1["abi"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/custom_abis") |
|
|
|
|> get("/api/account/v2/user/custom_abis") |
|
|
|
|> json_response(200) == [put_custom_abi_response] |
|
|
|
|> json_response(200) == [put_custom_abi_response] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -998,7 +1003,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_custom_abi_response = |
|
|
|
post_custom_abi_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/custom_abis", |
|
|
|
"/api/account/v2/user/custom_abis", |
|
|
|
custom_abi |
|
|
|
custom_abi |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -1007,17 +1012,17 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_custom_abi_response["id"] |
|
|
|
assert post_custom_abi_response["id"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/custom_abis") |
|
|
|
|> get("/api/account/v2/user/custom_abis") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.count() == 1 |
|
|
|
|> Enum.count() == 1 |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/custom_abis/#{post_custom_abi_response["id"]}") |
|
|
|
|> delete("/api/account/v2/user/custom_abis/#{post_custom_abi_response["id"]}") |
|
|
|
|> doc(description: "Delete custom abi") |
|
|
|
|> doc(description: "Delete custom abi") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/custom_abis") |
|
|
|
|> get("/api/account/v2/user/custom_abis") |
|
|
|
|> json_response(200) == [] |
|
|
|
|> json_response(200) == [] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -1029,7 +1034,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_public_tags_request_response = |
|
|
|
post_public_tags_request_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/public_tags", |
|
|
|
"/api/account/v2/user/public_tags", |
|
|
|
public_tags_request |
|
|
|
public_tags_request |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Submit request to add a public tag") |
|
|
|
|> doc(description: "Submit request to add a public tag") |
|
|
@ -1052,7 +1057,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_public_tags_request_response = |
|
|
|
post_public_tags_request_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/public_tags", |
|
|
|
"/api/account/v2/user/public_tags", |
|
|
|
public_tags_request |
|
|
|
public_tags_request |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -1068,7 +1073,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_public_tags_request_response["id"] |
|
|
|
assert post_public_tags_request_response["id"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/public_tags") |
|
|
|
|> get("/api/account/v2/user/public_tags") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
[post_public_tags_request_response] |
|
|
|
[post_public_tags_request_response] |
|
|
@ -1084,7 +1089,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
response = |
|
|
|
response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/public_tags", |
|
|
|
"/api/account/v2/user/public_tags", |
|
|
|
request |
|
|
|
request |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -1104,7 +1109,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
|> Enum.reverse() |
|
|
|
|> Enum.reverse() |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/public_tags") |
|
|
|
|> get("/api/account/v2/user/public_tags") |
|
|
|
|> doc(description: "Get list of requests to add a public tag") |
|
|
|
|> doc(description: "Get list of requests to add a public tag") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.map(&convert_date/1) == final_list |
|
|
|
|> Enum.map(&convert_date/1) == final_list |
|
|
@ -1112,18 +1117,18 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
%{"id" => id} = Enum.at(final_list, 0) |
|
|
|
%{"id" => id} = Enum.at(final_list, 0) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/public_tags/#{id}", %{"remove_reason" => "reason"}) |
|
|
|
|> delete("/api/account/v2/user/public_tags/#{id}", %{"remove_reason" => "reason"}) |
|
|
|
|> doc(description: "Delete public tags request") |
|
|
|
|> doc(description: "Delete public tags request") |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|
|
|
|
|
|
|
|
Enum.each(Enum.drop(final_list, 1), fn request -> |
|
|
|
Enum.each(Enum.drop(final_list, 1), fn request -> |
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> delete("/api/account/v1/user/public_tags/#{request["id"]}", %{"remove_reason" => "reason"}) |
|
|
|
|> delete("/api/account/v2/user/public_tags/#{request["id"]}", %{"remove_reason" => "reason"}) |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
|> json_response(200) == %{"message" => "OK"} |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/public_tags") |
|
|
|
|> get("/api/account/v2/user/public_tags") |
|
|
|
|> json_response(200) == [] |
|
|
|
|> json_response(200) == [] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -1133,7 +1138,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
post_public_tags_request_response = |
|
|
|
post_public_tags_request_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> post( |
|
|
|
|> post( |
|
|
|
"/api/account/v1/user/public_tags", |
|
|
|
"/api/account/v2/user/public_tags", |
|
|
|
public_tags_request |
|
|
|
public_tags_request |
|
|
|
) |
|
|
|
) |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
@ -1149,7 +1154,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert post_public_tags_request_response["id"] |
|
|
|
assert post_public_tags_request_response["id"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/public_tags") |
|
|
|
|> get("/api/account/v2/user/public_tags") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
[post_public_tags_request_response] |
|
|
|
[post_public_tags_request_response] |
|
|
@ -1160,7 +1165,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
put_public_tags_request_response = |
|
|
|
put_public_tags_request_response = |
|
|
|
conn |
|
|
|
conn |
|
|
|
|> put( |
|
|
|
|> put( |
|
|
|
"/api/account/v1/user/public_tags/#{post_public_tags_request_response["id"]}", |
|
|
|
"/api/account/v2/user/public_tags/#{post_public_tags_request_response["id"]}", |
|
|
|
new_public_tags_request |
|
|
|
new_public_tags_request |
|
|
|
) |
|
|
|
) |
|
|
|
|> doc(description: "Edit request to add a public tag") |
|
|
|
|> doc(description: "Edit request to add a public tag") |
|
|
@ -1177,7 +1182,7 @@ defmodule BlockScoutWeb.Account.Api.V1.UserControllerTest do |
|
|
|
assert put_public_tags_request_response["id"] == post_public_tags_request_response["id"] |
|
|
|
assert put_public_tags_request_response["id"] == post_public_tags_request_response["id"] |
|
|
|
|
|
|
|
|
|
|
|
assert conn |
|
|
|
assert conn |
|
|
|
|> get("/api/account/v1/user/public_tags") |
|
|
|
|> get("/api/account/v2/user/public_tags") |
|
|
|
|> json_response(200) |
|
|
|
|> json_response(200) |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
|> Enum.map(&convert_date/1) == |
|
|
|
[put_public_tags_request_response] |
|
|
|
[put_public_tags_request_response] |