From be170eb0aaa15f54c042a077c76cfdbac67843f5 Mon Sep 17 00:00:00 2001 From: Catalin Faur <52102171+cfaur09@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:33:51 +0200 Subject: [PATCH] Create stake.cs-e2e.ts (#1407) * Create stake.cs-e2e.ts * Update stake.cs-e2e.ts --- src/test/chain-simulator/stake.cs-e2e.ts | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/test/chain-simulator/stake.cs-e2e.ts diff --git a/src/test/chain-simulator/stake.cs-e2e.ts b/src/test/chain-simulator/stake.cs-e2e.ts new file mode 100644 index 000000000..b9cff75d4 --- /dev/null +++ b/src/test/chain-simulator/stake.cs-e2e.ts @@ -0,0 +1,52 @@ +import axios from "axios"; +import { config } from "./config/env.config"; +import { ChainSimulatorUtils } from "./utils/test.utils"; + +describe('Stake e2e tests with chain simulator', () => { + beforeAll(async () => { + await ChainSimulatorUtils.waitForEpoch(2); + }); + + describe('GET /stake', () => { + let stakeResponse: any; + + beforeEach(async () => { + stakeResponse = await axios.get(`${config.apiServiceUrl}/stake`); + }); + + it('should return status code 200 and a stake object', () => { + expect(stakeResponse.status).toBe(200); + expect(stakeResponse.data).toBeInstanceOf(Object); + }); + + it('should return the correct total number of validators', () => { + expect(stakeResponse.data.totalValidators).toBeGreaterThanOrEqual(0); + }); + + it('should return the correct number of active validators', () => { + expect(stakeResponse.data.activeValidators).toBeGreaterThanOrEqual(0); + }); + + it('should return the correct number of total observers', () => { + expect(stakeResponse.data.totalObservers).toBeGreaterThanOrEqual(0); + }); + + it('should return the correct queue size', () => { + expect(stakeResponse.data.queueSize).toBeGreaterThanOrEqual(0); + }); + + it('should return all expected properties in the response', () => { + const expectedProperties = [ + 'totalValidators', + 'activeValidators', + 'totalObservers', + 'queueSize', + 'totalStaked', + ]; + + for (const property of expectedProperties) { + expect(stakeResponse.data).toHaveProperty(property); + } + }); + }); +});