@@ -244,4 +244,45 @@ describe('ETag cache', () => {
244
244
} ) ;
245
245
expect ( cacheBusted . statusCode ) . toBe ( 200 ) ;
246
246
} ) ;
247
+
248
+ test ( 'inscription content cache control' , async ( ) => {
249
+ const block1 = new TestChainhookPayloadBuilder ( )
250
+ . apply ( )
251
+ . block ( { height : 778575 , hash : randomHash ( ) } )
252
+ . transaction ( { hash : '0x9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201' } )
253
+ . inscriptionRevealed ( {
254
+ content_bytes : '0x48656C6C6F' ,
255
+ content_type : 'text/plain' ,
256
+ content_length : 5 ,
257
+ inscription_number : 7 ,
258
+ inscription_fee : 705 ,
259
+ inscription_id : '9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0' ,
260
+ inscription_output_value : 10000 ,
261
+ inscriber_address : 'bc1pscktlmn99gyzlvymvrezh6vwd0l4kg06tg5rvssw0czg8873gz5sdkteqj' ,
262
+ ordinal_number : 257418248345364 ,
263
+ ordinal_block_height : 650000 ,
264
+ ordinal_offset : 0 ,
265
+ satpoint_post_inscription :
266
+ '9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201:0:0' ,
267
+ } )
268
+ . build ( ) ;
269
+ await db . updateInscriptions ( block1 ) ;
270
+
271
+ // ETag response
272
+ const response = await fastify . inject ( {
273
+ method : 'GET' ,
274
+ url : '/ordinals/v1/inscriptions/9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0/content' ,
275
+ } ) ;
276
+ expect ( response . statusCode ) . toBe ( 200 ) ;
277
+ expect ( response . headers . etag ) . not . toBeUndefined ( ) ;
278
+ const etag = response . headers . etag ;
279
+
280
+ // Cached
281
+ const cached = await fastify . inject ( {
282
+ method : 'GET' ,
283
+ url : '/ordinals/v1/inscriptions/9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0/content' ,
284
+ headers : { 'if-none-match' : etag } ,
285
+ } ) ;
286
+ expect ( cached . statusCode ) . toBe ( 304 ) ;
287
+ } ) ;
247
288
} ) ;
0 commit comments