Skip to content

Commit

Permalink
update tokens and collections tests + added bob address in config
Browse files Browse the repository at this point in the history
  • Loading branch information
cfaur09 committed Dec 2, 2024
1 parent a29e5f2 commit 8b3384b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/test/chain-simulator/collections.cs-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { fundAddress, issueMultipleNftsCollections } from './utils/chain.simulat
describe('Collections e2e tests with chain simulator', () => {
beforeAll(async () => {
await ChainSimulatorUtils.waitForEpoch(2);

await fundAddress(config.chainSimulatorUrl, config.aliceAddress);
await issueMultipleNftsCollections(config.chainSimulatorUrl, config.aliceAddress, 2);
await new Promise((resolve) => setTimeout(resolve, 5000));
Expand Down
1 change: 1 addition & 0 deletions src/test/chain-simulator/config/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CHAIN_SIMULATOR_URL=http://localhost:8085
API_SERVICE_URL=http://localhost:3001
ALICE_ADDRESS=erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th
BOB_ADDRESS=erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx
1 change: 1 addition & 0 deletions src/test/chain-simulator/config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const config = {
chainSimulatorUrl: process.env.CHAIN_SIMULATOR_URL || 'http://localhost:8085',
apiServiceUrl: process.env.API_SERVICE_URL || 'http://localhost:3001',
aliceAddress: process.env.ALICE_ADDRESS || 'erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th',
bobAddress: process.env.BOB_ADDRESS || 'erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx',
};
20 changes: 7 additions & 13 deletions src/test/chain-simulator/tokens.cs-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ import { config } from './config/env.config';
import { ChainSimulatorUtils } from './utils/test.utils';
import { fundAddress, issueMultipleEsdts } from './utils/chain.simulator.operations';

const ALICE_ADDRESS =
'erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th';
const BOB_ADDRESS =
'erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx';

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

// Fund Alice's address
await fundAddress(config.chainSimulatorUrl, ALICE_ADDRESS);

// Issue multiple ESDT tokens
await issueMultipleEsdts(config.chainSimulatorUrl, ALICE_ADDRESS, 5);
await fundAddress(config.chainSimulatorUrl, config.aliceAddress);
await issueMultipleEsdts(config.chainSimulatorUrl, config.aliceAddress, 5);
await new Promise((resolve) => setTimeout(resolve, 20000));
});

Expand Down Expand Up @@ -259,7 +253,7 @@ describe('Tokens e2e tests with chain simulator', () => {
`${config.apiServiceUrl}/tokens?size=1`,
);
const response = await axios.get(
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/roles/${ALICE_ADDRESS}`,
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/roles/${config.aliceAddress}`,
);
const roles = response.data;
expect(response.status).toBe(200);
Expand All @@ -271,7 +265,7 @@ describe('Tokens e2e tests with chain simulator', () => {
const nonExistentTokenIdentifier = 'NON_EXISTENT_TOKEN';
try {
await axios.get(
`${config.apiServiceUrl}/tokens/${nonExistentTokenIdentifier}/roles/${ALICE_ADDRESS}`,
`${config.apiServiceUrl}/tokens/${nonExistentTokenIdentifier}/roles/${config.aliceAddress}`,
);
} catch (error: any) {
expect(error.response.status).toBe(400);
Expand Down Expand Up @@ -311,12 +305,12 @@ describe('Tokens e2e tests with chain simulator', () => {
`${config.apiServiceUrl}/tokens?size=1`,
);
const response = await axios.get(
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/transfers?receiver=${ALICE_ADDRESS}`,
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/transfers?receiver=${config.aliceAddress}`,
);
const transfers = response.data;
expect(response.status).toBe(200);
for (const transfer of transfers) {
expect(transfer.receiver).toBe(ALICE_ADDRESS);
expect(transfer.receiver).toBe(config.aliceAddress);
}
});

Expand Down Expand Up @@ -408,7 +402,7 @@ describe('Tokens e2e tests with chain simulator', () => {
`${config.apiServiceUrl}/tokens?size=1`,
);
const response = await axios.get(
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/transfers/count?receiver=${ALICE_ADDRESS}`,
`${config.apiServiceUrl}/tokens/${tokensResponse.data[0].identifier}/transfers/count?receiver=${config.aliceAddress}`,
);
const count = response.data;
expect(response.status).toBe(200);
Expand Down

0 comments on commit 8b3384b

Please sign in to comment.