'Verify that a client and server created with the given contexts can
successfully handshake and communicate.'

def _handshake_test(self, serverContext, clientContext):

    (serverSocket, clientSocket) = socket_pair()
    server = Connection(serverContext, serverSocket)
    server.set_accept_state()
    client = Connection(clientContext, clientSocket)
    client.set_connect_state()
    for i in range(3):
        for s in [client, server]:
            try:
                s.do_handshake()
            except WantReadError:
                pass
