Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move transactions count to v3 properly #1712

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/ae_mdw_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ defmodule AeMdwWeb.Router do
get "/micro-blocks/:hash", BlockController, :micro_block
get "/micro-blocks/:hash/transactions", TxController, :micro_block_txs

get "/transactions/count", TxController, :count
get "/transactions/count/:id", TxController, :count_id
get "/transactions", TxController, :txs
get "/transactions/:hash", TxController, :tx

Expand Down Expand Up @@ -93,9 +95,6 @@ defmodule AeMdwWeb.Router do
get "/statistics/blocks", StatsController, :blocks_statistics
get "/statistics/names", StatsController, :names_statistics

get "/transactions/count", TxController, :count
get "/transactions/count/:id", TxController, :count_id

get "/transfers", TransferController, :transfers
get "/contracts/logs", ContractController, :logs
get "/contracts/calls", ContractController, :calls
Expand Down
40 changes: 20 additions & 20 deletions test/ae_mdw_web/controllers/tx_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert ^tx_index =
conn
|> with_store(store)
|> get("/v2/txs/count")
|> get("/v3/transactions/count")
|> json_response(200)
end

Expand All @@ -1632,7 +1632,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert 101 =
conn
|> get("/v2/txs/count", scope: "txi:#{first_txi}-#{last_txi}")
|> get("/v3/transactions/count", scope: "txi:#{first_txi}-#{last_txi}")
|> json_response(200)
end

Expand All @@ -1648,7 +1648,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 100 =
conn
|> with_store(store)
|> get("/v2/txs/count", scope: "gen:#{first_gen}-#{last_gen}")
|> get("/v3/transactions/count", scope: "gen:#{first_gen}-#{last_gen}")
|> json_response(200)
end

Expand All @@ -1665,19 +1665,19 @@ defmodule AeMdwWeb.TxControllerTest do
assert ^count =
conn
|> with_store(store)
|> get("/v2/txs/count", type: "oracle_register")
|> get("/v3/transactions/count", type: "oracle_register")
|> json_response(200)

assert ^count =
conn
|> with_store(store)
|> get("/v2/txs/count", tx_type: "oracle_register")
|> get("/v3/transactions/count", tx_type: "oracle_register")
|> json_response(200)

assert 0 =
conn
|> with_store(store)
|> get("/v2/txs/count", tx_type: "oracle_response")
|> get("/v3/transactions/count", tx_type: "oracle_response")
|> json_response(200)
end

Expand All @@ -1694,7 +1694,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert ^count =
conn
|> with_store(store)
|> get("/v2/txs/count", tx_type: "oracle_register")
|> get("/v3/transactions/count", tx_type: "oracle_register")
|> json_response(200)
end

Expand All @@ -1717,7 +1717,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 5 =
conn
|> with_store(store)
|> get("/v2/txs/count", id: account_id, type: "spend")
|> get("/v3/transactions/count", id: account_id, type: "spend")
|> json_response(200)
end
end
Expand All @@ -1742,7 +1742,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 15 =
conn
|> with_store(store)
|> get("/v2/txs/count", id: enc_address)
|> get("/v3/transactions/count", id: enc_address)
|> json_response(200)
end

Expand All @@ -1767,7 +1767,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 14 =
conn
|> with_store(store)
|> get("/v2/txs/count", id: enc_address)
|> get("/v3/transactions/count", id: enc_address)
|> json_response(200)
end

Expand All @@ -1790,7 +1790,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 5 =
conn
|> with_store(store)
|> get("/v2/txs/count/#{enc_address}", type: "spend")
|> get("/v3/transactions/count/#{enc_address}", type: "spend")
|> json_response(200)
end

Expand Down Expand Up @@ -1823,7 +1823,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert 12 =
conn
|> with_store(store)
|> get("/v2/txs/count/#{enc_address}", type_group: "contract")
|> get("/v3/transactions/count/#{enc_address}", type_group: "contract")
|> json_response(200)
end

Expand Down Expand Up @@ -1857,7 +1857,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert %{"data" => 3} =
conn
|> with_store(store)
|> get("/v2/txs/count", mb_hash: encoded_mb_hash)
|> get("/v3/transactions/count", mb_hash: encoded_mb_hash)
|> json_response(200)
end
end
Expand Down Expand Up @@ -1895,7 +1895,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert %{"data" => 2} =
conn
|> with_store(store)
|> get("/v2/txs/count", mb_hash: encoded_mb_hash, type: "contract_call")
|> get("/v3/transactions/count", mb_hash: encoded_mb_hash, type: "contract_call")
|> json_response(200)
end
end
Expand Down Expand Up @@ -1923,7 +1923,7 @@ defmodule AeMdwWeb.TxControllerTest do
assert %{"error" => ^error_msg} =
conn
|> with_store(store)
|> get("/v2/txs/count", mb_hash: encoded_mb_hash)
|> get("/v3/transactions/count", mb_hash: encoded_mb_hash)
|> json_response(404)
end
end
Expand All @@ -1933,7 +1933,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert %{"error" => ^error_msg} =
conn
|> get("/v2/txs/count", type: "oracle_foo")
|> get("/v3/transactions/count", type: "oracle_foo")
|> json_response(400)
end

Expand All @@ -1942,7 +1942,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert %{"error" => ^error_msg} =
conn
|> get("/v2/txs/count", id: "foo")
|> get("/v3/transactions/count", id: "foo")
|> json_response(400)
end

Expand All @@ -1951,7 +1951,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert %{"error" => ^error_msg} =
conn
|> get("/v2/txs/count/foo", type: "oracle_query")
|> get("/v3/transactions/count/foo", type: "oracle_query")
|> json_response(400)
end

Expand All @@ -1960,7 +1960,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert %{"error" => ^error_msg} =
conn
|> get("/v2/txs/count/foo", type_group: "oracle")
|> get("/v3/transactions/count/foo", type_group: "oracle")
|> json_response(400)
end

Expand All @@ -1970,7 +1970,7 @@ defmodule AeMdwWeb.TxControllerTest do

assert %{"error" => ^error_msg} =
conn
|> get("/v2/txs/count", id: id, scope: "gen:1-2")
|> get("/v3/transactions/count", id: id, scope: "gen:1-2")
|> json_response(400)
end
end
Expand Down