-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor: move formatting to main render functions #775
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got some integration test errors using staging 1.14 snapshot. However calling one endpoint locally worked: /v2/oracles/ok_R7cQfVN15F5ek1wBSYaMRjW2XbMRKx7VDQQmbtwxspjZQvmPM
.
Some of the errors might related to other 1.15 issue while some results indicated a call to Format
module:
2) test oracle get oracle information for given oracle id (Integration.AeMdwWeb.OracleControllerTest)
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:18
** (FunctionClauseError) no function clause matching in AeMdw.Db.Format.to_map/3
The following arguments were given to AeMdw.Db.Format.to_map/3:
# 1
%AeMdw.Db.State{cache: %{}, jobs: %{}, stats: %{}, store: %AeMdw.Db.DbStore{}}
# 2
{:oracle, <<54, 192, 244, 73, 174, 156, 95, 127, 38, 129, 230, 7, 121, 152, 205, 152, 215, 243, 207, 101, 25, 180, 137, 30, 98, 88, 243, 169, 200, 145, 218, 49>>, 4660, 6894, {{4660, 0}, 11023}, [{{4662, 0}, 11025}], nil}
# 3
AeMdw.Db.Model.InactiveOracle
Attempted function clauses (showing 4 out of 4):
def to_map(state, {:tx, index, _hash, {_kb_index, mb_index}, mb_time}, {block_hash, type, signed_tx, tx_rec})
def to_map(state, auction_bid, AeMdw.Db.Model.AuctionBid)
def to_map(state, m_name, source) when source === AeMdw.Db.Model.ActiveName or source === AeMdw.Db.Model.InactiveName
def to_map(state, {call_txi, local_idx}, AeMdw.Db.Model.IntContractCall)
code: TestUtil.handle_input(fn ->
stacktrace:
(ae_mdw 1.14.0) lib/ae_mdw/db/format.ex:182: AeMdw.Db.Format.to_map/3
(ae_mdw 1.14.0) test/support/test_util.ex:6: AeMdwWeb.TestUtil.handle_input/1
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:23: (test)
3) test inactive_oracles it gets active oracles with limit=1 and expand parameter (Integration.AeMdwWeb.OracleControllerTest)
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:344
** (RuntimeError) {623238, -1} not found in Elixir.AeMdw.Db.Model.Block
code: |> get("/oracles", state: "inactive", limit: limit, expand: true)
stacktrace:
(ae_mdw 1.14.0) lib/ae_mdw/db/state.ex:108: AeMdw.Db.State.fetch!/3
(ae_mdw 1.14.0) lib/ae_mdw/blocks.ex:73: AeMdw.Blocks.block_hash/2
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:170: AeMdw.Oracles.render/5
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:54: AeMdw.Oracles.fetch_oracles/6
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:49: AeMdwWeb.OracleController.oracles/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.action/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.phoenix_controller_pipeline/2
(phoenix 1.5.8) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.plug_builder_call/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.call/2
(phoenix 1.5.8) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:349: (test)
...
4) test oracle get oracle information for given oracle id with expand parameter (Integration.AeMdwWeb.OracleControllerTest)
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:30
** (FunctionClauseError) no function clause matching in AeMdw.Db.Format.bi_txi_txi/1
The following arguments were given to AeMdw.Db.Format.bi_txi_txi/1:
# 1
8916
Attempted function clauses (showing 1 out of 1):
def bi_txi_txi({{_height, _mbi}, txi})
code: conn = get(conn, "/v2/oracles/#{id}?expand")
stacktrace:
(ae_mdw 1.14.0) lib/ae_mdw/db/format.ex:22: AeMdw.Db.Format.bi_txi_txi/1
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:209: AeMdw.Oracles.expand_txi/3
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:179: AeMdw.Oracles.render/5
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:124: AeMdw.Oracles.fetch/3
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:19: AeMdwWeb.OracleController.oracle/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.action/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.phoenix_controller_pipeline/2
(phoenix 1.5.8) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.plug_builder_call/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.call/2
(phoenix 1.5.8) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:32: (test)
.....
5) test inactive_oracles get inactive oracles with limit=1 and expand parameter (Integration.AeMdwWeb.OracleControllerTest)
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:247
** (FunctionClauseError) no function clause matching in AeMdw.Db.Format.bi_txi_txi/1
The following arguments were given to AeMdw.Db.Format.bi_txi_txi/1:
# 1
32724723
Attempted function clauses (showing 1 out of 1):
def bi_txi_txi({{_height, _mbi}, txi})
code: |> get("/oracles/inactive", limit: limit, expand: "true")
stacktrace:
(ae_mdw 1.14.0) lib/ae_mdw/db/format.ex:22: AeMdw.Db.Format.bi_txi_txi/1
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:209: AeMdw.Oracles.expand_txi/3
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:179: AeMdw.Oracles.render/5
(elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
(ae_mdw 1.14.0) lib/ae_mdw/oracles.ex:113: AeMdw.Oracles.fetch_inactive_oracles/4
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:29: AeMdwWeb.OracleController.inactive_oracles/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.action/2
(ae_mdw 1.14.0) lib/ae_mdw_web/controllers/oracle_controller.ex:1: AeMdwWeb.OracleController.phoenix_controller_pipeline/2
(phoenix 1.5.8) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.plug_builder_call/2
(ae_mdw 1.14.0) lib/ae_mdw_web/endpoint.ex:1: AeMdwWeb.Endpoint.call/2
(phoenix 1.5.8) lib/phoenix/test/conn_test.ex:225: Phoenix.ConnTest.dispatch/5
test/integration/ae_mdw_web/controllers/oracle_controller_test.exs:252: (test)
@jyeshe the error was caused by an integration test that was using a Format function that wasn't used anywhere else. Updated it now, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup and formatting integration tests passed ✔️
This is a pre-amble to start adding tx_hash for every txi found. Plus, it removes some unused code that won't need to be looked into