Skip to content

Commit

Permalink
fix: handle invalid hashes error (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
sborrazas committed Mar 19, 2024
1 parent 75d945e commit fae0967
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ae_mdw/error.ex
Expand Up @@ -61,6 +61,7 @@ defmodule AeMdw.Error do
}

defexception!(Id)
defexception!(Hash)
defexception!(BlockIndex)
defexception!(NonnegInt)
defexception!(TxField)
Expand Down
10 changes: 10 additions & 0 deletions test/ae_mdw_web/controllers/block_controller_test.exs
Expand Up @@ -191,6 +191,16 @@ defmodule AeMdwWeb.BlockControllerTest do
|> json_response(404)
end
end

test "when key block hash is invalid, it returns 400", %{conn: conn} do
encoded_hash = "asdadads"
error_msg = "invalid hash: #{encoded_hash}"

assert %{"error" => ^error_msg} =
conn
|> get("/v2/key-blocks/#{encoded_hash}/micro-blocks")
|> json_response(400)
end
end

describe "key-block" do
Expand Down

0 comments on commit fae0967

Please sign in to comment.