Skip to content

Commit fce15d6

Browse files
authored
fix: query param until_block not working in several endpoints (#2101)
* fix: query param `until_block` not working in several endpoints * chore: fix tests
1 parent bdbb41f commit fce15d6

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/api/query-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export function parseUntilBlockQuery(
4141
): undefined | number | string {
4242
if (!untilBlock) return;
4343
if (typeof untilBlock === 'string') {
44-
if (unanchored !== undefined) {
44+
if (unanchored) {
4545
// if mutually exclusive unachored is also specified, throw bad request error
4646
throw new InvalidRequestError(
47-
`can't handle both 'unanchored' and 'until_block' in the same request`,
47+
`can't handle both 'unanchored=true' and 'until_block' in the same request`,
4848
InvalidRequestErrorType.bad_request
4949
);
5050
}

src/tests/address-tests.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,12 @@ describe('address tests', () => {
15701570
};
15711571
expect(JSON.parse(fetchAddrBalance1.text)).toEqual(expectedResp1);
15721572

1573+
const fetchAddrBalance1AtBlock = await supertest(api.server).get(
1574+
`/extended/v1/address/${testAddr2}/balances?until_block=1`
1575+
);
1576+
expect(fetchAddrBalance1AtBlock.status).toBe(200);
1577+
expect(fetchAddrBalance1AtBlock.type).toBe('application/json');
1578+
15731579
const fetchAddrBalance2 = await supertest(api.server).get(
15741580
`/extended/v1/address/${testContractAddr}/balances`
15751581
);
@@ -2608,16 +2614,6 @@ describe('address tests', () => {
26082614
);
26092615
expect(response.status).toBe(400);
26102616
}
2611-
2612-
const addressEndpoints1 = ['/transactions', '/transactions_with_transfers', '/stx_inbound'];
2613-
2614-
/// check for mutually exclusive until_block adn height params
2615-
for (const path of addressEndpoints1) {
2616-
const response1 = await supertest(api.server).get(
2617-
`/extended/v1/address/STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6${path}?until_block=5&height=0`
2618-
);
2619-
expect(response1.status).toBe(400);
2620-
}
26212617
});
26222618

26232619
test('/transactions materialized view separates anchored and unanchored counts correctly', async () => {

0 commit comments

Comments
 (0)