From dcd0f031fa26bded63d2c1e4508f70c6e8ec4a27 Mon Sep 17 00:00:00 2001 From: Alexey Stratulat <alexey.stratulat@demlabs.net> Date: Tue, 2 Jul 2019 18:28:49 +0700 Subject: [PATCH] [+] Made UnitTest which checks initialization, and library deinitialization, and also checks the operation of the base58 and base64 algorithm --- .gitmodules | 3 +++ test/libdap-python | 1 + test/test.py | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 160000 test/libdap-python create mode 100644 test/test.py diff --git a/.gitmodules b/.gitmodules index 2d451727..778e626b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "libdap"] path = libdap url = https://github.com/cellframe/libdap.git +[submodule "test/libdap-python"] + path = test/libdap-python + url = https://github.com/cellframe/libdap-python.git diff --git a/test/libdap-python b/test/libdap-python new file mode 160000 index 00000000..e8d7f4e8 --- /dev/null +++ b/test/libdap-python @@ -0,0 +1 @@ +Subproject commit e8d7f4e84f0cbca515236f317e9aa5d079df1962 diff --git a/test/test.py b/test/test.py new file mode 100644 index 00000000..0b2c73df --- /dev/null +++ b/test/test.py @@ -0,0 +1,21 @@ +import libdap_crypto_python_module as crypto +import unittest + +class TestLibdapCryptoPythonModule(unittest.TestCase): + def test_ini(self): + self.assertTrue(crypto.init() == 0, "Failed init libdap crypto python") + def test_deinit(self): + self.assertTrue(crypto.deinit() == 0, "Failed deinit libdap crypto python") + def test_b58(self): + s = "REvgshguqwt76thuioh1`lwi0-8i-d0hjwpeocnpgh89efty7ug" + crypt = crypto.encode_base58(s) + decrypt = crypto.decode_base58(crypt) + self.assertTrue(s == decrypt, "Encoding and decoded information using the base58 algorithm does not match the original") + def test_b64(self): + s = "LindyfekrngFHJFGR23356fer" + crypt = crypto.encode_base64(s) + decrypt = crypto.decode_base64(crypt, len(s)) + self.assertTrue(s == decrypt, "Encoding and decoded information using the base64 algorithm does not match the original") + +if __name__ == '__main__': + unittest.main() -- GitLab