def METHOD_NAME(tls_protocol, peer, expected_result=True, ciphers=None, tlsOnly=False):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.settimeout(1)
    ctx = ssl.SSLContext(tls_protocol)
    if ciphers:
        print("Trying ciphers: ", ciphers)
        try:
            ctx.set_ciphers(ciphers)
        except Exception as e:
            print("===> Error: could not set ciphers {}, {}".format(ciphers, e))
            print("     Check openssl version used by python")
            return
    if expected_result == False:
        res_string = "should fail"
    else:
        res_string = "should succeed"
    print("--->", res_string)
    result = True
    try:
        wrappedSocket = ctx.wrap_socket(sock)
        wrappedSocket.connect(peer)
        if expected_result == result:
            print("...OK, TLS connection established")
        print("negotiated protocol: {}, using cipher: {}".format(wrappedSocket.version(), wrappedSocket.cipher()[0]))
        wrappedSocket.shutdown(socket.SHUT_RDWR)
        wrappedSocket.close()
        sock.close()
    except Exception as e:
        result = False
        if expected_result != result:
            print("Error: ", e)
            assert_true(False)
        print("...OK, TLS connection failed: ", e)
        wrappedSocket.close()
        sock.close()
        if tlsOnly == False:
            # upon failure, a TLS node optionally can fall back to unencrypted mode for this endpoint ip, 
            # therefore we must connect/disconnect in order to be able to try a new TLS connection 
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            sock.settimeout(1)
            print("...connecting non-TLS and exiting...")
            sock.connect(peer)
            sock.close()
    if result != expected_result:
        raise AssertionError("Unexpected result!")
    print