mirror of https://github.com/nucypher/nucypher.git
Fixing test race condition.
parent
b1aef7fdb3
commit
6ee0c606f5
|
@ -38,8 +38,7 @@ def test_get_cert_from_running_seed_node(ursula_federated_test_config):
|
||||||
node_deployer.catalogServers(node_deployer.hendrix)
|
node_deployer.catalogServers(node_deployer.hendrix)
|
||||||
node_deployer.start()
|
node_deployer.start()
|
||||||
|
|
||||||
cert = node_deployer.cert.to_cryptography()
|
certificate_as_deployed = node_deployer.cert.to_cryptography()
|
||||||
cert_bytes = cert.public_bytes(serialization.Encoding.PEM)
|
|
||||||
|
|
||||||
firstula_as_seed_node = firstula.seed_node_metadata()
|
firstula_as_seed_node = firstula.seed_node_metadata()
|
||||||
any_other_ursula = lonely_ursula_maker(seed_nodes=[firstula_as_seed_node],
|
any_other_ursula = lonely_ursula_maker(seed_nodes=[firstula_as_seed_node],
|
||||||
|
@ -56,3 +55,6 @@ def test_get_cert_from_running_seed_node(ursula_federated_test_config):
|
||||||
|
|
||||||
yield deferToThread(start_lonely_learning_loop)
|
yield deferToThread(start_lonely_learning_loop)
|
||||||
assert firstula in any_other_ursula.known_nodes.values()
|
assert firstula in any_other_ursula.known_nodes.values()
|
||||||
|
|
||||||
|
certificate_as_learned = list(any_other_ursula.known_nodes.values())[0].certificate
|
||||||
|
assert certificate_as_learned == certificate_as_deployed
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
|
import maya
|
||||||
|
import pytest
|
||||||
|
import pytest_twisted
|
||||||
|
from twisted.internet.threads import deferToThread
|
||||||
|
|
||||||
from nucypher.utilities.sandbox.ursula import make_federated_ursulas
|
from nucypher.utilities.sandbox.ursula import make_federated_ursulas
|
||||||
|
|
||||||
|
|
||||||
|
@pytest_twisted.inlineCallbacks
|
||||||
def test_one_node_stores_a_bunch_of_others(federated_ursulas, ursula_federated_test_config):
|
def test_one_node_stores_a_bunch_of_others(federated_ursulas, ursula_federated_test_config):
|
||||||
the_chosen_seednode = list(federated_ursulas)[2]
|
the_chosen_seednode = list(federated_ursulas)[2]
|
||||||
seed_node = the_chosen_seednode.seed_node_metadata()
|
seed_node = the_chosen_seednode.seed_node_metadata()
|
||||||
|
@ -12,10 +18,17 @@ def test_one_node_stores_a_bunch_of_others(federated_ursulas, ursula_federated_t
|
||||||
seed_nodes=[seed_node]).pop()
|
seed_nodes=[seed_node]).pop()
|
||||||
|
|
||||||
assert not newcomer.known_nodes
|
assert not newcomer.known_nodes
|
||||||
newcomer.start_learning_loop()
|
|
||||||
|
def start_lonely_learning_loop():
|
||||||
|
newcomer.start_learning_loop()
|
||||||
|
start = maya.now()
|
||||||
|
# Loop until the_chosen_seednode is in storage.
|
||||||
|
while not the_chosen_seednode in newcomer.node_storage.all(federated_only=True):
|
||||||
|
passed = maya.now() - start
|
||||||
|
if passed.seconds > 2:
|
||||||
|
pytest.fail("Didn't find the seed node.")
|
||||||
|
|
||||||
|
yield deferToThread(start_lonely_learning_loop)
|
||||||
|
|
||||||
# The known_nodes are all saved in storage (and no others have been saved)
|
# The known_nodes are all saved in storage (and no others have been saved)
|
||||||
assert list(newcomer.known_nodes.values()) == list(newcomer.node_storage.all(True))
|
assert list(newcomer.known_nodes.values()) == list(newcomer.node_storage.all(True))
|
||||||
|
|
||||||
# ...and the_chosen_seednode is in there.
|
|
||||||
assert the_chosen_seednode in newcomer.node_storage.all(federated_only=True)
|
|
||||||
|
|
Loading…
Reference in New Issue