test_ripemd: add simple test case for ripemd module

This commit is contained in:
Roman Zeyde 2015-08-15 09:52:27 +03:00
parent fa412c3a86
commit ac8e792c58
1 changed files with 16 additions and 0 deletions

16
lib/tests/test_ripemd.py Normal file
View File

@ -0,0 +1,16 @@
import unittest
import random
import hashlib
from lib import ripemd
class Test_RIPEMD160(unittest.TestCase):
""" Test pure Python implementation against standard library. """
def test_ripemd(self):
r = random.Random(0)
for i in range(128):
blob = bytearray([r.randrange(0, 256) for j in range(1024)])
h = hashlib.new('ripemd160')
h.update(blob)
self.assertEqual(h.hexdigest(), ripemd.new(blob).hexdigest())