You missed tests for the following routes:
| Endpoint |
Expected Cache-Control |
| /tx |
public, max-age=31536000, immutable |
| /blockfilter |
public, max-age=31536000, immutable |
| /blockfilterheaders |
public, max-age=31536000, immutable |
| /deploymentinfo |
no-store |
| /getutxos |
no-store |
0 self.log.info("Test Cache-Control headers on REST responses")
1
2 blockhash = self.nodes[0].getbestblockhash()
3 height = self.nodes[0].getblockcount()
4 txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"]
5
6 # Immutable (hash-addressed) endpoints
7 response = self.test_rest_request(f"/block/{blockhash}", ret_type=RetType.OBJ)
8 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
9 response.read()
10
11 response = self.test_rest_request(f"/block/{blockhash}", req_type=ReqType.BIN, ret_type=RetType.OBJ)
12 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
13 response.read()
14
15 response = self.test_rest_request(f"/headers/{blockhash}", ret_type=RetType.OBJ, query_params={"count": 1})
16 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
17 response.read()
18
19 response = self.test_rest_request(f"/spenttxouts/{blockhash}", ret_type=RetType.OBJ)
20 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
21 response.read()
22
23 response = self.test_rest_request(f"/tx/{txid}", ret_type=RetType.OBJ)
24 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
25 response.read()
26
27 response = self.test_rest_request(f"/blockfilter/basic/{blockhash}", ret_type=RetType.OBJ)
28 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
29 response.read()
30
31 response = self.test_rest_request(f"/blockfilterheaders/basic/{blockhash}", ret_type=RetType.OBJ, query_params={"count": 1})
32 assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
33 response.read()
34
35 # Short-lived (height-addressed) endpoints
36 response = self.test_rest_request(f"/blockhashbyheight/{height}", ret_type=RetType.OBJ)
37 assert_equal(response.getheader("Cache-Control"), "public, max-age=30")
38 response.read()
39
40 # Dynamic (no-store) endpoints
41 response = self.test_rest_request("/chaininfo", ret_type=RetType.OBJ)
42 assert_equal(response.getheader("Cache-Control"), "no-store")
43 response.read()
44
45 response = self.test_rest_request("/mempool/info", ret_type=RetType.OBJ)
46 assert_equal(response.getheader("Cache-Control"), "no-store")
47 response.read()
48
49 response = self.test_rest_request("/deploymentinfo", ret_type=RetType.OBJ)
50 assert_equal(response.getheader("Cache-Control"), "no-store")
51 response.read()
52
53 response = self.test_rest_request(f"/getutxos/{txid}-0", ret_type=RetType.OBJ)
54 assert_equal(response.getheader("Cache-Control"), "no-store")
55 response.read()
56
57 # Error responses should not be cached
58 response = self.test_rest_request(f"/block/{UNKNOWN_PARAM}", status=404, ret_type=RetType.OBJ)
59 assert_equal(response.getheader("Cache-Control"), "no-store")
60 response.read()