File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 3
3
)
4
4
from typing import (
5
5
Any ,
6
+ cast ,
6
7
)
7
8
8
9
import multiaddr
10
+ from multiaddr .protocols import Protocol
9
11
10
12
from .id import (
11
13
ID ,
@@ -42,7 +44,8 @@ def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
42
44
p2p_protocols = p2p_part .protocols ()
43
45
if not p2p_protocols :
44
46
raise InvalidAddrError ("The last part of the address has no protocols" )
45
- last_protocol = p2p_protocols [0 ]
47
+ last_protocol = cast (Protocol , p2p_part .protocols ()[0 ])
48
+
46
49
if last_protocol is None :
47
50
raise InvalidAddrError ("The last protocol is None" )
48
51
Original file line number Diff line number Diff line change
1
+ fixed malformed PeerId in test_peerinfo
Original file line number Diff line number Diff line change
1
+ fixed a typecheck error using cast in peerinfo.py
Original file line number Diff line number Diff line change 13
13
)
14
14
15
15
ALPHABETS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
16
- VALID_MULTI_ADDR_STR = "/ip4/127.0.0.1/tcp/8000/p2p/3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ" # noqa: E501
16
+ VALID_MULTI_ADDR_STR = (
17
+ "/ip4/127.0.0.1/tcp/8000/p2p/QmWQqHcMi6Cay5M6KWSNVYSDnxzfqWb1aGFQFSRzBNe49t"
18
+ )
17
19
18
20
19
21
def test_init_ ():
@@ -50,9 +52,6 @@ def test_info_from_p2p_addr_invalid(addr):
50
52
def test_info_from_p2p_addr_valid ():
51
53
m_addr = multiaddr .Multiaddr (VALID_MULTI_ADDR_STR )
52
54
info = info_from_p2p_addr (m_addr )
53
- assert (
54
- info .peer_id .pretty ()
55
- == "3YgLAeMKSAPcGqZkAt8mREqhQXmJT8SN8VCMN4T6ih4GNX9wvK8mWJnWZ1qA2mLdCQ"
56
- )
55
+ assert info .peer_id .pretty () == "QmWQqHcMi6Cay5M6KWSNVYSDnxzfqWb1aGFQFSRzBNe49t"
57
56
assert len (info .addrs ) == 1
58
57
assert str (info .addrs [0 ]) == "/ip4/127.0.0.1/tcp/8000"
You can’t perform that action at this time.
0 commit comments