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_get_protocols_basic(): store = PeerStore() store.add_protocols("peer1", ["p1", "p2"]) store.add_protocols("peer2", ["p3"]) assert set(store.get_protocols("peer1")) == set(["p1", "p2"]) assert set(store.get_protocols("peer2")) == set(["p3"])
def test_set_protocols(): store = PeerStore() store.add_protocols("peer1", ["p1", "p2"]) store.add_protocols("peer2", ["p3"]) store.set_protocols("peer1", ["p4"]) store.set_protocols("peer2", []) assert set(store.get_protocols("peer1")) == set(["p4"]) assert set(store.get_protocols("peer2")) == set([])