Beispiel #1
0
 def create_peer(self, peer_name: str, peer_address: PeerAddress,
                 default_peer_port):
     squeak_peer = create_saved_peer(
         peer_name,
         peer_address,
         default_peer_port,
     )
     return self.squeak_db.insert_peer(squeak_peer)
Beispiel #2
0
def test_create_saved_peer_use_tor(peer_name, peer_address_with_tor):
    peer = create_saved_peer(
        peer_name,
        peer_address_with_tor,
    )

    assert peer.peer_name == peer_name
    assert peer.address == peer_address_with_tor
Beispiel #3
0
def test_create_saved_peer(peer_name, peer_address):
    peer = create_saved_peer(
        peer_name,
        peer_address,
    )

    assert peer.peer_name == peer_name
    assert peer.address == peer_address
Beispiel #4
0
def test_create_saved_peer_no_port(peer_name, peer_address_with_no_port, default_peer_port):
    peer = create_saved_peer(
        peer_name,
        peer_address_with_no_port,
        default_peer_port,
    )

    assert peer.peer_name == peer_name
    assert peer.address.port == default_peer_port
Beispiel #5
0
def test_create_saved_peer(peer_name, peer_address, default_peer_port):
    peer = create_saved_peer(
        peer_name,
        peer_address,
        default_peer_port,
    )

    assert peer.peer_name == peer_name
    assert peer.address == peer_address
Beispiel #6
0
def gen_squeak_peer(peer_name):
    host = "random_host_{}".format(uuid.uuid1())
    port = random.randint(1, 10000)
    peer_address = PeerAddress(
        network=Network.IPV4,
        host=host,
        port=port,
    )
    return create_saved_peer(
        peer_name,
        peer_address,
    )
Beispiel #7
0
def test_create_saved_peer_empty_name(peer_address, default_peer_port):
    create_saved_peer("", peer_address, default_peer_port)
Beispiel #8
0
def test_create_saved_peer_empty_name(peer_address):
    with pytest.raises(Exception) as excinfo:
        create_saved_peer("", peer_address)
    assert "Peer name cannot be empty." in str(excinfo.value)