diff options
author | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 20:28:56 +0100 |
---|---|---|
committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2019-01-19 20:28:56 +0100 |
commit | 4309d80e3f8be6bfcf911cf75ea691694a0dbb15 (patch) | |
tree | ac75b9b3ee615ea200b42fc107360f0931a099f6 /tests/unit/test_crypto.py | |
parent | bda184f81ea7865067b4bcd73cef42251bff0217 (diff) | |
download | gnunet-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.py | 31 |
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 @@ | |||
1 | import pytest | ||
2 | |||
3 | from gnunet.crypto import EcdsaPublicKey | ||
4 | |||
5 | def test___repr__(): | ||
6 | k = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
7 | assert repr(k).startswith('gnunet.crypto.EcdsaPublicKey(') | ||
8 | |||
9 | def test___init__string(): | ||
10 | s = "C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI0" | ||
11 | k = EcdsaPublicKey(s) | ||
12 | |||
13 | def test___init__bytes(): | ||
14 | k = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
15 | |||
16 | def test___init_EcdsaPublicKey(): | ||
17 | k1 = EcdsaPublicKey(b"abcd"*(256//8//4)) | ||
18 | k2 = EcdsaPublicKey(k1) | ||
19 | assert k1._data == k2._data | ||
20 | |||
21 | def 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 | |||
27 | def 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) | ||