From 7348568c78d5a25c6788e3951e9493791e39de21 Mon Sep 17 00:00:00 2001
From: Dmitri Bogomolov <4glitch@gmail.com>
Date: Thu, 29 Jul 2021 22:18:16 +0300
Subject: [PATCH] The test for double SHA512

---
 src/tests/samples.py     | 6 ++++++
 src/tests/test_crypto.py | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/tests/samples.py b/src/tests/samples.py
index 42a14f58..a80a61ae 100644
--- a/src/tests/samples.py
+++ b/src/tests/samples.py
@@ -2,6 +2,12 @@
 
 from binascii import unhexlify
 
+# hello, page 1 of the Specification
+sample_hash_data = b'hello'
+sample_double_sha512 = unhexlify(
+    '0592a10584ffabf96539f3d780d776828c67da1ab5b169e9e8aed838aaecc9ed36d49ff14'
+    '23c55f019e050c66c6324f53588be88894fef4dcffdb74b98e2b200')
+
 
 # 500 identical peers:
 # 1626611891, 1, 1, 127.0.0.1, 8444
diff --git a/src/tests/test_crypto.py b/src/tests/test_crypto.py
index 0065b318..0a6f9f96 100644
--- a/src/tests/test_crypto.py
+++ b/src/tests/test_crypto.py
@@ -17,6 +17,7 @@ except ImportError:
     RIPEMD160 = None
 
 from .samples import (
+    sample_double_sha512, sample_hash_data,
     sample_msg, sample_pubsigningkey, sample_pubencryptionkey,
     sample_privsigningkey, sample_privencryptionkey, sample_ripe,
     sample_sig, sample_sig_sha1
@@ -66,6 +67,12 @@ class TestCrypto(RIPEMD160TestCase, unittest.TestCase):
 class TestHighlevelcrypto(unittest.TestCase):
     """Test highlevelcrypto public functions"""
 
+    def test_double_sha512(self):
+        """Reproduce the example on page 1 of the Specification"""
+        self.assertEqual(
+            highlevelcrypto.double_sha512(sample_hash_data),
+            sample_double_sha512)
+
     def test_randomBytes(self):
         """Dummy checks for random bytes"""
         for n in (8, 32, 64):