Merge pull request #102 from jMyles/policy

Ursula now saves interface info in her own DHT instance.
pull/106/head
Justin Holmes 2017-11-06 18:10:39 -08:00 committed by GitHub
commit 2155f09fae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View File

@ -53,14 +53,10 @@ class NuCypherDHTServer(Server):
self.storage[dkey] = value
ds = []
for n in nodes:
if self.node.id == n.id:
# TOOD: Consider whether to store stuff locally. We don't really know yet. Probably at least some things.
ds.append(False)
else:
disposition, value_was_set = await self.protocol.callStore(n, dkey, value)
if value_was_set:
self.digests_set += 1
ds.append(value_was_set)
_disposition, value_was_set = await self.protocol.callStore(n, dkey, value)
if value_was_set:
self.digests_set += 1
ds.append(value_was_set)
# return true only if at least one store call succeeded
return any(ds)

View File

@ -28,8 +28,7 @@ def make_fake_ursulas(how_many):
URSULAS.append(_URSULA)
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)]))
EVENT_LOOP.run_until_complete(ursula.server.bootstrap([("127.0.0.1", URSULA_PORT + _c) for _c in range(how_many)]))
ursula.publish_interface_information()
return URSULAS
@ -50,6 +49,16 @@ EVENT_LOOP.run_until_complete(BOB.server.bootstrap([("127.0.0.1", URSULA_PORT)])
community_meeting(ALICE, BOB, URSULAS[0])
def test_all_ursulas_know_about_all_other_ursulas():
ignorance = []
for acounter, announcing_ursula in enumerate(list_all_ursulas()):
for counter, propagating_ursula in enumerate(URSULAS):
if not digest(announcing_ursula) in propagating_ursula.server.storage:
ignorance.append((counter, acounter))
if ignorance:
pytest.fail(str(["{} didn't know about {}".format(counter, acounter) for counter, acounter in ignorance]))
def test_alice_finds_ursula():
ursula_index = 1
all_ursulas = list_all_ursulas()
@ -61,7 +70,7 @@ def test_alice_finds_ursula():
assert port == URSULA_PORT + ursula_index
def test_ursula_with_bad_interface_key_does_not_propagate():
def test_vladimir_illegal_interface_key_does_not_propagate():
vladimir = URSULAS[0]
ursula = URSULAS[1]