Apply PR feedback and fix
This commit is contained in:
parent
fab27b0357
commit
94c7a0bca4
|
@ -16,6 +16,8 @@ class PeerData(IPeerData):
|
|||
addrs: List[Multiaddr]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.pubkey = None
|
||||
self.privkey = None
|
||||
self.metadata = {}
|
||||
self.protocols = []
|
||||
self.addrs = []
|
||||
|
|
|
@ -328,18 +328,19 @@ async def test_host_connect():
|
|||
transport_opt_list = [["/ip4/127.0.0.1/tcp/0"], ["/ip4/127.0.0.1/tcp/0"]]
|
||||
(node_a, node_b) = await set_up_nodes_by_transport_opt(transport_opt_list)
|
||||
|
||||
assert not node_a.get_peerstore().peer_ids()
|
||||
# Only our peer ID is stored in peer store
|
||||
assert len(node_a.get_peerstore().peer_ids()) == 1
|
||||
|
||||
addr = node_b.get_addrs()[0]
|
||||
info = info_from_p2p_addr(addr)
|
||||
await node_a.connect(info)
|
||||
|
||||
assert len(node_a.get_peerstore().peer_ids()) == 1
|
||||
assert len(node_a.get_peerstore().peer_ids()) == 2
|
||||
|
||||
await node_a.connect(info)
|
||||
|
||||
# make sure we don't do double connection
|
||||
assert len(node_a.get_peerstore().peer_ids()) == 1
|
||||
assert len(node_a.get_peerstore().peer_ids()) == 2
|
||||
|
||||
assert node_b.get_id() in node_a.get_peerstore().peer_ids()
|
||||
ma_node_b = multiaddr.Multiaddr("/p2p/%s" % node_b.get_id().pretty())
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from libp2p.peer.peerstore import PeerStore
|
||||
import pytest
|
||||
|
||||
from libp2p.peer.peerstore import PeerStore, PeerStoreError
|
||||
|
||||
# Testing methods from IPeerStore base class.
|
||||
|
||||
|
||||
def test_peer_info_empty():
|
||||
store = PeerStore()
|
||||
info = store.peer_info("peer")
|
||||
|
||||
assert not info
|
||||
with pytest.raises(PeerStoreError):
|
||||
store.peer_info("peer")
|
||||
|
||||
|
||||
def test_peer_info_basic():
|
||||
|
|
Loading…
Reference in New Issue
Block a user