Skip to content

Commit

Permalink
feat: add test for contract address as module_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Sep 18, 2023
1 parent 990e637 commit c4aaba6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ describe('SRModulesOperatorsKeysController (e2e)', () => {
// Get all keys and operators without filters
const resp = await request(app.getHttpServer()).get(`/v1/modules/${dvtModule.id}/operators/keys`);

const respByContractAddress = await request(app.getHttpServer()).get(
`/v1/modules/${dvtModule.stakingModuleAddress}/operators/keys`,
);

expect(resp.body).toEqual(respByContractAddress.body);

expect(resp.status).toEqual(200);
expect(resp.body.data.operators).toEqual(expect.arrayContaining([operatorOneDvt, operatorTwoDvt]));
expect(resp.body.data.keys).toEqual(expect.arrayContaining(dvtModuleKeys));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ describe('SRModuleOperatorsController (e2e)', () => {
// Get all operators without filters
const resp = await request(app.getHttpServer()).get(`/v1/modules/${dvtModule.id}/operators`);

const respByContractAddress = await request(app.getHttpServer()).get(
`/v1/modules/${dvtModule.stakingModuleAddress}/operators`,
);

expect(resp.body).toEqual(respByContractAddress.body);

expect(resp.status).toEqual(200);
expect(resp.body.data.operators).toBeDefined();
expect(resp.body.data.operators).toEqual(expect.arrayContaining([operatorOneDvt, operatorTwoDvt]));
Expand Down
12 changes: 12 additions & 0 deletions src/http/sr-modules/sr-modules.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ describe('SRModulesController (e2e)', () => {
});
});

it('should return module by contract address', async () => {
const resp = await request(app.getHttpServer()).get(`/v1/modules/${dvtModule.stakingModuleAddress}`);
expect(resp.status).toEqual(200);
expect(resp.body.data).toEqual(dvtModuleResp);
expect(resp.body.elBlockSnapshot).toEqual({
blockNumber: elMeta.number,
blockHash: elMeta.hash,
timestamp: elMeta.timestamp,
});
});

it("should return 404 if module doesn't exist", async () => {
const resp = await request(app.getHttpServer()).get(`/v1/modules/77`);
expect(resp.status).toEqual(404);
Expand All @@ -189,6 +200,7 @@ describe('SRModulesController (e2e)', () => {
});
});
});

describe('too early response case', () => {
beforeEach(async () => {
await cleanDB();
Expand Down

0 comments on commit c4aaba6

Please sign in to comment.