self.num_nodes = 1
Test runs fine with 1 node (and doesn't need to override setup_network() to avoid connecting the nodes). Multiple nodes existed for historical reasons to test different keepalive settings from what I gathered.
<details><summary>Diff</summary>
diff --git a/test/functional/interface_http.py b/test/functional/interface_http.py
index ff6d70a03a..189e1e8cd7 100755
--- a/test/functional/interface_http.py
+++ b/test/functional/interface_http.py
@@ -94,11 +94,9 @@ class BitcoinHTTPConnection:
class HTTPBasicsTest (BitcoinTestFramework):
def set_test_params(self):
- self.num_nodes = 3
+ self.num_nodes = 1
self.supports_cli = False
- def setup_network(self):
- self.setup_nodes()
def run_test(self):
self.check_default_connection()
@@ -167,7 +165,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
assert_equal(response1.status, http.client.NOT_FOUND)
# Excessive URI size plus default headers breaks the limit.
- conn = BitcoinHTTPConnection(self.nodes[1])
+ conn = BitcoinHTTPConnection(self.nodes[0])
response2 = conn.get(f'/{"x" * MAX_HEADERS_SIZE}')
assert_equal(response2.status, http.client.BAD_REQUEST)
@@ -183,14 +181,14 @@ class HTTPBasicsTest (BitcoinTestFramework):
headers_above_limit += 1000 // header_line_length
# Many small header lines is ok
- conn = BitcoinHTTPConnection(self.nodes[2])
+ conn = BitcoinHTTPConnection(self.nodes[0])
for i in range(headers_below_limit):
conn.add_header(f"header_{i:04}", "foo")
response3 = conn.get('/x')
assert_equal(response3.status, http.client.NOT_FOUND)
# Too many small header lines exceeds total headers size allowed
- conn = BitcoinHTTPConnection(self.nodes[2])
+ conn = BitcoinHTTPConnection(self.nodes[0])
for i in range(headers_above_limit):
conn.add_header(f"header_{i:04}", "foo")
response3 = conn.get('/x')
@@ -207,7 +205,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
response4 = conn.post('/', f'{{"jsonrpc": "2.0", "id": "0", "method": "submitblock", "params": ["{"0" * bytes_below_limit}"]}}')
assert_equal(response4.status, http.client.OK)
- conn = BitcoinHTTPConnection(self.nodes[1])
+ conn = BitcoinHTTPConnection(self.nodes[0])
try:
# Excessive body size is invalid
response5 = conn.post('/', f'{{"jsonrpc": "2.0", "id": "0", "method": "submitblock", "params": ["{"0" * bytes_above_limit}"]}}')
@@ -229,8 +227,8 @@ class HTTPBasicsTest (BitcoinTestFramework):
See https://www.rfc-editor.org/rfc/rfc7230#section-6.3.2
"""
self.log.info("Check pipelining")
- tip_height = self.nodes[2].getblockcount()
- conn = BitcoinHTTPConnection(self.nodes[2])
+ tip_height = self.nodes[0].getblockcount()
+ conn = BitcoinHTTPConnection(self.nodes[0])
conn.set_timeout(5)
# Send two requests in a row.
@@ -248,7 +246,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
pass
# Use a separate http connection to generate a block
- self.generate(self.nodes[2], 1, sync_fun=self.no_op)
+ self.generate(self.nodes[0], 1, sync_fun=self.no_op)
# Wait for two responses to be received
res = b""
@@ -264,7 +262,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
def check_chunked_transfer(self):
self.log.info("Check HTTP request encoded with chunked transfer")
- conn = BitcoinHTTPConnection(self.nodes[2])
+ conn = BitcoinHTTPConnection(self.nodes[0])
headers_chunked = conn.headers.copy()
headers_chunked.update({"Transfer-encoding": "chunked"})
body_chunked = [
@@ -325,17 +323,17 @@ class HTTPBasicsTest (BitcoinTestFramework):
# the server. Negating this setting will force the AuthServiceProxy
# for this node to create a fresh new HTTP connection for every command
# called for the remainder of this test.
- self.nodes[2].reuse_http_connections = False
+ self.nodes[0].reuse_http_connections = False
# This is the amount of time the server will wait for a client to
# send a complete request. Test it by sending an incomplete but
# so-far otherwise well-formed HTTP request, and never finishing it
- self.restart_node(2, extra_args=[f"-rpcservertimeout={RPCSERVERTIMEOUT}"])
+ self.restart_node(0, extra_args=[f"-rpcservertimeout={RPCSERVERTIMEOUT}"])
# Copied from http_incomplete_test_() in regress_http.c in libevent.
# A complete request would have an additional "\r\n" at the end.
bad_http_request = "GET /test1 HTTP/1.1\r\nHost: somehost\r\n"
- conn = BitcoinHTTPConnection(self.nodes[2])
+ conn = BitcoinHTTPConnection(self.nodes[0])
conn.conn.sock.sendall(bad_http_request.encode("utf-8"))
conn.expect_timeout(RPCSERVERTIMEOUT)
@@ -353,13 +351,13 @@ class HTTPBasicsTest (BitcoinTestFramework):
def check_server_busy_idle_timeout(self):
self.log.info("Check that -rpcservertimeout won't close on a delayed response")
- tip_height = self.nodes[2].getblockcount()
- conn = BitcoinHTTPConnection(self.nodes[2])
+ tip_height = self.nodes[0].getblockcount()
+ conn = BitcoinHTTPConnection(self.nodes[0])
conn.post_raw('/', f'{{"method": "waitforblockheight", "params": [{tip_height + 1}]}}')
# Wait until after the timeout, then generate a block with a second HTTP connection
time.sleep(RPCSERVERTIMEOUT + 1)
- generated_block = self.generate(self.nodes[2], 1, sync_fun=self.no_op)[0]
+ generated_block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
# The first connection gets the response it is patiently waiting for
response1 = conn.recv_raw().decode()
</details>