Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit bce62ef

Browse files
committed
test: add test for content etag
1 parent a7674a9 commit bce62ef

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/cache.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)