Skip to content

Commit

Permalink
feat: small fixed in SRModulesLeysController and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Sep 18, 2023
1 parent 6c82b4a commit 758a2d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 14 additions & 1 deletion src/http/sr-modules-keys/sr-modules-keys.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { Controller, Get, Version, Param, Query, Body, Post, NotFoundException, HttpStatus, Res } from '@nestjs/common';
import {
Controller,
Get,
Version,
Param,
Query,
Body,
Post,
NotFoundException,
HttpStatus,
Res,
HttpCode,
} from '@nestjs/common';
import { ApiNotFoundResponse, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
import { SRModuleKeyListResponse, GroupedByModuleKeyListResponse } from './entities';
import { SRModulesKeysService } from './sr-modules-keys.service';
Expand Down Expand Up @@ -86,6 +98,7 @@ export class SRModulesKeysController {

@Version('1')
@Post(':module_id/keys/find')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Get list of found staking router module keys in db from pubkey list.' })
@ApiResponse({
status: 200,
Expand Down
12 changes: 5 additions & 7 deletions src/http/sr-modules-keys/sr-modules-keys.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ describe('SRModulesKeysController (e2e)', () => {
});

it('Should return all keys for request without filters', async () => {
// Get all keys and operators without filters
const resp = await request(app.getHttpServer()).get(`/v1/modules/${dvtModule.id}/keys`);

expect(resp.status).toEqual(200);
Expand Down Expand Up @@ -179,7 +178,7 @@ describe('SRModulesKeysController (e2e)', () => {
});
});

it('Should return unused keys and operator one', async () => {
it('Should return unused keys for operator one', async () => {
const resp = await request(app.getHttpServer())
.get(`/v1/modules/${dvtModule.id}/keys`)
.query({ used: false, operatorIndex: 1 });
Expand Down Expand Up @@ -271,13 +270,13 @@ describe('SRModulesKeysController (e2e)', () => {

it('Should return all keys that satisfy the request', async () => {
const pubkeys = [dvtModuleKeys[0].key, dvtModuleKeys[1].key];
// Get all keys and operators without filters

const resp = await request(app.getHttpServer())
.post(`/v1/modules/${dvtModule.id}/keys/find`)
.set('Content-Type', 'application/json')
.send({ pubkeys });

expect(resp.status).toEqual(201);
expect(resp.status).toEqual(200);
expect(resp.body.data.keys).toEqual(expect.arrayContaining(dvtModuleKeys));
expect(resp.body.data.module).toEqual(dvtModuleResp);
expect(resp.body.meta).toEqual({
Expand All @@ -298,7 +297,7 @@ describe('SRModulesKeysController (e2e)', () => {
.set('Content-Type', 'application/json')
.send({ pubkeys });

expect(resp.status).toEqual(201);
expect(resp.status).toEqual(200);
expect(resp.body.data.keys).toEqual([]);
expect(resp.body.data.module).toEqual(dvtModuleResp);
expect(resp.body.meta).toEqual({
Expand Down Expand Up @@ -362,7 +361,6 @@ describe('SRModulesKeysController (e2e)', () => {
});

it('Should return all keys for request without filters', async () => {
// Get all keys and operators without filters
const resp = await request(app.getHttpServer()).get(`/v1/modules/keys`);

expect(resp.status).toEqual(200);
Expand Down Expand Up @@ -440,7 +438,7 @@ describe('SRModulesKeysController (e2e)', () => {
});
});

it('Should return empty keys and operators lists for non-existent operator', async () => {
it('Should return empty keys lists for non-existent operator', async () => {
const resp = await request(app.getHttpServer()).get(`/v1/modules/keys`).query({ operatorIndex: 777 });

expect(resp.status).toEqual(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ describe('SRModulesOperatorsKeysController (e2e)', () => {
});

it('should return all keys for request without filters', async () => {
// Get all keys and operators without filters
const resp = await request(app.getHttpServer()).get(`/v1/modules/${dvtModule.id}/operators/keys`);

expect(resp.status).toEqual(200);
Expand Down

0 comments on commit 758a2d2

Please sign in to comment.