nucypher/tests/network/test_node_storage.py

39 lines
1.4 KiB
Python
Raw Normal View History

"""
This file is part of nucypher.
nucypher is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
nucypher is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from nucypher.utilities.sandbox.ursula import make_federated_ursulas
2018-07-02 12:18:31 +00:00
def test_one_node_stores_a_bunch_of_others(federated_ursulas, ursula_federated_test_config):
the_chosen_seednode = list(federated_ursulas)[2] # ...neo?
seed_node = the_chosen_seednode.seed_node_metadata()
newcomer = make_federated_ursulas(
ursula_config=ursula_federated_test_config,
quantity=1,
know_each_other=False,
save_metadata=True,
seed_nodes=[seed_node]).pop()
assert not newcomer.known_nodes
2018-10-27 21:26:33 +00:00
newcomer.start_learning_loop(now=True)
assert list(newcomer.known_nodes)
assert len(list(newcomer.known_nodes)) == len(list(newcomer.node_storage.all(True)))
assert set(list(newcomer.known_nodes)) == set(list(newcomer.node_storage.all(True)))