diff --git a/test/test_accelerator.py b/test/accelerator/test_accelerator.py similarity index 85% rename from test/test_accelerator.py rename to test/accelerator/test_accelerator.py index 664984d..3af0de7 100644 --- a/test/test_accelerator.py +++ b/test/accelerator/test_accelerator.py @@ -24,7 +24,10 @@ def test_merkle_root_rust(): print(x.hex()) result = tree.make_root(leafs) - assert result.hex() == "6b403b6dbdd79d6bb882036292bbe89a57e10defabd5c6718e66321c79b96abd", "Rust merkle root" + assert ( + result.hex() + == "6b403b6dbdd79d6bb882036292bbe89a57e10defabd5c6718e66321c79b96abd" + ), "Rust merkle root" def test_merkle_root_python(): @@ -36,6 +39,5 @@ def test_merkle_root_python(): result = tree.make_root(leafs) assert ( - result[0] - == "6b403b6dbdd79d6bb882036292bbe89a57e10defabd5c6718e66321c79b96abd" + result[0] == "6b403b6dbdd79d6bb882036292bbe89a57e10defabd5c6718e66321c79b96abd" ), "Rust merkle root" diff --git a/test/merkletreejs/index.py b/test/merkletreejs/index.py index 94b126b..220ca1d 100644 --- a/test/merkletreejs/index.py +++ b/test/merkletreejs/index.py @@ -2,14 +2,17 @@ import hashlib + def hashing(data): return hashlib.sha256(data.encode()).hexdigest() + def hashing2(data: str): keccak_256 = keccak.new(digest_bits=256) keccak_256.update(data.encode()) return keccak_256.hexdigest() + class MerkleTree: def __init__(self, leaves): self.leaves = [hashing2(leaf) for leaf in leaves] @@ -31,12 +34,12 @@ def get_merkle_root(self): return self.tree[-1][0] if self.tree else None - -leaves = ['a', 'b', 'c', 'd'] +leaves = ["a", "b", "c", "d"] tree = MerkleTree(leaves) root = tree.get_merkle_root() leafs = tree.leaves -for i in leafs: print(i) +for i in leafs: + print(i) print(root)