2019-06-28 02:43:50 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-03-04 06:59:29 +00:00
|
|
|
import unittest, sys, uuid, os
|
|
|
|
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
|
|
|
print("Test directory:", TEST_DIR)
|
|
|
|
os.environ["ONIONR_HOME"] = TEST_DIR
|
2019-06-28 02:43:50 +00:00
|
|
|
sys.path.append(".")
|
2019-11-21 09:26:23 +00:00
|
|
|
sys.path.append("src/")
|
2020-11-22 00:43:59 +00:00
|
|
|
from utils import createdirs
|
|
|
|
createdirs.create_dirs()
|
2019-06-28 02:43:50 +00:00
|
|
|
from utils import reconstructhash
|
|
|
|
|
|
|
|
class ZFill_Hash(unittest.TestCase):
|
|
|
|
def test_reconstruct(self):
|
|
|
|
h = b"4d20d791cbc293999b97cc627aa011692d317dede3d0fbd390c763210b0d"
|
|
|
|
self.assertEqual(reconstructhash.reconstruct_hash(h), b"0000" + h)
|
|
|
|
h = b"4d20d791cbc293999b97cc627aa011692d317dede3d0fbd390c763210b0d"
|
|
|
|
self.assertEqual(reconstructhash.reconstruct_hash(h, 62), b"00" + h)
|
2020-03-04 06:59:29 +00:00
|
|
|
|
2019-06-28 02:43:50 +00:00
|
|
|
def test_deconstruct(self):
|
|
|
|
h = b"0000e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87"
|
|
|
|
h_no = b"e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87"
|
|
|
|
self.assertEqual(reconstructhash.deconstruct_hash(h), h_no)
|
|
|
|
h = "0000e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87"
|
|
|
|
h_no = "e918d24999ad9b0ff00c1d414f36b74afc93871a0ece4bd452f82b56af87"
|
|
|
|
self.assertEqual(reconstructhash.deconstruct_hash(h), h_no)
|
2019-09-13 02:22:25 +00:00
|
|
|
unittest.main()
|