Skip to content

Commit 7348568

Browse files
g1itchLee Miller
authored andcommitted
The test for double SHA512
1 parent 3ed84a5 commit 7348568

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/tests/samples.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
from binascii import unhexlify
44

5+
# hello, page 1 of the Specification
6+
sample_hash_data = b'hello'
7+
sample_double_sha512 = unhexlify(
8+
'0592a10584ffabf96539f3d780d776828c67da1ab5b169e9e8aed838aaecc9ed36d49ff14'
9+
'23c55f019e050c66c6324f53588be88894fef4dcffdb74b98e2b200')
10+
511

612
# 500 identical peers:
713
# 1626611891, 1, 1, 127.0.0.1, 8444

src/tests/test_crypto.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
RIPEMD160 = None
1818

1919
from .samples import (
20+
sample_double_sha512, sample_hash_data,
2021
sample_msg, sample_pubsigningkey, sample_pubencryptionkey,
2122
sample_privsigningkey, sample_privencryptionkey, sample_ripe,
2223
sample_sig, sample_sig_sha1
@@ -66,6 +67,12 @@ def _hashdigest(data):
6667
class TestHighlevelcrypto(unittest.TestCase):
6768
"""Test highlevelcrypto public functions"""
6869

70+
def test_double_sha512(self):
71+
"""Reproduce the example on page 1 of the Specification"""
72+
self.assertEqual(
73+
highlevelcrypto.double_sha512(sample_hash_data),
74+
sample_double_sha512)
75+
6976
def test_randomBytes(self):
7077
"""Dummy checks for random bytes"""
7178
for n in (8, 32, 64):

0 commit comments

Comments
 (0)