Skip to content

feat(core-api): accept block height to list block transactions #2567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions __tests__/integration/core-api/v2/handlers/blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ describe("API 2.0 - Blocks", () => {
);
});

describe("GET /blocks/:height/transactions", () => {
describe.each([["API-Version", "request"], ["Accept", "requestWithAcceptHeader"]])(
'using the "%s" header',
(header, request) => {
it("should GET all the transactions for the given block by id", async () => {
const response = await utils[request]("GET", `blocks/${genesisBlock.height}/transactions`);
expect(response).toBeSuccessfulResponse();
expect(response.data.data).toBeArray();

const transaction = response.data.data[0];
utils.expectTransaction(transaction);
expect(transaction.blockId).toBe(genesisBlock.id);
});
},
);
});

describe("POST /blocks/search", () => {
describe.each([["API-Version", "request"], ["Accept", "requestWithAcceptHeader"]])(
"using the %s header",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-api/src/versions/2/blocks/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const show = async request => {
};

const transactions = async request => {
const block = await blocksRepository.findById(request.params.id);
const block = await blocksRepository.findByIdOrHeight(request.params.id);

if (!block) {
return Boom.notFound("Block not found");
Expand Down