Beispiel #1
0
def test_on_survey(node_with_callbacks, request):
    nA, results = node_with_callbacks
    nA.run()

    nB = PyreNode('testB')
    request.addfinalizer(nB.shutdown)

    nB.run()
    wait_cb(results, 'on_new_peer')

    nB.send_survey({'req_id': 'this is a test'}, 0.1, 1)

    wait_cb(results, 'on_survey')

    peer_id, peer_name, request = results.on_survey_results
    assert peer_id == nB.uuid()
    assert peer_name == b'testB'
    assert request == {'req_id': 'this is a test'}
Beispiel #2
0
def test_on_survey(node_with_callbacks):
    nA, results = node_with_callbacks
    nA.run()

    nB = PyreNode('testB')
    try:
        nB.run()
        wait_cb(results, 'on_new_peer')

        nB.send_survey({'req_id': 'this is a test'}, 0.1, 1)

        wait_cb(results, 'on_survey')

        peer_id, peer_name, request = results.on_survey_results
        assert peer_id == nB.uuid()
        assert peer_name == 'testB'
        assert request == {'req_id': 'this is a test'}
    finally:
        nB.shutdown()
Beispiel #3
0
def test_survey_process(node_with_callbacks):
    nA, results = node_with_callbacks
    nA.run()

    nB = PyreNode('testB')
    try:
        nB.run()
        wait_cb(results, 'on_new_peer')

        # Test it can cope with wrong req_id
        nA.reply_survey(nB.uuid(), {'req_id': 'wrong!', 'data': ''})

        def _reply():
            wait_cb(results, 'on_survey')
            peer_id, peer_name, request = results.on_survey_results
            nA.reply_survey(peer_id, {'req_id': 'this is a test', 'data': 'OK!'})
        green.spawn(_reply)

        assert nB.send_survey({'req_id': 'this is a test'}, 1, 1) == [('testA', 'OK!')]
    finally:
        nB.shutdown()
Beispiel #4
0
def test_survey_process(node_with_callbacks, request):
    nA, results = node_with_callbacks
    nA.run()

    nB = PyreNode('testB')
    request.addfinalizer(nB.shutdown)

    nB.run()
    wait_cb(results, 'on_new_peer')

    # Test it can cope with wrong req_id
    nA.reply_survey(nB.uuid(), {'req_id': 'wrong!', 'data': ''})

    def _reply():
        wait_cb(results, 'on_survey')
        peer_id, peer_name, request = results.on_survey_results
        nA.reply_survey(peer_id, {'req_id': 'this is a test', 'data': 'OK!'})

    green.spawn(_reply)

    assert nB.send_survey({'req_id': 'this is a test'}, 1,
                          1) == [(b'testA', 'OK!')]