diff --git a/src/routes/txs/hash/required-signers.ts b/src/routes/txs/hash/required-signers.ts index cedfd876..2f8a947d 100644 --- a/src/routes/txs/hash/required-signers.ts +++ b/src/routes/txs/hash/required-signers.ts @@ -8,18 +8,17 @@ import { getDbSync } from '../../../utils/database.js'; async function route(fastify: FastifyInstance) { fastify.route({ - url: '/txs/:hash/required-signers', + url: '/txs/:hash/required_signers', method: 'GET', - schema: getSchemaForEndpoint('/txs/:hash:/required-signers'), + schema: getSchemaForEndpoint('/txs/:hash:/required_signers'), handler: async (request: FastifyRequest, reply) => { const clientDbSync = await getDbSync(fastify); try { - const { rows } = - await clientDbSync.query( - SQLQuery.get('txs_hash_wits'), - [request.params.hash], - ); + const { rows } = await clientDbSync.query( + SQLQuery.get('txs_hash_wits'), + [request.params.hash], + ); clientDbSync.release(); @@ -34,6 +33,7 @@ async function route(fastify: FastifyInstance) { } const unpaged = isUnpaged(request); + if (unpaged) { // Use of Reply.raw functions is at your own risk as you are skipping all the Fastify logic of handling the HTTP response // https://www.fastify.io/docs/latest/Reference/Reply/#raw diff --git a/test/unit/fixtures/txs.fixtures.ts b/test/unit/fixtures/txs.fixtures.ts index b647f5ea..a9574498 100644 --- a/test/unit/fixtures/txs.fixtures.ts +++ b/test/unit/fixtures/txs.fixtures.ts @@ -1137,6 +1137,20 @@ const response_txs_redeemers = [ }, ]; +const query_txs_required_signers = [ + { hash: 'd52e11f3e48436dd42dbec6d88c239732e503b8b7a32af58e5f87625' }, + { hash: '41b32682c413535dbca5178f92f3cee5dede31b995400b8c371e2469' }, + { hash: 'd52e11f3e48436dd42dbec6d88c239732e503b8b7a32af58e5f87625' }, + { hash: '666414964a05b01cef36427b8a0fb0f621806c43e66e7a4d3cca3bfb' }, +]; + +const response_txs_required_signers = [ + 'd52e11f3e48436dd42dbec6d88c239732e503b8b7a32af58e5f87625', + '41b32682c413535dbca5178f92f3cee5dede31b995400b8c371e2469', + 'd52e11f3e48436dd42dbec6d88c239732e503b8b7a32af58e5f87625', + '666414964a05b01cef36427b8a0fb0f621806c43e66e7a4d3cca3bfb', +]; + const response_404 = { error: 'Not Found', message: 'The requested component has not been found.', @@ -1542,6 +1556,28 @@ export default [ }, response: [], }, + { + name: 'respond with success and data on /txs/:hash/required_signers', + endpoint: '/txs/6e6644e0f8aeec3437bec536408fc007a6147d94098f2dbaeb6ad80d0508631b/required_signers', + sqlQueryMock: { + rows: query_found, + }, + sqlQueryMock2: { + rows: query_txs_required_signers, + }, + response: response_txs_required_signers, + }, + { + name: 'respond with success and data on /txs/:hash/required_signers', + endpoint: '/txs/6e6644e0f8aeec3437bec536408fc007a6147d94098f2dbaeb6ad80d0508631b/required_signers', + sqlQueryMock: { + rows: query_found, + }, + sqlQueryMock2: { + rows: [], + }, + response: [], + }, /* 404s */ @@ -1637,6 +1673,14 @@ export default [ }, response: response_404, }, + { + name: 'respond with 404 and empty data on /txs/:hash/required_signers', + endpoint: '/txs/stonks_tx/required_signers', + sqlQueryMock: { + rows: [], + }, + response: response_404, + }, /* 500s @@ -1778,4 +1822,12 @@ export default [ }, response: response_500, }, + { + name: 'respond with 500 and null on /txs/:hash/required_signers', + endpoint: '/txs/stonks_tx/required_signers', + sqlQueryMock: { + rows: null, + }, + response: response_500, + }, ]; //as const;