Skip to content

Commit

Permalink
fix: query param until_block not working in several endpoints (#2101)
Browse files Browse the repository at this point in the history
* fix: query param `until_block` not working in several endpoints

* chore: fix tests
  • Loading branch information
zone117x authored Oct 1, 2024
1 parent bdbb41f commit fce15d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/api/query-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export function parseUntilBlockQuery(
): undefined | number | string {
if (!untilBlock) return;
if (typeof untilBlock === 'string') {
if (unanchored !== undefined) {
if (unanchored) {
// if mutually exclusive unachored is also specified, throw bad request error
throw new InvalidRequestError(
`can't handle both 'unanchored' and 'until_block' in the same request`,
`can't handle both 'unanchored=true' and 'until_block' in the same request`,
InvalidRequestErrorType.bad_request
);
}
Expand Down
16 changes: 6 additions & 10 deletions src/tests/address-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,12 @@ describe('address tests', () => {
};
expect(JSON.parse(fetchAddrBalance1.text)).toEqual(expectedResp1);

const fetchAddrBalance1AtBlock = await supertest(api.server).get(
`/extended/v1/address/${testAddr2}/balances?until_block=1`
);
expect(fetchAddrBalance1AtBlock.status).toBe(200);
expect(fetchAddrBalance1AtBlock.type).toBe('application/json');

const fetchAddrBalance2 = await supertest(api.server).get(
`/extended/v1/address/${testContractAddr}/balances`
);
Expand Down Expand Up @@ -2608,16 +2614,6 @@ describe('address tests', () => {
);
expect(response.status).toBe(400);
}

const addressEndpoints1 = ['/transactions', '/transactions_with_transfers', '/stx_inbound'];

/// check for mutually exclusive until_block adn height params
for (const path of addressEndpoints1) {
const response1 = await supertest(api.server).get(
`/extended/v1/address/STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6${path}?until_block=5&height=0`
);
expect(response1.status).toBe(400);
}
});

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

0 comments on commit fce15d6

Please sign in to comment.