py-libp2p/tests/peer/test_peerid.py

135 lines
3.3 KiB
Python
Raw Normal View History

Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
import random
import multihash
import pytest
import base58
from Crypto.PublicKey import RSA
2019-08-01 06:00:12 +08:00
from libp2p.peer.id import (
ID,
id_b58_encode,
id_b58_decode,
id_from_public_key,
id_from_private_key,
)
2019-01-10 02:38:56 +08:00
2019-08-01 06:00:12 +08:00
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_init_():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
peer_id = ID(random_id_string)
2019-08-01 06:00:12 +08:00
# pylint: disable=protected-access
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
assert peer_id._id_str == random_id_string
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_no_init_value():
with pytest.raises(Exception) as _:
2019-08-01 06:00:12 +08:00
# pylint: disable=no-value-for-parameter
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
ID()
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_pretty():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
peer_id = ID(random_id_string)
actual = peer_id.pretty()
expected = base58.b58encode(random_id_string).decode()
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_str_less_than_10():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(5):
random_id_string += random.SystemRandom().choice(ALPHABETS)
pid = base58.b58encode(random_id_string).decode()
2019-05-22 10:25:08 +08:00
expected = pid
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
actual = ID(random_id_string).__str__()
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_str_more_than_10():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
pid = base58.b58encode(random_id_string).decode()
2019-05-22 10:25:08 +08:00
expected = pid
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
actual = ID(random_id_string).__str__()
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_eq_true():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
other = ID(random_id_string)
expected = True
actual = ID(random_id_string).__eq__(other)
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_eq_false():
other = ID("efgh")
expected = False
actual = ID("abcd").__eq__(other)
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_hash():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
expected = hash(random_id_string)
actual = ID(random_id_string).__hash__()
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_id_b58_encode():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
expected = base58.b58encode(random_id_string).decode()
actual = id_b58_encode(ID(random_id_string))
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_id_b58_decode():
2019-08-01 06:00:12 +08:00
random_id_string = ""
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
for _ in range(10):
random_id_string += random.SystemRandom().choice(ALPHABETS)
expected = ID(base58.b58decode(random_id_string))
actual = id_b58_decode(random_id_string)
assert actual == expected
2019-08-01 06:00:12 +08:00
Update unit tests from peer package (#103) * Update more test for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more tests for peerid.py Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update more unit tests Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * FIx travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix travis failaure Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Update indent-string to tab Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Convert indent back to space Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Disable W0212 and E1120 Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix lines that too long Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Fix failure from travis Signed-off-by: Tran Ly Vu <tranly.vu@accellion.com> * Remove W0212 and E1120 Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Fix packages import Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com> * Add pylint dsiable Signed-off-by: Tran Ly Vu <vutransingapore@gmail.com>
2019-01-13 00:31:08 +08:00
def test_id_from_public_key():
bits_list = [1024, 1280, 1536, 1536, 2048]
key = RSA.generate(random.choice(bits_list))
key_bin = key.exportKey("DER")
algo = multihash.Func.sha2_256
mh_digest = multihash.digest(key_bin, algo)
expected = ID(mh_digest.encode())
actual = id_from_public_key(key)
assert actual == expected
2019-08-01 06:00:12 +08:00
def test_id_from_private_key():
key = RSA.generate(2048, e=65537)
id_from_pub = id_from_public_key(key.publickey())
id_from_priv = id_from_private_key(key)
assert id_from_pub == id_from_priv