Skip to content

Commit

Permalink
Rename calc_merkle_root to get_merkle_root_from_items
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Jan 8, 2019
1 parent e5c1205 commit 88445f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions eth/_utils/blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
zpad_right,
)
from eth._utils.merkle import (
calc_merkle_root,
get_merkle_root_from_items,
)

from eth.constants import (
Expand All @@ -44,7 +44,7 @@ def iterate_chunks(collation_body: bytes) -> Iterator[Hash32]:
def calc_chunk_root(collation_body: bytes) -> Hash32:
check_body_size(collation_body)
chunks = list(iterate_chunks(collation_body))
return calc_merkle_root(chunks)
return get_merkle_root_from_items(chunks)


def check_body_size(body: bytes) -> bytes:
Expand Down
2 changes: 1 addition & 1 deletion eth/_utils/merkle.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def calc_merkle_tree(items: Sequence[Union[bytes, bytearray]]) -> MerkleTree:
return calc_merkle_tree_from_leaves(leaves)


def calc_merkle_root(items: Sequence[Union[bytes, bytearray]]) -> Hash32:
def get_merkle_root_from_items(items: Sequence[Union[bytes, bytearray]]) -> Hash32:
"""
Calculate the Merkle root corresponding to a list of items.
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/core/merkle-utils/test_merkle_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

from eth._utils.merkle import (
calc_merkle_root,
get_merkle_root_from_items,
calc_merkle_tree,
get_root,
get_merkle_proof,
Expand Down Expand Up @@ -65,13 +65,13 @@ def test_merkle_tree_calculation(leaves, tree):
calculated_tree = calc_merkle_tree(leaves)
assert calculated_tree == tree
assert get_root(tree) == tree[0][0]
assert calc_merkle_root(leaves) == get_root(tree)
assert get_merkle_root_from_items(leaves) == get_root(tree)


@pytest.mark.parametrize("leave_number", [0, 3, 5, 6, 7, 9])
def test_invalid_merkle_root_calculation(leave_number):
with pytest.raises(ValueError):
calc_merkle_root((b"",) * leave_number)
get_merkle_root_from_items((b"",) * leave_number)


@pytest.mark.parametrize("leaves,index,proof", [
Expand Down

0 comments on commit 88445f1

Please sign in to comment.