From 4cf79726e35c9da7c1e92571834defcdc051f04c Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sat, 19 Oct 2024 03:15:42 -0300 Subject: [PATCH] fix: lint --- merkly/mtree.py | 16 ++++++++-------- test/merkle_proof/test_merkle_proof.py | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/merkly/mtree.py b/merkly/mtree.py index cf26fac..635e908 100644 --- a/merkly/mtree.py +++ b/merkly/mtree.py @@ -179,24 +179,24 @@ def verify_proof(proof: List[Node], raw_leaf: str, root: str, **kwargs) -> bool: """ Verify the validity of a Merkle proof for a given leaf against the expected root hash. - This method checks whether the provided proof can reconstruct the root hash - from the given raw leaf data. It uses the specified hash function to compute + This method checks whether the provided proof can reconstruct the root hash + from the given raw leaf data. It uses the specified hash function to compute the hashes along the proof path. Args: - proof (List[Node]): A list of Nodes representing the Merkle proof. Each Node + proof (List[Node]): A list of Nodes representing the Merkle proof. Each Node contains the hash of a sibling node and its position (left or right) in the tree. - raw_leaf (str): The raw leaf data (in string format) for which the proof is + raw_leaf (str): The raw leaf data (in string format) for which the proof is being verified. This data should correspond to a leaf in the Merkle tree. - root (str): The expected root hash (in hexadecimal string format) that the + root (str): The expected root hash (in hexadecimal string format) that the proof should reconstruct if valid. **kwargs: Optional keyword arguments. Can include: - - hash_function (Callable[[bytes, bytes], bytes]): A custom hash function - that takes two byte inputs and returns a hash. If not provided, + - hash_function (Callable[[bytes, bytes], bytes]): A custom hash function + that takes two byte inputs and returns a hash. If not provided, the default `keccak` function is used. Returns: - bool: Returns True if the proof is valid and reconstructs the expected root + bool: Returns True if the proof is valid and reconstructs the expected root hash; otherwise, returns False. Example: diff --git a/test/merkle_proof/test_merkle_proof.py b/test/merkle_proof/test_merkle_proof.py index 88471a1..5213abf 100644 --- a/test/merkle_proof/test_merkle_proof.py +++ b/test/merkle_proof/test_merkle_proof.py @@ -90,6 +90,8 @@ def test_verify_merkle_proof_without_leaves(): assert not invalid_result, "Expected proof to be invalid for incorrect leaf" # Test with a different root - different_root = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" + different_root = ( + "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" + ) different_result = MerkleTree.verify_proof(proof, leaf, different_root) assert not different_result, "Expected proof to be invalid for different root"