aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_crypto.py
diff options
context:
space:
mode:
authorHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 20:28:56 +0100
committerHartmut Goebel <h.goebel@crazy-compilers.com>2019-01-19 20:28:56 +0100
commit4309d80e3f8be6bfcf911cf75ea691694a0dbb15 (patch)
treeac75b9b3ee615ea200b42fc107360f0931a099f6 /tests/unit/test_crypto.py
parentbda184f81ea7865067b4bcd73cef42251bff0217 (diff)
downloadgnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.tar.gz
gnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.zip
Add a small test-suite.
Diffstat (limited to 'tests/unit/test_crypto.py')
-rw-r--r--tests/unit/test_crypto.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit/test_crypto.py b/tests/unit/test_crypto.py
new file mode 100644
index 0000000..ab3db79
--- /dev/null
+++ b/tests/unit/test_crypto.py
@@ -0,0 +1,31 @@
1import pytest
2
3from gnunet.crypto import EcdsaPublicKey
4
5def test___repr__():
6 k = EcdsaPublicKey(b"abcd"*(256//8//4))
7 assert repr(k).startswith('gnunet.crypto.EcdsaPublicKey(')
8
9def test___init__string():
10 s = "C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI0"
11 k = EcdsaPublicKey(s)
12
13def test___init__bytes():
14 k = EcdsaPublicKey(b"abcd"*(256//8//4))
15
16def test___init_EcdsaPublicKey():
17 k1 = EcdsaPublicKey(b"abcd"*(256//8//4))
18 k2 = EcdsaPublicKey(k1)
19 assert k1._data == k2._data
20
21def test___init__string_wrong_size():
22 with pytest.raises(ValueError):
23 k = EcdsaPublicKey("abcd")
24 with pytest.raises(ValueError):
25 k = EcdsaPublicKey("abcd"*256)
26
27def test___init__bytes_wrong_size():
28 with pytest.raises(ValueError):
29 k = EcdsaPublicKey(b"abcd")
30 with pytest.raises(ValueError):
31 k = EcdsaPublicKey(b"abcd"*256)