示例#1
0
def test_add_addrs_multiple():
    store = PeerStore()
    store.add_addrs("peer1", ["/foo1", "/bar1"], 10)
    store.add_addrs("peer2", ["/foo2"], 10)

    assert store.addrs("peer1") == ["/foo1", "/bar1"]
    assert store.addrs("peer2") == ["/foo2"]
示例#2
0
def test_peers_with_addrs():
    store = PeerStore()
    store.add_addrs("peer1", [], 10)
    store.add_addrs("peer2", ["/foo"], 10)
    store.add_addrs("peer3", ["/bar"], 10)

    assert set(store.peers_with_addrs()) == set(["peer2", "peer3"])

    store.clear_addrs("peer2")

    assert set(store.peers_with_addrs()) == set(["peer3"])
示例#3
0
def test_clear_addrs():
    store = PeerStore()
    store.add_addrs("peer1", ["/foo1", "/bar1"], 10)
    store.add_addrs("peer2", ["/foo2"], 10)
    store.clear_addrs("peer1")

    assert store.addrs("peer1") == []
    assert store.addrs("peer2") == ["/foo2"]

    store.add_addrs("peer1", ["/foo1", "/bar1"], 10)

    assert store.addrs("peer1") == ["/foo1", "/bar1"]