Add a basic test for the SHA-256 Transaction store.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
9eafc61bda
commit
e509dacc9a
1 changed files with 19 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from newfol.filemanip import Record, FileStorage
|
||||
from newfol.filemanip import Record, FileStorage, SHA256TransactionStore
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
|
@ -53,5 +53,23 @@ class TestRoundTripping(unittest.TestCase):
|
|||
def test_pickle(self):
|
||||
self.run_test("pickle")
|
||||
|
||||
class SHA256TransactionTest(unittest.TestCase):
|
||||
def test_hashing(self):
|
||||
testcases = {
|
||||
"": "0:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"abc": "3:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
|
||||
"©": "2:0a79b0ca699d37228d3affd3b6d38b7f2731702f12fd1edd6cb9ac42a686e3a3",
|
||||
"\ufeff": "3:f1945cd6c19e56b3c1c78943ef5ec18116907a4ca1efc40a57d48ab1db7adfc5",
|
||||
}
|
||||
tempdir = tempfile.TemporaryDirectory()
|
||||
temp = tempdir.name + "/test"
|
||||
for k, v in testcases.items():
|
||||
wfp = open(temp, "w")
|
||||
wfp.write(k)
|
||||
wfp.close()
|
||||
self.assertEqual(SHA256TransactionStore._hash_file(temp),
|
||||
"sha256:" + v)
|
||||
tempdir = None
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue