Merge bitcoin/bitcoin#24797: test: compare /chaininfo response with getblockchaininfo RPC

0f7dc893ea test: compare `/chaininfo` response with `getblockchaininfo` RPC (brunoerg)

Pull request description:

  The `/chaininfo` REST endpoint gets its infos from `getblockchaininfo` RPC, so this PR adds an `assert_equal` (in `interface_rest`) to ensure both responses are the same. Obs: other endpoints do the same for their respective RPC.

ACKs for top commit:
  0xB10C:
    Concept and Code Review ACK 0f7dc893ea. Belts-and-spenders.

Tree-SHA512: 51cbcf988090272e406a47dc869710740b74e2222af29c05ddcbf53bd49765cdc59efb525e970867f091b3d2efec4fb13371a342d9e484e51144b760265bc5b8
This commit is contained in:
MarcoFalke 2022-04-11 11:04:17 +02:00
commit 4a58b6acd2
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -361,6 +361,10 @@ class RESTTest (BitcoinTestFramework):
json_obj = self.test_rest_request("/chaininfo") json_obj = self.test_rest_request("/chaininfo")
assert_equal(json_obj['bestblockhash'], bb_hash) assert_equal(json_obj['bestblockhash'], bb_hash)
# Compare with normal RPC getblockchaininfo response
blockchain_info = self.nodes[0].getblockchaininfo()
assert_equal(blockchain_info, json_obj)
# Test compatibility of deprecated and newer endpoints # Test compatibility of deprecated and newer endpoints
self.log.info("Test compatibility of deprecated and newer endpoints") self.log.info("Test compatibility of deprecated and newer endpoints")
assert_equal(self.test_rest_request(f"/headers/{bb_hash}", query_params={"count": 1}), self.test_rest_request(f"/headers/1/{bb_hash}")) assert_equal(self.test_rest_request(f"/headers/{bb_hash}", query_params={"count": 1}), self.test_rest_request(f"/headers/1/{bb_hash}"))