From 702af198f269bc475e477f818358b58055ad5191 Mon Sep 17 00:00:00 2001 From: Stuckinaboot Date: Wed, 8 May 2019 20:19:02 -0400 Subject: [PATCH 1/3] Remove truncating peerid when converting to string --- libp2p/peer/id.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libp2p/peer/id.py b/libp2p/peer/id.py index 47d7cf5..a46c462 100644 --- a/libp2p/peer/id.py +++ b/libp2p/peer/id.py @@ -27,9 +27,7 @@ class ID: def __str__(self): pid = self.pretty() - if len(pid) <= 10: - return "" % pid - return "" % (pid[:2], pid[len(pid)-6:]) + return "" % pid __repr__ = __str__ From 1250182e7ceadab9700778ebd8954a78e78e8e1b Mon Sep 17 00:00:00 2001 From: Stuckinaboot Date: Wed, 8 May 2019 20:19:13 -0400 Subject: [PATCH 2/3] Update peerid tests for longer peerids --- tests/peer/test_peerid.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/peer/test_peerid.py b/tests/peer/test_peerid.py index f7c82cb..e481a40 100644 --- a/tests/peer/test_peerid.py +++ b/tests/peer/test_peerid.py @@ -46,9 +46,7 @@ def test_str_more_than_10(): for _ in range(10): random_id_string += random.SystemRandom().choice(ALPHABETS) pid = base58.b58encode(random_id_string).decode() - part_1, part_2 = pid[:2], pid[len(pid)-6:] - - expected = "" + expected = "" actual = ID(random_id_string).__str__() assert actual == expected From f9721a2ade224eed45b0d759cdf9969b41db6d3d Mon Sep 17 00:00:00 2001 From: Stuckinaboot Date: Tue, 21 May 2019 22:25:08 -0400 Subject: [PATCH 3/3] Modify peer_id str --- libp2p/peer/id.py | 2 +- tests/peer/test_peerid.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libp2p/peer/id.py b/libp2p/peer/id.py index a46c462..3097e1f 100644 --- a/libp2p/peer/id.py +++ b/libp2p/peer/id.py @@ -27,7 +27,7 @@ class ID: def __str__(self): pid = self.pretty() - return "" % pid + return pid __repr__ = __str__ diff --git a/tests/peer/test_peerid.py b/tests/peer/test_peerid.py index e481a40..d1cf718 100644 --- a/tests/peer/test_peerid.py +++ b/tests/peer/test_peerid.py @@ -36,7 +36,7 @@ def test_str_less_than_10(): for _ in range(5): random_id_string += random.SystemRandom().choice(ALPHABETS) pid = base58.b58encode(random_id_string).decode() - expected = "" + expected = pid actual = ID(random_id_string).__str__() assert actual == expected @@ -46,7 +46,7 @@ def test_str_more_than_10(): for _ in range(10): random_id_string += random.SystemRandom().choice(ALPHABETS) pid = base58.b58encode(random_id_string).decode() - expected = "" + expected = pid actual = ID(random_id_string).__str__() assert actual == expected