'Test creation and handling of a new live edge.'

def test_live_edge_callback(self):

    (node, other) = self.create_nodes(2)
    cache = object.__new__(IntroductionRequestCache)
    blockingCallFromThread(reactor, IntroductionRequestCache.__init__, cache, node.community, other.my_candidate.sock_addr)
    cache = blockingCallFromThread(reactor, node.community.request_cache.add, cache)
    response = other.create_introduction_response(node.my_candidate, other.my_candidate.sock_addr, other.my_candidate.sock_addr, ('0.0.0.0', 0), ('0.0.0.0', 0), u'unknown', False, cache.number)
    response._candidate = other.my_candidate
    def check_live_edge(edge_id, candidates):
        self.assertEqual(1, edge_id)
        self.assertEqual(node.my_member.mid, candidates[0].get_member().mid)
        self.assertEqual(other.my_member.mid, candidates[1].get_member().mid)
        check_live_edge.called = True
    node.community.set_live_edge_callback(check_live_edge)
    blockingCallFromThread(reactor, node.community.on_introduction_response, [response])
    self.assertTrue(check_live_edge.called)
