Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Berman committed Jun 14, 2023
1 parent 2ae0c8e commit 24ceea9
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion apps/arweave/src/ar_merkle.erl
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,52 @@ generate_and_validate_tree_with_rebase_test() ->
{Leaf6, Left3_6, Right3_6} = ar_merkle:validate_path2(Root3,
5 * ?DATA_CHUNK_SIZE, 6 * ?DATA_CHUNK_SIZE, Path3_6),
?assertEqual(5 * ?DATA_CHUNK_SIZE, Left3_6),
?assertEqual(6 * ?DATA_CHUNK_SIZE, Right3_6).
?assertEqual(6 * ?DATA_CHUNK_SIZE, Right3_6),
%% Root4
%% / \
%% SubTree1 SubTree2
%% / \ / \
%% Leaf1 Leaf2 SubTree3 (with offset reset) SubTree4 (with offset reset)
%% / \ / \
%% Leaf3 Leaf4 Leaf5 Leaf6
?debugMsg("Tree 4"),
Tags4 = [{Leaf1, ?DATA_CHUNK_SIZE}, {Leaf2, ?DATA_CHUNK_SIZE * 2},
[{Leaf3, ?DATA_CHUNK_SIZE}, {Leaf4, 2 * ?DATA_CHUNK_SIZE}],
[{Leaf5, ?DATA_CHUNK_SIZE}, {Leaf6, ?DATA_CHUNK_SIZE * 2}]],
{Root4, Tree4} = ar_merkle:generate_tree(Tags4),
Path4_1 = ar_merkle:generate_path(Root4, 0, Tree4),
?debugMsg("Path 1"),
{Leaf1, 0, ?DATA_CHUNK_SIZE} = ar_merkle:validate_path2(Root4, 0,
6 * ?DATA_CHUNK_SIZE, Path4_1),
Path4_2 = ar_merkle:generate_path(Root4, ?DATA_CHUNK_SIZE, Tree4),
?debugMsg("Path 2"),
{Leaf2, ?DATA_CHUNK_SIZE, Right4_2} = ar_merkle:validate_path2(Root4, ?DATA_CHUNK_SIZE,
6 * ?DATA_CHUNK_SIZE, Path4_2),
?assertEqual(2 * ?DATA_CHUNK_SIZE, Right4_2),
Path4_3 = ar_merkle:generate_path(Root4, ?DATA_CHUNK_SIZE * 2, Tree4),
?debugMsg("Path 3"),
{Leaf3, Left4_3, Right4_3} = ar_merkle:validate_path2(Root4,
2 * ?DATA_CHUNK_SIZE, 6 * ?DATA_CHUNK_SIZE, Path4_3),
?assertEqual(2 * ?DATA_CHUNK_SIZE, Left4_3),
?assertEqual(3 * ?DATA_CHUNK_SIZE, Right4_3),
Path4_4 = ar_merkle:generate_path(Root4, ?DATA_CHUNK_SIZE * 3, Tree4),
?debugMsg("Path 4"),
{Leaf4, Left4_4, Right4_4} = ar_merkle:validate_path2(Root4,
3 * ?DATA_CHUNK_SIZE, 6 * ?DATA_CHUNK_SIZE, Path4_4),
?assertEqual(3 * ?DATA_CHUNK_SIZE, Left4_4),
?assertEqual(4 * ?DATA_CHUNK_SIZE, Right4_4),
Path4_5 = ar_merkle:generate_path(Root4, ?DATA_CHUNK_SIZE * 4, Tree4),
?debugMsg("Path 5"),
{Leaf5, Left4_5, Right4_5} = ar_merkle:validate_path2(Root4,
4 * ?DATA_CHUNK_SIZE, 6 * ?DATA_CHUNK_SIZE, Path4_5),
?assertEqual(4 * ?DATA_CHUNK_SIZE, Left4_5),
?assertEqual(5 * ?DATA_CHUNK_SIZE, Right4_5),
Path4_6 = ar_merkle:generate_path(Root4, ?DATA_CHUNK_SIZE * 5, Tree4),
?debugMsg("Path 6"),
{Leaf6, Left4_6, Right4_6} = ar_merkle:validate_path2(Root4,
5 * ?DATA_CHUNK_SIZE, 6 * ?DATA_CHUNK_SIZE, Path4_6),
?assertEqual(5 * ?DATA_CHUNK_SIZE, Left4_6),
?assertEqual(6 * ?DATA_CHUNK_SIZE, Right4_6).

generate_and_validate_uneven_tree_path_test() ->
Tags = make_tags_cumulative([{<<N:256>>, 1}
Expand Down

0 comments on commit 24ceea9

Please sign in to comment.