tests: mempool/contents verbose and mempool_sequence query params tests

This commit is contained in:
Andrew Toth 2022-10-03 23:29:21 -04:00
parent a518fff0f2
commit 52a31dccc9
No known key found for this signature in database
GPG Key ID: 60007AFC8938B018

View File

@ -348,6 +348,34 @@ class RESTTest (BitcoinTestFramework):
assert_equal(json_obj[tx]['spentby'], txs[i + 1:i + 2])
assert_equal(json_obj[tx]['depends'], txs[i - 1:i])
# Check the mempool response for explicit parameters
json_obj = self.test_rest_request("/mempool/contents", query_params={"verbose": "true", "mempool_sequence": "false"})
assert_equal(json_obj, raw_mempool_verbose)
# Check the mempool response for not verbose
json_obj = self.test_rest_request("/mempool/contents", query_params={"verbose": "false"})
raw_mempool = self.nodes[0].getrawmempool(verbose=False)
assert_equal(json_obj, raw_mempool)
# Check the mempool response for sequence
json_obj = self.test_rest_request("/mempool/contents", query_params={"verbose": "false", "mempool_sequence": "true"})
raw_mempool = self.nodes[0].getrawmempool(verbose=False, mempool_sequence=True)
assert_equal(json_obj, raw_mempool)
# Check for error response if verbose=true and mempool_sequence=true
resp = self.test_rest_request("/mempool/contents", ret_type=RetType.OBJ, status=400, query_params={"verbose": "true", "mempool_sequence": "true"})
assert_equal(resp.read().decode('utf-8').strip(), 'Verbose results cannot contain mempool sequence values. (hint: set "verbose=false")')
# Check for error response if verbose is not "true" or "false"
resp = self.test_rest_request("/mempool/contents", ret_type=RetType.OBJ, status=400, query_params={"verbose": "TRUE"})
assert_equal(resp.read().decode('utf-8').strip(), 'The "verbose" query parameter must be either "true" or "false".')
# Check for error response if mempool_sequence is not "true" or "false"
resp = self.test_rest_request("/mempool/contents", ret_type=RetType.OBJ, status=400, query_params={"verbose": "false", "mempool_sequence": "TRUE"})
assert_equal(resp.read().decode('utf-8').strip(), 'The "mempool_sequence" query parameter must be either "true" or "false".')
# Now mine the transactions
newblockhash = self.generate(self.nodes[1], 1)