|
22 | 22 |
|
23 | 23 | class HTTPBasicsTest (BitcoinTestFramework): |
24 | 24 | def setup_nodes(self): |
25 | | - return start_nodes(4, self.options.tmpdir, extra_args=[['-rpckeepalive']]*4) |
| 25 | + return start_nodes(4, self.options.tmpdir, extra_args=[['-rpckeepalive=1'], ['-rpckeepalive=0'], [], []]) |
26 | 26 |
|
27 | 27 | def run_test(self): |
28 | 28 |
|
@@ -74,6 +74,29 @@ def run_test(self): |
74 | 74 | assert_equal('"error":null' in out1, True) |
75 | 75 | assert_equal(conn.sock!=None, False) #now the connection must be closed after the response |
76 | 76 |
|
| 77 | + #node1 (2nd node) is running with disabled keep-alive option |
| 78 | + urlNode1 = urlparse.urlparse(self.nodes[1].url) |
| 79 | + authpair = urlNode1.username + ':' + urlNode1.password |
| 80 | + headers = {"Authorization": "Basic " + base64.b64encode(authpair)} |
| 81 | + |
| 82 | + conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port) |
| 83 | + conn.connect() |
| 84 | + conn.request('GET', '/', '{"method": "getbestblockhash"}', headers) |
| 85 | + out1 = conn.getresponse().read(); |
| 86 | + assert_equal('"error":null' in out1, True) |
| 87 | + assert_equal(conn.sock!=None, False) #connection must be closed because keep-alive was set to false |
| 88 | + |
| 89 | + #node2 (third node) is running with standard keep-alive parameters which means keep-alive is off |
| 90 | + urlNode2 = urlparse.urlparse(self.nodes[2].url) |
| 91 | + authpair = urlNode2.username + ':' + urlNode2.password |
| 92 | + headers = {"Authorization": "Basic " + base64.b64encode(authpair)} |
| 93 | + |
| 94 | + conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) |
| 95 | + conn.connect() |
| 96 | + conn.request('GET', '/', '{"method": "getbestblockhash"}', headers) |
| 97 | + out1 = conn.getresponse().read(); |
| 98 | + assert_equal('"error":null' in out1, True) |
| 99 | + assert_equal(conn.sock!=None, False) #connection must be closed because bitcoind should use keep-alive by default |
77 | 100 |
|
78 | 101 | if __name__ == '__main__': |
79 | 102 | HTTPBasicsTest ().main () |
0 commit comments