Skip to content

Commit

Permalink
Better error handlin for get_info(Peer, Type)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPiechota committed Jul 10, 2024
1 parent 535fe9c commit 319984a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/arweave/src/ar_http_iface_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ get_info(Peer, Type) ->
case get_info(Peer) of
info_unavailable -> info_unavailable;
Info ->
maps:get(atom_to_binary(Type), Info)
maps:get(atom_to_binary(Type), Info, info_unavailable)
end.
get_info(Peer) ->
case
Expand Down
2 changes: 2 additions & 0 deletions apps/arweave/src/ar_peers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ discover_peers([Peer | Peers]) ->
case ar_http_iface_client:get_info(Peer, release) of
Release when is_integer(Release) ->
maybe_add_peer(Peer, Release);
info_unavailable ->
maybe_add_peer(Peer, 0);
_ ->
ok
end;
Expand Down
2 changes: 2 additions & 0 deletions apps/arweave/test/ar_http_iface_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ get_tx(ID) ->

%% @doc Ensure that server info can be retreived via the HTTP interface.
test_get_info(_) ->
?assertEqual(info_unavailable,
ar_http_iface_client:get_info(ar_test_node:peer_ip(main), bad_key)),
?assertEqual(<<?NETWORK_NAME>>,
ar_http_iface_client:get_info(ar_test_node:peer_ip(main), network)),
?assertEqual(?RELEASE_NUMBER,
Expand Down

0 comments on commit 319984a

Please sign in to comment.