aboutsummaryrefslogtreecommitdiff
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
parentbda184f81ea7865067b4bcd73cef42251bff0217 (diff)
downloadgnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.tar.gz
gnunet-python-4309d80e3f8be6bfcf911cf75ea691694a0dbb15.zip
Add a small test-suite.
-rw-r--r--tests/unit/test_crypto.py31
-rw-r--r--tests/unit/test_hashcode.py32
2 files changed, 63 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)
diff --git a/tests/unit/test_hashcode.py b/tests/unit/test_hashcode.py
new file mode 100644
index 0000000..d40cdd9
--- /dev/null
+++ b/tests/unit/test_hashcode.py
@@ -0,0 +1,32 @@
1import pytest
2
3from gnunet import HashCode
4
5def test___repr__():
6 k = HashCode(b"abcd"*(512//8//4))
7 assert repr(k).startswith('gnunet.HashCode(')
8
9def test___init__string():
10 s = ("C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P31C9HM8OB2CDI6"
11 "2OJ3CHGM4OR4C5H66P31C9HM8OB2CDI62OJ3CHGM4OR4C5H66P0")
12 k = HashCode(s)
13
14def test___init__bytes():
15 k = HashCode(b"abcd"*(512//8//4))
16
17def test___init_HashCode():
18 k1 = HashCode(b"abcd"*(512//8//4))
19 k2 = HashCode(k1)
20 assert k1._data == k2._data
21
22def test___init__string_wrong_size():
23 with pytest.raises(ValueError):
24 k = HashCode("abcd")
25 with pytest.raises(ValueError):
26 k = HashCode("abcd"*512)
27
28def test___init__bytes_wrong_size():
29 with pytest.raises(ValueError):
30 k = HashCode(b"abcd")
31 with pytest.raises(ValueError):
32 k = HashCode(b"abcd"*512)