py-libp2p/tests/peer/test_peerid.py

107 lines
2.7 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
2019-08-03 13:36:19 +08:00
import base58
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 multihash
2019-01-10 02:38:56 +08:00
2019-08-14 09:19:14 +08:00
from libp2p.crypto.rsa import create_new_key_pair
import libp2p.peer.id as PeerID
2019-08-03 13:36:19 +08:00
from libp2p.peer.id import ID
2019-08-01 06:00:12 +08:00
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
# ensure we are not in "debug" mode for the following tests
PeerID.FRIENDLY_IDS = False
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
2019-08-14 09:19:14 +08:00
def test_eq_impl_for_bytes():
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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-07-31 19:26:13 +08:00
peer_id = ID(random_id_string.encode())
assert peer_id == random_id_string.encode()
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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-07-31 19:26:13 +08:00
peer_id = ID(random_id_string.encode())
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 = peer_id.pretty()
2019-08-02 16:48:38 +08:00
expected = base58.b58encode(random_id_string).decode()
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 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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-08-02 16:48:38 +08:00
peer_id = base58.b58encode(random_id_string).decode()
2019-07-31 19:26:13 +08:00
expected = peer_id
actual = ID(random_id_string.encode()).__str__()
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 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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-08-02 16:48:38 +08:00
peer_id = base58.b58encode(random_id_string).decode()
2019-07-31 19:26:13 +08:00
expected = peer_id
actual = ID(random_id_string.encode()).__str__()
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 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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-07-31 19:26:13 +08:00
peer_id = ID(random_id_string.encode())
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
2019-08-02 16:48:38 +08:00
assert peer_id == base58.b58encode(random_id_string).decode()
assert peer_id == random_id_string.encode()
2019-07-31 19:26:13 +08:00
assert peer_id == ID(random_id_string.encode())
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
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():
2019-07-31 19:26:13 +08:00
peer_id = ID("efgh")
other = ID("abcd")
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
2019-07-31 19:26:13 +08:00
assert peer_id != other
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
2019-08-01 06:00:12 +08:00
2019-08-02 16:48:38 +08:00
def test_id_to_base58():
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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-08-02 16:48:38 +08:00
expected = base58.b58encode(random_id_string).decode()
actual = ID(random_id_string.encode()).to_base58()
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 actual == expected
2019-08-01 06:00:12 +08:00
2019-08-02 16:48:38 +08:00
def test_id_from_base58():
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):
2019-08-14 09:19:14 +08:00
random_id_string += random.choice(ALPHABETS)
2019-08-02 16:48:38 +08:00
expected = ID(base58.b58decode(random_id_string))
actual = ID.from_base58(random_id_string.encode())
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 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():
key_pair = create_new_key_pair()
public_key = key_pair.public_key
2019-08-14 09:19:14 +08:00
key_bin = public_key.serialize()
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
algo = multihash.Func.sha2_256
mh_digest = multihash.digest(key_bin, algo)
expected = ID(mh_digest.encode())
2019-08-14 09:19:14 +08:00
actual = ID.from_pubkey(public_key)
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 actual == expected