Skip to content
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
10 changes: 7 additions & 3 deletions packages/wallet-service/src/api/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import 'source-map-support/register';
import {
closeDbConnection,
getDbConnection,
getUnixTimestamp,
} from '@src/utils';
import { warmupMiddleware } from '@src/api/utils';
import { getRawFullnodeData } from '@src/nodeConfig'
import { getFullnodeData } from '@src/nodeConfig'
import errorHandler from '@src/api/middlewares/errorHandler';
import middy from '@middy/core';
import cors from '@middy/http-cors';
Expand All @@ -26,15 +27,18 @@ const mysql = getDbConnection();
* This lambda is called by API Gateway on GET /version
*/
export const get: APIGatewayProxyHandler = middy(async () => {
const versionData = await getRawFullnodeData(mysql);
const versionData = await getFullnodeData(mysql);

await closeDbConnection(mysql);

return {
statusCode: 200,
body: JSON.stringify({
success: true,
data: versionData,
data: {
...versionData,
timestamp: getUnixTimestamp(),
},
}),
};
}).use(cors())
Expand Down
8 changes: 7 additions & 1 deletion packages/wallet-service/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
import fullnode from '@src/fullnode';
import { getHealthcheck } from '@src/api/healthcheck';
import { Severity } from '@wallet-service/common';
import { convertApiVersionData } from '@src/nodeConfig';

// Monkey patch bitcore-lib

Expand Down Expand Up @@ -1682,17 +1683,22 @@ test('GET /version', async () => {
genesis_tx2_hash: 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc',
native_token: { name: 'Hathor', symbol: 'HTR'},
};
const returnData = convertApiVersionData(mockData);

const ts = getUnixTimestamp()
await updateVersionData(mysql, ts, mockData);


const event = makeGatewayEvent({});
const result = await getVersionDataGet(event, null, null) as APIGatewayProxyResult;
const returnBody = JSON.parse(result.body as string);

expect(result.statusCode).toBe(200);
expect(returnBody.success).toBe(true);
expect(returnBody.data).toStrictEqual(mockData);
expect(returnBody.data).toEqual(expect.objectContaining({
timestamp: expect.anything(),
...returnData,
}));
});

test('GET /wallet/proxy/transactions/{txId}', async () => {
Expand Down