[qa] httpbasics: Actually test second connection

pull/262/head
MarcoFalke 9 years ago
parent e662a76288
commit fa24456d0c

@ -37,13 +37,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.connect() conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) assert(b'"error":null' in out1)
assert(conn.sock!=None) #according to http/1.1 connection must still be open! assert(conn.sock!=None) #according to http/1.1 connection must still be open!
#send 2nd request without closing connection #send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers) conn.request('POST', '/', '{"method": "getchaintips"}', headers)
out2 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) #must also response with a correct json-rpc message assert(b'"error":null' in out1) #must also response with a correct json-rpc message
assert(conn.sock!=None) #according to http/1.1 connection must still be open! assert(conn.sock!=None) #according to http/1.1 connection must still be open!
conn.close() conn.close()
@ -54,13 +54,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.connect() conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) assert(b'"error":null' in out1)
assert(conn.sock!=None) #according to http/1.1 connection must still be open! assert(conn.sock!=None) #according to http/1.1 connection must still be open!
#send 2nd request without closing connection #send 2nd request without closing connection
conn.request('POST', '/', '{"method": "getchaintips"}', headers) conn.request('POST', '/', '{"method": "getchaintips"}', headers)
out2 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) #must also response with a correct json-rpc message assert(b'"error":null' in out1) #must also response with a correct json-rpc message
assert(conn.sock!=None) #according to http/1.1 connection must still be open! assert(conn.sock!=None) #according to http/1.1 connection must still be open!
conn.close() conn.close()
@ -71,7 +71,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.connect() conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) assert(b'"error":null' in out1)
assert(conn.sock==None) #now the connection must be closed after the response assert(conn.sock==None) #now the connection must be closed after the response
#node1 (2nd node) is running with disabled keep-alive option #node1 (2nd node) is running with disabled keep-alive option
@ -83,7 +83,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.connect() conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) assert(b'"error":null' in out1)
#node2 (third node) is running with standard keep-alive parameters which means keep-alive is on #node2 (third node) is running with standard keep-alive parameters which means keep-alive is on
urlNode2 = urlparse.urlparse(self.nodes[2].url) urlNode2 = urlparse.urlparse(self.nodes[2].url)
@ -94,7 +94,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
conn.connect() conn.connect()
conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) conn.request('POST', '/', '{"method": "getbestblockhash"}', headers)
out1 = conn.getresponse().read() out1 = conn.getresponse().read()
assert('"error":null' in out1) assert(b'"error":null' in out1)
assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default
# Check excessive request size # Check excessive request size

Loading…
Cancel
Save