Set 404 on blocks which lose consensus (#7244)

* Set 404 on blocks which lose consensus

* Changelog
pull/7245/head
nikitosing 2 years ago committed by GitHub
parent 43b04e733c
commit 46f77791e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 1
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/fallback_controller.ex
  3. 2
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/block_controller_test.exs

@ -5,7 +5,7 @@
### Features
- [#7185](https://github.com/blockscout/blockscout/pull/7185) - Aave v3 transaction actions indexer
- [#7148](https://github.com/blockscout/blockscout/pull/7148) - API v2 improvements: API rate limiting, `/tokens/{address_hash}/instances/{token_id}/holders` and other changes
- [#7148](https://github.com/blockscout/blockscout/pull/7148), [#7244](https://github.com/blockscout/blockscout/pull/7244) - API v2 improvements: API rate limiting, `/tokens/{address_hash}/instances/{token_id}/holders` and other changes
### Fixes

@ -81,6 +81,7 @@ defmodule BlockScoutWeb.API.V2.FallbackController do
def call(conn, {:lost_consensus, {:ok, block}}) do
conn
|> put_status(:not_found)
|> json(%{message: "Block lost consensus", hash: to_string(block.hash)})
end

@ -206,7 +206,7 @@ defmodule BlockScoutWeb.API.V2.BlockControllerTest do
hash = to_string(block.hash)
request_1 = get(conn, "/api/v2/blocks/#{block.number}")
assert %{"message" => "Block lost consensus", "hash" => ^hash} = json_response(request_1, 200)
assert %{"message" => "Block lost consensus", "hash" => ^hash} = json_response(request_1, 404)
end
test "get the same blocks by hash and number", %{conn: conn} do

Loading…
Cancel
Save