-
Notifications
You must be signed in to change notification settings - Fork 72
fix: Load routes via store #563
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
base: edge
Are you sure you want to change the base?
Changes from all commits
d90332b
a389931
e37442d
22b74d0
2d66d2d
ca810b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,8 @@ read(BaseStoreOpts, Key) -> | |
| %% @doc Normalize the routes in the given `Opts`. | ||
| opts(Opts) -> | ||
| case hb_maps:find(<<"node">>, Opts) of | ||
| error -> Opts; | ||
| error -> | ||
| hb_opts:mimic_default_types(Opts, existing, Opts); | ||
| {ok, Node} -> | ||
| case hb_maps:get(<<"node-type">>, Opts, <<"arweave">>, Opts) of | ||
| <<"arweave">> -> | ||
|
|
@@ -214,23 +215,49 @@ cache_read_message_test() -> | |
| %% produce the same result, despite an empty 'only' route list, then we would | ||
| %% know that the module is not respecting the route list. | ||
| specific_route_test() -> | ||
| hb_http_server:start_node(#{}), | ||
| LocalNode = hb_http_server:start_node(#{}), | ||
| %% Define the response we want | ||
| ID = <<"BOogk_XAI3bvNWnxNxwxmvOfglZt17o4MOVAdPNZ_ew">>, | ||
| %% Define configuration, we use a valid gateway to obtain a valid response | ||
| %% and then mock the raw endpoint to our mockserver. | ||
| Opts = #{ | ||
| store => | ||
| [ | ||
| #{ <<"store-module">> => hb_store_gateway, | ||
| <<"routes">> => [], | ||
| <<"only">> => local | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting... Why would
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is the behavior that is shown here. By not loading the remaining configuration from the global defaults, the following modules, which need access to some of the defaults (like Because we're testing only a different |
||
| <<"routes">> => [ | ||
| #{ | ||
| <<"template">> => <<"/graphql">>, | ||
| <<"nodes">> => [ | ||
| #{ | ||
| <<"prefix">> => <<"https://arweave-search.goldsky.com">>, | ||
| <<"opts">> => #{ | ||
| <<"http_client">> => httpc, | ||
| <<"protocol">> => http2 | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| #{ | ||
| <<"template">> => <<"/raw">>, | ||
| <<"node">> => | ||
| %% This prefix allow us to set a custom message that is a little bit | ||
| %% different than the original one (data field isn't provided). | ||
| #{ | ||
| <<"prefix">> => <<LocalNode/binary, "~message@1.0/message?message=3#">>, | ||
| <<"opts">> => #{ | ||
| <<"http_client">> => gun, | ||
| <<"protocol">> => http2 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| ?assertMatch( | ||
| not_found, | ||
| hb_cache:read( | ||
| <<"BOogk_XAI3bvNWnxNxwxmvOfglZt17o4MOVAdPNZ_ew">>, | ||
| Opts | ||
| ) | ||
| ). | ||
|
Comment on lines
-227
to
-233
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of error behaviours that mimic a "true" |
||
| {ok, Response} = hb_cache:read(ID, Opts), | ||
| %% If the result returns <<"1984">>, it is using the default route, | ||
| %% not the custom one we defined | ||
| ?assert(maps:get(<<"data">>, Response, <<>>) /= <<"1984">>). | ||
|
|
||
| %% @doc Test that the default node config allows for data to be accessed. | ||
| external_http_access_test() -> | ||
|
|
||
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.
Since now
<<"routes">>is converted toroutesatom,falseis not an acceptable result.