예제 #1
0
def test_register_for_task_first_node_registration(redisdb):
    node = CommitteeCandidate()
    node.conn = redisdb

    registration_channel = 'test_registration'

    node._task_registration_channel = registration_channel
    node.register_for_task()
    assert node.get_number_of_registered_nodes() == 1
예제 #2
0
def test_register_for_task_multiple_nodes(redisdb):
    registration_channel = 'test_registration'

    node_1 = CommitteeCandidate()
    node_1.conn = redisdb

    node_1._task_registration_channel = registration_channel
    node_1.register_for_task()

    node_2 = CommitteeCandidate()
    node_2.conn = redisdb

    node_2._task_registration_channel = registration_channel
    node_2.register_for_task()

    assert node_1.get_number_of_registered_nodes() == 2
예제 #3
0
def test_committee_gets_disolved_before_completing_training(redisdb):
    registration_channel = 'test_registration'

    node_1 = CommitteeCandidate()
    node_1.conn = redisdb

    node_1._task_registration_channel = registration_channel
    node_1.register_for_task()

    node_2 = CommitteeCandidate()
    node_2.conn = redisdb

    node_2._task_registration_channel = registration_channel
    node_2.register_for_task()

    assert node_1.get_number_of_registered_nodes() == 2
    assert node_2.get_number_of_registered_nodes() == 2

    time.sleep(20)

    assert len(node_1.get_registered_nodes()) == 0