def run_test(self):
    url = urllib.parse.urlparse(self.nodes[0].url)
    authpair = ((url.username + ':') + url.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.request('POST', '/', '{"method": "getchaintips"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.close()
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair)), 'Connection': 'keep-alive'}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.request('POST', '/', '{"method": "getchaintips"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.close()
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair)), 'Connection': 'close'}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock == None)
    urlNode1 = urllib.parse.urlparse(self.nodes[1].url)
    authpair = ((urlNode1.username + ':') + urlNode1.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(urlNode1.hostname, urlNode1.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    urlNode2 = urllib.parse.urlparse(self.nodes[2].url)
    authpair = ((urlNode2.username + ':') + urlNode2.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('GET', ('/' + ('x' * 1000)), '', headers)
    out1 = conn.getresponse()
    assert_equal(out1.status, http.client.NOT_FOUND)
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('GET', ('/' + ('x' * 10000)), '', headers)
    out1 = conn.getresponse()
    assert_equal(out1.status, http.client.BAD_REQUEST)
def run_test(self):
    url = urllib.parse.urlparse(self.nodes[0].url)
    authpair = ((url.username + ':') + url.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.request('POST', '/', '{"method": "getchaintips"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.close()
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair)), 'Connection': 'keep-alive'}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.request('POST', '/', '{"method": "getchaintips"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn.close()
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair)), 'Connection': 'close'}
    conn = http.client.HTTPConnection(url.hostname, url.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock == None)
    urlNode1 = urllib.parse.urlparse(self.nodes[1].url)
    authpair = ((urlNode1.username + ':') + urlNode1.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(urlNode1.hostname, urlNode1.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    urlNode2 = urllib.parse.urlparse(self.nodes[2].url)
    authpair = ((urlNode2.username + ':') + urlNode2.password)
    headers = {'Authorization': ('Basic ' + str_to_b64str(authpair))}
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
    out1 = conn.getresponse().read()
    assert (b'"error":null' in out1)
    assert (conn.sock != None)
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('GET', ('/' + ('x' * 1000)), , headers)
    out1 = conn.getresponse()
    assert_equal(out1.status, http.client.NOT_FOUND)
    conn = http.client.HTTPConnection(urlNode2.hostname, urlNode2.port)
    conn.connect()
    conn.request('GET', ('/' + ('x' * 10000)), , headers)
    out1 = conn.getresponse()
    assert_equal(out1.status, http.client.BAD_REQUEST)