Skip to content

Commit

Permalink
tests: added a test for invalid payload
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Jun 5, 2023
1 parent 5c9ab39 commit 69a6e83
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import * as Wallet from '@src/api/wallet';
import * as Db from '@src/db';
import { ApiError } from '@src/api/errors';
import { closeDbConnection, getDbConnection, getUnixTimestamp, getWalletId } from '@src/utils';
import { STATUS_CODE_TABLE } from '@src/api/utils';
import { WalletStatus, FullNodeVersionData } from '@src/types';
import { walletUtils, constants, network, HathorWalletServiceWallet } from '@hathor/wallet-lib';
import bitcore from 'bitcore-lib';
Expand Down Expand Up @@ -166,6 +167,17 @@ test('GET /addresses', async () => {
transactions: addresses[1].transactions,
});

// we should error on invalid index parameter
event = makeGatewayEventWithAuthorizer('my-wallet', {
index: '-50',
});
result = await addressesGet(event, null, null) as APIGatewayProxyResult;
returnBody = JSON.parse(result.body as string);

expect(result.statusCode).toBe(STATUS_CODE_TABLE[ApiError.INVALID_PAYLOAD]);
expect(returnBody.details).toHaveLength(1);
expect(returnBody.details[0].message).toMatchInlineSnapshot(`"\\"index\\" must be greater than or equal to 0"`);

// we should be able to filter for a specific index
event = makeGatewayEventWithAuthorizer('my-wallet', {
index: String(addresses[0].index),
Expand Down

0 comments on commit 69a6e83

Please sign in to comment.