Skip to content

Commit e3d47b2

Browse files
committed
improvements: code clean up
1 parent ca8d0fa commit e3d47b2

File tree

9 files changed

+115
-106
lines changed

9 files changed

+115
-106
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ HyperBEAM supports several optional build profiles that enable additional featur
8787

8888
- `genesis_wasm`: Enables Genesis WebAssembly support
8989
- `rocksdb`: Enables RocksDB storage backend (adds RocksDB v1.8.0 dependency)
90-
- `s3`: Enables S3 storage backend
90+
- `s3`: Enables S3 storage backend
9191
- `http3`: Enables HTTP/3 support via QUIC protocol
9292

9393
Using these profiles allows you to optimize HyperBEAM for your specific use case without adding unnecessary dependencies to the base installation.
@@ -109,7 +109,9 @@ To create a release with profiles:
109109
rebar3 as rocksdb,genesis_wasm release
110110

111111
# Run S3 integration tests (make sure you have docker-compose installed)
112-
rebar3 as s3 cmd docker_up, eunit --module hb_store_s3, cmd docker_down
112+
docker-compose -f test/docker-compose.yml -d up
113+
rebar3 as s3 eunit --module hb_store_s3
114+
docker-compose -f test/docker-compose.yml -d down
113115
```
114116

115117
Note: Profiles modify compile-time options that get baked into the release. Choose the profiles you need before starting HyperBEAM.
@@ -269,9 +271,9 @@ schedule of another execution.
269271
Details on other devices found in the pre-loaded set can be located in their
270272
respective documentation.
271273

272-
## Testing
274+
## Testing
273275

274-
### Running tests
276+
### Running tests
275277

276278
Specific tests can be ran with `--test` parameter:
277279

@@ -309,9 +311,9 @@ To test generator tests, you need to add `-g` to the eunit command:
309311
rebar3 eunit -g hb_cache:cache_suite_test_
310312
```
311313

312-
### Generating test coverage report
314+
### Generating test coverage report
313315

314-
Add `--cover` to the eunit command to generate test coverage data.
316+
Add `--cover` to the eunit command to generate test coverage data.
315317
To generate the HTML report, run the command `cover`.
316318

317319
```
@@ -351,4 +353,4 @@ HyperBEAM is developed as an open source implementation of the AO-Core protocol
351353
by [Forward Research](https://fwd.arweave.net). Pull Requests are always welcome!
352354

353355
To get started building on HyperBEAM, check out the [hacking on HyperBEAM](./docs/misc/hacking-on-hyperbeam.md)
354-
guide.
356+
guide.

rebar.config

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@
6262
{add, gun, [{erl_opts, [{d, 'GUN_QUICER', 1}]}]}
6363
]}
6464
]},
65-
{recon, [{deps, [{recon, "2.5.6"}]}]},
6665
{test, [
67-
{deps, [{meck, "1.1.0"}]}
66+
{deps, [{meck, "1.1.0"}]}
6867
]}
6968
]}.
7069

@@ -193,4 +192,4 @@
193192
{preprocess, true},
194193
{private, true},
195194
{hidden, true}
196-
]}.
195+
]}.

src/dev_scheduler.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,4 +2272,4 @@ benchmark_suite(Port, Base) ->
22722272
},
22732273
desc => <<"100xRocksDB store, aggressive conf, http/3.">>
22742274
}
2275-
].
2275+
].

src/hb_cache.erl

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ read(Path, Opts) ->
385385
%% @doc List all of the subpaths of a given path and return a map of keys and
386386
%% links to the subpaths, including their types.
387387
store_read(_Path, no_viable_store, _) ->
388-
erlang:display("NO_VIABLE_STORE"),
389388
not_found;
390389
store_read(Path, Store, Opts) ->
391390
ResolvedFullPath = hb_store:resolve(Store, PathBin = hb_path:to_binary(Path)),
@@ -395,16 +394,12 @@ store_read(Path, Store, Opts) ->
395394
{store, Store}
396395
}),
397396
case hb_store:type(Store, ResolvedFullPath) of
398-
not_found ->
399-
erlang:display({type_not_found, {resolved_full_path, ResolvedFullPath}}),
400-
not_found;
397+
not_found -> not_found;
401398
simple ->
402399
?event({reading_data, ResolvedFullPath}),
403400
case hb_store:read(Store, ResolvedFullPath) of
404401
{ok, Bin} -> {ok, Bin};
405-
not_found ->
406-
erlang:display("NOT FOUND"),
407-
not_found
402+
not_found -> not_found
408403
end;
409404
composite ->
410405
?event({reading_composite, ResolvedFullPath}),
@@ -888,9 +883,7 @@ test_message_with_list(Store) ->
888883
{ok, RetrievedItem} = read(Path, Opts),
889884
?assert(hb_message:match(Msg, RetrievedItem, strict, Opts)).
890885

891-
test_match_message(Store) when map_get(<<"store-module">>, Store) =/= hb_store_lmdb ->
892-
Module = map_get(<<"store-module">>, Store),
893-
?event({test_skip, {module, Module}}),
886+
test_match_message(Store) when map_get(<<"store-module">>, Store) =/= hb_store_lmdb ->
894887
skip;
895888
test_match_message(Store) ->
896889
hb_store:reset(Store),
@@ -918,8 +911,6 @@ test_match_message(Store) ->
918911
?assertEqual([ID2b], MatchedItems2).
919912

920913
test_match_linked_message(Store) when map_get(<<"store-module">>, Store) =/= hb_store_lmdb ->
921-
Module = map_get(<<"store-module">>, Store),
922-
?event({test_skip, {module, Module}}),
923914
skip;
924915
test_match_linked_message(Store) ->
925916
hb_store:reset(Store),
@@ -937,8 +928,6 @@ test_match_linked_message(Store) ->
937928
?assertEqual(#{ <<"a">> => Inner }, ensure_all_loaded(Read2, Opts)).
938929

939930
test_match_typed_message(Store) when map_get(<<"store-module">>, Store) =/= hb_store_lmdb ->
940-
Module = map_get(<<"store-module">>, Store),
941-
?event({test_skip, {module, Module}}),
942931
skip;
943932
test_match_typed_message(Store) ->
944933
hb_store:reset(Store),
@@ -994,4 +983,4 @@ test_device_map_cannot_be_written_test() ->
994983
%% @doc Run a specific test with a given store module.
995984
run_test() ->
996985
Store = hb_test_utils:test_store(hb_store_lmdb),
997-
test_match_message(Store).
986+
test_match_message(Store).

src/hb_cache_control.erl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,11 @@ perform_cache_write(Base, Req, Res, Opts) ->
136136
hb_cache:write(Req, Opts),
137137
case Res of
138138
<<_/binary>> ->
139-
Store = hb_opts:get(store, no_viable_store, Opts),
140-
HP = hb_path:hashpath(Base, Req, Opts),
141-
DataPath = <<"data/", (hb_path:hashpath(Res, Opts))/binary>>,
142-
case hb_store:type(Store, DataPath) of
143-
simple -> hb_store:make_link(Store, DataPath, HP);
144-
_ -> hb_cache:write_binary(HP, Res, Opts)
145-
end;
139+
hb_cache:write_binary(
140+
hb_path:hashpath(Base, Req, Opts),
141+
Res,
142+
Opts
143+
);
146144
Map when is_map(Map) ->
147145
hb_cache:write(Res, Opts);
148146
_ ->
@@ -425,4 +423,4 @@ cache_message_result_test() ->
425423
{ok, Res3} = hb_ao:resolve(Base, Req, #{ cache_control => [<<"only-if-cached">>] }),
426424
?event({res2, Res2}),
427425
?event({res3, Res3}),
428-
?assertEqual(Res2, Res3).
426+
?assertEqual(Res2, Res3).

src/hb_http_client.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-behaviour(gen_server).
55
-include("include/hb.hrl").
66
-export([start_link/1, request/2]).
7-
-export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, open_connection/2]).
7+
-export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2]).
88

99
-record(state, {
1010
pid_by_peer = #{},
@@ -154,7 +154,7 @@ gun_req(Args, ReestablishedConnection, Opts) ->
154154
Reply ->
155155
Reply
156156
end;
157-
{'EXIT', Reason} ->
157+
{'EXIT', _} ->
158158
{error, client_error};
159159
Error ->
160160
Error

src/hb_store.erl

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -426,20 +426,20 @@ call_all([Store = #{<<"store-module">> := Mod} | Rest], Function, Args) ->
426426
%% default into all HyperBEAM distributions.
427427
test_stores() ->
428428
[
429-
% (hb_test_utils:test_store(hb_store_fs))#{
430-
% <<"benchmark-scale">> => 0.001
431-
% },
432-
% (hb_test_utils:test_store(hb_store_lmdb))#{
433-
% <<"benchmark-scale">> => 0.5
434-
% },
435-
% (hb_test_utils:test_store(hb_store_lru))#{
436-
% <<"persistent-store">> => [
437-
% #{
438-
% <<"store-module">> => hb_store_fs,
439-
% <<"name">> => <<"cache-TEST/lru">>
440-
% }
441-
% ]
442-
% }
429+
(hb_test_utils:test_store(hb_store_fs))#{
430+
<<"benchmark-scale">> => 0.001
431+
},
432+
(hb_test_utils:test_store(hb_store_lmdb))#{
433+
<<"benchmark-scale">> => 0.5
434+
},
435+
(hb_test_utils:test_store(hb_store_lru))#{
436+
<<"persistent-store">> => [
437+
#{
438+
<<"store-module">> => hb_store_fs,
439+
<<"name">> => <<"cache-TEST/lru">>
440+
}
441+
]
442+
}
443443
] ++ rocks_stores() ++ s3_stores().
444444

445445
-ifdef(ENABLE_ROCKSDB).
@@ -475,8 +475,7 @@ generate_test_suite(Suite, Stores) ->
475475
hb_store:reset(Store)
476476
end,
477477
fun(_) ->
478-
%hb_store:reset(Store)
479-
ok
478+
hb_store:reset(Store)
480479
% hb_store:stop(Store)
481480
end,
482481
[
@@ -533,8 +532,8 @@ store_suite_test_() ->
533532

534533
benchmark_suite_test_() ->
535534
generate_test_suite([
536-
%{"benchmark key read write", fun benchmark_key_read_write/1},
537-
%{"benchmark list", fun benchmark_list/1},
535+
{"benchmark key read write", fun benchmark_key_read_write/1},
536+
{"benchmark list", fun benchmark_list/1},
538537
{"benchmark message read write", fun benchmark_message_read_write/1}
539538
]).
540539

@@ -852,7 +851,6 @@ benchmark_message_read_write(Store, WriteOps, ReadOps) ->
852851
fun({MsgID, Msg}, Count) ->
853852
case hb_cache:read(MsgID, Opts) of
854853
{ok, Base} ->
855-
erlang:display(Base),
856854
case hb_cache:ensure_all_loaded(Base, Opts) of
857855
Msg -> Count;
858856
_ -> Count + 1

0 commit comments

Comments
 (0)