mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-12 14:16:06 +00:00
feat(core/tests): add smoke test for libtropic
[no changelog]
This commit is contained in:
parent
bf3029cf8a
commit
984e4e214a
31
core/tests/test_trezor.crypto.tropic.py
Normal file
31
core/tests/test_trezor.crypto.tropic.py
Normal file
@ -0,0 +1,31 @@
|
||||
# flake8: noqa: F403,F405
|
||||
from common import * # isort:skip
|
||||
|
||||
if utils.USE_TROPIC:
|
||||
from trezor.crypto import tropic
|
||||
|
||||
|
||||
@unittest.skipUnless(utils.USE_TROPIC, "tropic")
|
||||
class TestCryptoTropic(unittest.TestCase):
|
||||
def test_ping(self):
|
||||
self.assertEqual(tropic.ping(""), "")
|
||||
self.assertEqual(tropic.ping("HeLlO!"), "HeLlO!")
|
||||
|
||||
def test_get_certificate(self):
|
||||
self.assertEqual(len(tropic.get_certificate()), 512)
|
||||
|
||||
def test_sign(self):
|
||||
try:
|
||||
tropic.sign(0, "ASD")
|
||||
assert False
|
||||
except ValueError as e:
|
||||
self.assertIn("invalid length", str(e).lower())
|
||||
|
||||
tropic.key_generate(0)
|
||||
|
||||
# signing should work now that we have a key
|
||||
self.assertEqual(len(tropic.sign(0, "a" * 32)), 64)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user