Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/chain simulator e2e #1402

Draft
wants to merge 57 commits into
base: development
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
74c71ea
API-72: first integration of chain simulator
bogdan-rosianu Nov 14, 2024
f6638e9
API-72: npm init
bogdan-rosianu Nov 14, 2024
1aaeeac
API-72: refactoring
bogdan-rosianu Nov 14, 2024
7bd5b43
API-72: fix workflow file + cs start script
bogdan-rosianu Nov 14, 2024
7e105f4
API-72: fix workflow file
bogdan-rosianu Nov 14, 2024
ccc4712
API-72: update chain simulator tests and configuration
cfaur09 Nov 14, 2024
2cc680f
Enhance e2e test workflow: add API startup delay and shutdown step; i…
cfaur09 Nov 14, 2024
ed50e0f
Replace accounts e2e tests with new blocks e2e tests for improved cov…
cfaur09 Nov 15, 2024
4672d97
Update blocks e2e test to filter by nonce 0 for accurate count valida…
cfaur09 Nov 15, 2024
b6ad48a
Update blocks e2e test to adjust epoch filter and add validation for …
cfaur09 Nov 15, 2024
2dee24d
Add e2e test for GET /blocks/latest endpoint with property and type v…
cfaur09 Nov 15, 2024
58b9539
Add e2e test for blocks count with high epoch and nonce values
cfaur09 Nov 15, 2024
b211e0b
Remove scheduledRootHash from expected properties and type validation…
cfaur09 Nov 15, 2024
38083fb
Add e2e tests for GET /blocks and GET /miniblocks endpoints with stat…
cfaur09 Nov 15, 2024
e5258e4
Add e2e tests for GET /miniblocks endpoint with pagination and type f…
cfaur09 Nov 15, 2024
9554a75
Add e2e tests for GET /rounds
cfaur09 Nov 15, 2024
7672364
small refactoring
cfaur09 Nov 15, 2024
1d0494d
small refactoring
cfaur09 Nov 15, 2024
09362f1
small refactoring_2
cfaur09 Nov 15, 2024
d511195
small refactoring_2
cfaur09 Nov 15, 2024
44d34c0
update file formatting
cfaur09 Nov 15, 2024
b8bf473
Create results.cs-e2e.ts
cfaur09 Nov 15, 2024
fa18b04
Update results.cs-e2e.ts
cfaur09 Nov 16, 2024
6b64688
Update results.cs-e2e.ts
cfaur09 Nov 16, 2024
874aa18
Add issueMultipleESDT + tokens.cs-e2e.ts
cfaur09 Nov 16, 2024
fce09a0
Update tokens.cs-e2e.ts
cfaur09 Nov 16, 2024
db89051
Update tokens.cs-e2e.ts
cfaur09 Nov 16, 2024
cd618d2
Update tokens.cs-e2e.ts
cfaur09 Nov 17, 2024
f7b19d8
Update tokens.cs-e2e.ts
cfaur09 Nov 17, 2024
dfc65cf
add EOL
cfaur09 Nov 20, 2024
540331f
add stop-chain-simulator script
cfaur09 Nov 20, 2024
bf46995
Merge branch 'development' into API-72-first-integration-of-cs-in-api…
cfaur09 Dec 2, 2024
768cb95
refactorin + adding utils checks
cfaur09 Dec 2, 2024
d185d50
move chain simulator operations into utils
cfaur09 Dec 2, 2024
a29e5f2
add issueMultipleNftsCollections + env Alice Address
cfaur09 Dec 2, 2024
8b3384b
update tokens and collections tests + added bob address in config
cfaur09 Dec 2, 2024
cd3eddb
Update collections.cs-e2e.ts
cfaur09 Dec 2, 2024
41e7039
update docker file + overridable-config
cfaur09 Dec 3, 2024
41c5aa5
revert chainsimulator image
cfaur09 Dec 3, 2024
f604ab9
update chainsimulator image
cfaur09 Dec 3, 2024
de7a2ca
fixes after review
cfaur09 Dec 3, 2024
91290e3
Update .gitignore
cfaur09 Dec 3, 2024
4b591c7
Merge pull request #1381 from multiversx/API-72-first-integration-of-…
bogdan-rosianu Dec 3, 2024
be170eb
Create stake.cs-e2e.ts (#1407)
cfaur09 Dec 3, 2024
1a73328
Create hello.cs-e2e.ts (#1405)
cfaur09 Dec 3, 2024
09c552e
Create delegation.cs-e2e.ts (#1403)
cfaur09 Dec 3, 2024
b729244
Create delegation-legacy.cs-e2e.ts (#1404)
cfaur09 Dec 3, 2024
428c2d6
Create accounts.cs-e2e.ts (#1409)
cfaur09 Dec 4, 2024
3660954
API-160: tx pool endpoint tests + new cs image (#1408)
bogdan-rosianu Dec 5, 2024
fc6a1f5
Create dapp.config.cs-e2e.ts (#1412)
cfaur09 Dec 5, 2024
5707d61
Create shards.cs-e2e.ts (#1406)
cfaur09 Dec 5, 2024
4a5e3dc
Update accounts.cs-e2e.ts (#1410)
cfaur09 Dec 10, 2024
b95b2e8
Create events.cs-e2e.ts (#1413)
cfaur09 Dec 10, 2024
1d99b54
Create identities.cs-e2e.ts (#1411)
cfaur09 Dec 12, 2024
3edb5bb
Create websocket-config.cs-e2e.ts (#1415)
cfaur09 Dec 12, 2024
adeeb5a
Merge branch 'refs/heads/development' into merge-development-feat-cs-…
bogdan-rosianu Dec 12, 2024
642aa7f
Merge pull request #1423 from multiversx/merge-development-feat-cs-e2…
bogdan-rosianu Dec 12, 2024
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
Prev Previous commit
Next Next commit
Create events.cs-e2e.ts (#1413)
* Create events.cs-e2e.ts

* Update events.cs-e2e.ts

* fixes after review

* Update events.cs-e2e.ts
cfaur09 authored Dec 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit b95b2e8110669622968d76730ae0570a8118a714
118 changes: 118 additions & 0 deletions src/test/chain-simulator/events.cs-e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { config } from "./config/env.config";
import { ChainSimulatorUtils } from "./utils/test.utils";
import axios from "axios";

describe('Events e2e tests with chain simulator', () => {
beforeAll(async () => {
await ChainSimulatorUtils.waitForEpoch(2);
});

describe('GET /events', () => {
it('should return status code 200 and a list of events', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
});

it('should support pagination', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events?from=0&size=2`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
expect(response.data.length).toStrictEqual(2);
});

it('should return different results for different from/size parameters', async () => {
const firstSet = await axios.get(`${config.apiServiceUrl}/events?from=0&size=2`);
const secondSet = await axios.get(`${config.apiServiceUrl}/events?from=1&size=2`);

expect(firstSet.status).toBe(200);
expect(secondSet.status).toBe(200);

expect(firstSet.data).not.toEqual(secondSet.data);
expect(firstSet.data[1]).toEqual(secondSet.data[0]);
});

it('should return events with expected properties', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events`);
const event = response.data[0];
expect(response.status).toBe(200);

const requiredProps = [
'txHash',
'logAddress',
'identifier',
'address',
'topics',
'shardID',
'txOrder',
'order',
'timestamp',
];

for (const prop of requiredProps) {
expect(event).toHaveProperty(prop);
}

expect(event.topics).toBeInstanceOf(Array);
});

it('should support filtering by address', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events?address=${config.aliceAddress}`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
expect(response.data.length).toBeGreaterThan(1);
expect(response.data[0].address).toBe(config.aliceAddress);
});

it('should support filtering by identifier', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events?identifier=completedTxEvent`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
expect(response.data.length).toBeGreaterThan(1);
expect(response.data[0].identifier).toBe('completedTxEvent');
});

// TODO: fix this
it.skip('should support filtering by txHash', async () => {
const events = await axios.get(`${config.apiServiceUrl}/events`);
const txHash = events.data[0].txHash;
const response = await axios.get(`${config.apiServiceUrl}/events?txHash=${txHash}`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
expect(response.data.length).toBeGreaterThan(1);
});

it('should support filtering by shard', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events?shard=0`);
expect(response.status).toBe(200);
expect(response.data).toBeInstanceOf(Array);
expect(response.data.length).toBeGreaterThan(1);
});
});

describe('GET /events/count', () => {
it('should return status code 200 and the number of events', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events/count`);
expect(response.status).toBe(200);
expect(typeof response.data).toBe('number');
});

it('should return the number of events with the given address', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events/count?address=${config.aliceAddress}`);
expect(response.status).toBe(200);
expect(response.data).toBeGreaterThan(1);
});

it('should return the number of events with the given identifier', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events/count?identifier=completedTxEvent`);
expect(response.status).toBe(200);
expect(response.data).toBeGreaterThan(1);
});

it('should return the number of events with the given shard', async () => {
const response = await axios.get(`${config.apiServiceUrl}/events/count?shard=0`);
expect(response.status).toBe(200);
expect(response.data).toBeGreaterThan(1);
});
});
});