Skip to content

Commit 75c850e

Browse files
committed
fix: rename by-block-time endpoint
1 parent 444caae commit 75c850e

5 files changed

Lines changed: 24 additions & 24 deletions

File tree

client/src/generated/schema.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,18 +1228,18 @@ export interface paths {
12281228
patch?: never;
12291229
trace?: never;
12301230
};
1231-
"/extended/v2/blocks/at-time/{timestamp}": {
1231+
"/extended/v2/blocks/by-block-time/{timestamp}": {
12321232
parameters: {
12331233
query?: never;
12341234
header?: never;
12351235
path?: never;
12361236
cookie?: never;
12371237
};
12381238
/**
1239-
* Get block at time
1239+
* Get block by block time
12401240
* @description Retrieves the most recent block mined at or before a given Unix timestamp (in seconds)
12411241
*/
1242-
get: operations["get_block_at_time"];
1242+
get: operations["get_block_by_block_time"];
12431243
put?: never;
12441244
post?: never;
12451245
delete?: never;
@@ -27582,7 +27582,7 @@ export interface operations {
2758227582
};
2758327583
};
2758427584
};
27585-
get_block_at_time: {
27585+
get_block_by_block_time: {
2758627586
parameters: {
2758727587
query?: never;
2758827588
header?: never;

openapi.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80517,10 +80517,10 @@ paths:
8051780517
type: string
8051880518
message:
8051980519
type: string
80520-
/extended/v2/blocks/at-time/{timestamp}:
80520+
/extended/v2/blocks/by-block-time/{timestamp}:
8052180521
get:
80522-
operationId: get_block_at_time
80523-
summary: Get block at time
80522+
operationId: get_block_by_block_time
80523+
summary: Get block by block time
8052480524
tags:
8052580525
- Blocks
8052680526
description: Retrieves the most recent block mined at or before a given Unix

src/api/routes/v2/blocks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ export const BlockRoutesV2: FastifyPluginAsync<
110110
);
111111

112112
fastify.get(
113-
'/at-time/:timestamp',
113+
'/by-block-time/:timestamp',
114114
{
115115
preHandler: handleBlockCache,
116116
schema: {
117-
operationId: 'get_block_at_time',
118-
summary: 'Get block at time',
117+
operationId: 'get_block_by_block_time',
118+
summary: 'Get block by block time',
119119
description: `Retrieves the most recent block mined at or before a given Unix timestamp (in seconds)`,
120120
tags: ['Blocks'],
121121
params: BlockTimestampParamsSchema,

tests/api/blocks/block.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,33 +1270,33 @@ describe('block tests', () => {
12701270
}
12711271

12721272
// Query with timestamp between block 2 and block 3 => should return block 2
1273-
const res1 = await supertest(api.server).get(`/extended/v2/blocks/at-time/2500`);
1273+
const res1 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/2500`);
12741274
assert.equal(res1.status, 200);
12751275
assert.equal(res1.body.height, 2);
12761276
assert.equal(res1.body.block_time, 2000);
12771277
assert.equal(res1.body.hash, '0x2222222222222222222222222222222222222222222222222222222222222222');
12781278

12791279
// Exact match: query with timestamp equal to block 3 => should return block 3
1280-
const res2 = await supertest(api.server).get(`/extended/v2/blocks/at-time/3000`);
1280+
const res2 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/3000`);
12811281
assert.equal(res2.status, 200);
12821282
assert.equal(res2.body.height, 3);
12831283
assert.equal(res2.body.block_time, 3000);
12841284

12851285
// Query with timestamp before all blocks => should return 404
1286-
const res3 = await supertest(api.server).get(`/extended/v2/blocks/at-time/500`);
1286+
const res3 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/500`);
12871287
assert.equal(res3.status, 404);
12881288

12891289
// Query with very large timestamp => should return most recent block
1290-
const res4 = await supertest(api.server).get(`/extended/v2/blocks/at-time/999999999`);
1290+
const res4 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/999999999`);
12911291
assert.equal(res4.status, 200);
12921292
assert.equal(res4.body.height, 3);
12931293

12941294
// Invalid timestamp (negative) => should return 400
1295-
const res5 = await supertest(api.server).get(`/extended/v2/blocks/at-time/-1`);
1295+
const res5 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/-1`);
12961296
assert.equal(res5.status, 400);
12971297

12981298
// Invalid timestamp (non-numeric) => should return 400
1299-
const res6 = await supertest(api.server).get(`/extended/v2/blocks/at-time/abc`);
1299+
const res6 = await supertest(api.server).get(`/extended/v2/blocks/by-block-time/abc`);
13001300
assert.equal(res6.status, 400);
13011301
});
13021302
});

tests/api/cache/cache-control.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ describe('cache-control tests', () => {
10061006
assert.equal(request7.text, '');
10071007
});
10081008

1009-
test('block at-time cache control', async () => {
1009+
test('block by-block-time cache control', async () => {
10101010
const blockTime1 = 1700000000;
10111011
const blockTime2 = 1700001000;
10121012

@@ -1031,7 +1031,7 @@ describe('cache-control tests', () => {
10311031

10321032
// Valid ETag for timestamp query.
10331033
const request1 = await supertest(api.server).get(
1034-
`/extended/v2/blocks/at-time/${blockTime2}`
1034+
`/extended/v2/blocks/by-block-time/${blockTime2}`
10351035
);
10361036
assert.equal(request1.status, 200);
10371037
assert.equal(request1.type, 'application/json');
@@ -1041,21 +1041,21 @@ describe('cache-control tests', () => {
10411041

10421042
// Cache works with valid ETag.
10431043
const request2 = await supertest(api.server)
1044-
.get(`/extended/v2/blocks/at-time/${blockTime2}`)
1044+
.get(`/extended/v2/blocks/by-block-time/${blockTime2}`)
10451045
.set('If-None-Match', etag0);
10461046
assert.equal(request2.status, 304);
10471047
assert.equal(request2.text, '');
10481048

10491049
// Cache miss with wrong ETag.
10501050
const request3 = await supertest(api.server)
1051-
.get(`/extended/v2/blocks/at-time/${blockTime2}`)
1051+
.get(`/extended/v2/blocks/by-block-time/${blockTime2}`)
10521052
.set('If-None-Match', '"0x12345678"');
10531053
assert.equal(request3.status, 200);
10541054
assert.equal(request3.headers['etag'], etag0);
10551055

10561056
// Timestamp between blocks returns earlier block with different ETag.
10571057
const request4 = await supertest(api.server).get(
1058-
`/extended/v2/blocks/at-time/${blockTime1 + 500}`
1058+
`/extended/v2/blocks/by-block-time/${blockTime1 + 500}`
10591059
);
10601060
assert.equal(request4.status, 200);
10611061
assert.equal(request4.body.height, 1);
@@ -1064,7 +1064,7 @@ describe('cache-control tests', () => {
10641064

10651065
// Cache works for earlier block timestamp.
10661066
const request5 = await supertest(api.server)
1067-
.get(`/extended/v2/blocks/at-time/${blockTime1 + 500}`)
1067+
.get(`/extended/v2/blocks/by-block-time/${blockTime1 + 500}`)
10681068
.set('If-None-Match', etag1);
10691069
assert.equal(request5.status, 304);
10701070
assert.equal(request5.text, '');
@@ -1091,15 +1091,15 @@ describe('cache-control tests', () => {
10911091

10921092
// Old ETag is now a miss after re-org.
10931093
const request6 = await supertest(api.server)
1094-
.get(`/extended/v2/blocks/at-time/${blockTime2}`)
1094+
.get(`/extended/v2/blocks/by-block-time/${blockTime2}`)
10951095
.set('If-None-Match', etag0);
10961096
assert.equal(request6.status, 200);
10971097
assert.notEqual(request6.headers['etag'], etag0);
10981098
const etag2 = request6.headers['etag'];
10991099

11001100
// Cache works with new ETag.
11011101
const request7 = await supertest(api.server)
1102-
.get(`/extended/v2/blocks/at-time/${blockTime2}`)
1102+
.get(`/extended/v2/blocks/by-block-time/${blockTime2}`)
11031103
.set('If-None-Match', etag2);
11041104
assert.equal(request7.status, 304);
11051105
assert.equal(request7.text, '');

0 commit comments

Comments
 (0)