@@ -260,4 +260,45 @@ describe('ETag cache', () => {
260260    } ) ; 
261261    expect ( cacheBusted . statusCode ) . toBe ( 200 ) ; 
262262  } ) ; 
263+ 
264+   test ( 'inscription content cache control' ,  async  ( )  =>  { 
265+     const  block1  =  new  TestChainhookPayloadBuilder ( ) 
266+       . apply ( ) 
267+       . block ( {  height : 778575 ,  hash : randomHash ( )  } ) 
268+       . transaction ( {  hash : '0x9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201'  } ) 
269+       . inscriptionRevealed ( { 
270+         content_bytes : '0x48656C6C6F' , 
271+         content_type : 'text/plain' , 
272+         content_length : 5 , 
273+         inscription_number : 7 , 
274+         inscription_fee : 705 , 
275+         inscription_id : '9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0' , 
276+         inscription_output_value : 10000 , 
277+         inscriber_address : 'bc1pscktlmn99gyzlvymvrezh6vwd0l4kg06tg5rvssw0czg8873gz5sdkteqj' , 
278+         ordinal_number : 257418248345364 , 
279+         ordinal_block_height : 650000 , 
280+         ordinal_offset : 0 , 
281+         satpoint_post_inscription :
282+           '9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201:0:0' , 
283+       } ) 
284+       . build ( ) ; 
285+     await  db . updateInscriptions ( block1 ) ; 
286+ 
287+     // ETag response 
288+     const  response  =  await  fastify . inject ( { 
289+       method : 'GET' , 
290+       url : '/ordinals/v1/inscriptions/9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0/content' , 
291+     } ) ; 
292+     expect ( response . statusCode ) . toBe ( 200 ) ; 
293+     expect ( response . headers . etag ) . not . toBeUndefined ( ) ; 
294+     const  etag  =  response . headers . etag ; 
295+ 
296+     // Cached 
297+     const  cached  =  await  fastify . inject ( { 
298+       method : 'GET' , 
299+       url : '/ordinals/v1/inscriptions/9f4a9b73b0713c5da01c0a47f97c6c001af9028d6bdd9e264dfacbc4e6790201i0/content' , 
300+       headers : {  'if-none-match' : etag  } , 
301+     } ) ; 
302+     expect ( cached . statusCode ) . toBe ( 304 ) ; 
303+   } ) ; 
263304} ) ; 
0 commit comments