mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-22 21:30:56 +00:00
chore(core/tests): add smoke test for libtropic
This commit is contained in:
parent
76afabec8d
commit
b80527c558
37
core/tests/test_trezor.crypto.tropic.py
Normal file
37
core/tests/test_trezor.crypto.tropic.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from common import * # isort:skip
|
||||||
|
|
||||||
|
from slip39_vectors import vectors
|
||||||
|
from trezor.crypto import tropic
|
||||||
|
|
||||||
|
|
||||||
|
class TestCryptoTropic(unittest.TestCase):
|
||||||
|
def test_ping(self):
|
||||||
|
self.assertEqual(tropic.ping("HeLlO!"), "HeLlO!")
|
||||||
|
|
||||||
|
def test_get_certificate(self):
|
||||||
|
self.assertEqual(len(tropic.get_certificate()), 512)
|
||||||
|
|
||||||
|
def test_get_random(self):
|
||||||
|
self.assertEqual(len(tropic.random_get(10)), 10)
|
||||||
|
|
||||||
|
def test_sign(self):
|
||||||
|
try:
|
||||||
|
tropic.sign(0, "ASD")
|
||||||
|
assert False
|
||||||
|
except ValueError as e:
|
||||||
|
self.assertIn("invalid length", str(e).lower())
|
||||||
|
|
||||||
|
# signing needs to fail because we don't have a key!
|
||||||
|
try:
|
||||||
|
tropic.sign(0, "a" * 32)
|
||||||
|
assert False
|
||||||
|
except tropic.TropicError as e:
|
||||||
|
self.assertIn("sign failed", 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