Esempio n. 1
0
def bob(alice, ursulas):
    BOB = Bob(alice=alice)
    BOB.attach_server()
    BOB.server.listen(8475)
    EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)]))
    congregate(alice, BOB, *ursulas)
    return BOB
Esempio n. 2
0
def bob(alice, ursulas):
    BOB = Bob()
    BOB.server.listen(8475)
    EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)]))
    return BOB
Esempio n. 3
0
# This is an example of Alice setting a Policy on the NuCypher network.
# In this example, Alice uses n=1, which is almost always a bad idea.  Don't do it.

# WIP w/ hendrix@8227c4abcb37ee6d27528a13ec22d55ee106107f

import datetime

import requests

from nkms.characters import Alice, Bob, Ursula
from nkms.network.node import NetworkyStuff

ALICE = Alice()
BOB = Bob()
URSULA = Ursula.from_rest_url("http://localhost:3500/public_keys")

ALICE.learn_about_actor(URSULA)


class SandboxNetworkyStuff(NetworkyStuff):
    def find_ursula(self, contract=None):
        ursula = Ursula.as_discovered_on_network(dhr_port=None,
                                                 dht_interface=None,
                                                 pubkey_sig_bytes=bytes(
                                                     URSULA.stamp),
                                                 rest_address="localhost",
                                                 rest_port=3500)
        response = requests.post("http://localhost:3500/consider_contract",
                                 bytes(contract))
        response.was_accepted = True
        return ursula, response
Esempio n. 4
0
def bob(ursulas):
    BOB = Bob(network_middleware=MockNetworkyStuff(ursulas))
    return BOB
Esempio n. 5
0
    for _counter, ursula in enumerate(URSULAS):
        EVENT_LOOP.run_until_complete(ursula.server.bootstrap([("127.0.0.1", URSULA_PORT)]))
        EVENT_LOOP.run_until_complete(ursula.server.bootstrap([("127.0.0.1", URSULA_PORT + _counter)]))
        ursula.publish_interface_information()

    return URSULAS

URSULAS = make_fake_ursulas(6)

ALICE = Alice()
ALICE.attach_server()
ALICE.server.listen(8471)
EVENT_LOOP.run_until_complete(ALICE.server.bootstrap([("127.0.0.1", URSULA_PORT)]))

BOB = Bob(alice=ALICE)
BOB.attach_server()
BOB.server.listen(8475)
EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)]))


community_meeting(ALICE, BOB, URSULAS[0])


def test_alice_finds_ursula():
    ursula_index = 1
    all_ursulas = list_all_ursulas()
    getter = ALICE.server.get(all_ursulas[ursula_index])
    loop = asyncio.get_event_loop()
    interface_bytes = loop.run_until_complete(getter)
    port, interface = msgpack.loads(interface_bytes)