MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / testSha

Method testSha

src/Test/TestCryptHash.py:12–25  ·  view source on GitHub ↗
(self, site)

Source from the content-addressed store, hash-verified

10class TestCryptBitcoin:
11
12 def testSha(self, site):
13 file_path = site.storage.getPath("dbschema.json")
14 assert CryptHash.sha512sum(file_path) == sha512t_sum_hex
15 assert CryptHash.sha512sum(open(file_path, "rb")) == sha512t_sum_hex
16 assert CryptHash.sha512sum(open(file_path, "rb"), format="digest") == sha512t_sum_bin
17
18 assert CryptHash.sha256sum(file_path) == sha256_sum_hex
19 assert CryptHash.sha256sum(open(file_path, "rb")) == sha256_sum_hex
20
21 with open(file_path, "rb") as f:
22 hash = CryptHash.Sha512t(f.read(100))
23 hash.hexdigest() != sha512t_sum_hex
24 hash.update(f.read(1024 * 1024))
25 assert hash.hexdigest() == sha512t_sum_hex
26
27 def testRandom(self):
28 assert len(CryptHash.random(64)) == 64

Callers

nothing calls this directly

Calls 4

hexdigestMethod · 0.95
updateMethod · 0.95
getPathMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected