def test_peer_info_basic(): store = PeerStore() store.add_addr("peer", "/foo", 10) info = store.peer_info("peer") assert info.peer_id == "peer" assert info.addrs == ["/foo"]
def test_peers(): store = PeerStore() store.add_protocols("peer1", []) store.put("peer2", "key", "val") store.add_addr("peer3", "/foo", 10) assert set(store.peers()) == set(["peer1", "peer2", "peer3"])
def test_add_addr_single(): store = PeerStore() store.add_addr("peer1", "/foo", 10) store.add_addr("peer1", "/bar", 10) store.add_addr("peer2", "/baz", 10) assert store.addrs("peer1") == ["/foo", "/bar"] assert store.addrs("peer2") == ["/baz"]