-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API-72: first integration of chain simulator
- Loading branch information
1 parent
6a03f1f
commit 74c71ea
Showing
5 changed files
with
390 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Chain simulator e2e tests workflow | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
call-reusable-workflow: | ||
uses: multiversx/chain-simulator-reusable-workflow/.github/workflows/workflow.yml@v1 | ||
with: | ||
with_elastic: true # Enable Elasticsearch services | ||
with_notifier: false # Do not enable notifier services | ||
|
||
test-chainsimulator-e2e: | ||
runs-on: ubuntu-latest | ||
needs: call-reusable-workflow # Ensures this job waits for call-reusable-workflow | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Download Docker directory artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: docker | ||
path: docker/ | ||
|
||
- name: Start Chain simulator Docker containers | ||
run: | | ||
cd docker | ||
docker compose -f docker-compose.yml --profile elastic up -d | ||
# Step 1: Wait for services to be healthy | ||
- name: Wait for services to be ready | ||
run: | | ||
echo "Waiting for services to be healthy..." | ||
docker ps | ||
sleep 10 # Allow time for the containers to initialize | ||
docker logs chainsimulator | ||
sleep 20 # Wait for 20 seconds to ensure services are up | ||
# Step 2: Check chain-simulator API | ||
- name: Check chain-simulator API | ||
run: | | ||
curl http://localhost:8085/simulator/observers | ||
- name: Start API Docker containers | ||
run: | | ||
cd . | ||
docker compose up -d | ||
- name: Wait for API docker containers to start | ||
run: | | ||
sleep 20 | ||
docker ps | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Start API | ||
run: | | ||
npm run start:mainnet:e2e | ||
# Step 3: Set up Node.js environment | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- name: Run e2e tests | ||
run: npm run test:cs-e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,51 @@ network: 'mainnet' | |
metaChainShardId: 4294967295 | ||
api: | ||
public: true | ||
publicPort: 3001 | ||
private: true | ||
graphql: true | ||
privatePort: 4001 | ||
websocket: true | ||
cron: | ||
cacheWarmer: true | ||
fastWarm: false | ||
queueWorker: true | ||
elasticUpdater: false | ||
flags: | ||
useRequestCaching: true | ||
useKeepAliveAgent: true | ||
useTracing: false | ||
useRequestLogging: false | ||
useVmQueryTracing: false | ||
processNfts: true | ||
collectionPropertiesFromGateway: false | ||
features: | ||
eventsNotifier: | ||
enabled: false | ||
port: 5674 | ||
url: 'amqp://guest:[email protected]:5672' | ||
exchange: 'all_events' | ||
queue: 'api-process-logs-and-events' | ||
guestCaching: | ||
enabled: false | ||
hitsThreshold: 100 | ||
ttl: 12 | ||
transactionPool: | ||
enabled: false | ||
transactionPoolWarmer: | ||
enabled: false | ||
cronExpression: '*/5 * * * * *' | ||
ttlInSeconds: 60 | ||
updateCollectionExtraDetails: | ||
enabled: false | ||
updateAccountExtraDetails: | ||
enabled: false | ||
transfersLast24hUrl: 'https://tools.multiversx.com/growth-api/explorer/widgets/most-used/applications' | ||
marketplace: | ||
enabled: false | ||
serviceUrl: 'https://nfts-graph.multiversx.com/graphql' | ||
exchange: | ||
enabled: false | ||
serviceUrl: 'https://graph.xexchange.com/graphql' | ||
dataApi: | ||
enabled: false | ||
serviceUrl: 'https://data-api.multiversx.com' | ||
|
@@ -13,35 +55,93 @@ features: | |
maxExpirySeconds: 86400 | ||
acceptedOrigins: | ||
- '' | ||
admins: | ||
- '' | ||
jwtSecret: '' | ||
stakingV4: | ||
enabled: false | ||
cronExpression: '*/5 * * * * *' | ||
activationEpoch: 1391 | ||
nodeEpochsLeft: | ||
enabled: false | ||
transactionProcessor: | ||
enabled: false | ||
maxLookBehind: 1000 | ||
transactionCompleted: | ||
enabled: false | ||
maxLookBehind: 1000 | ||
logLevel: 'Error' | ||
transactionBatch: | ||
enabled: false | ||
maxLookBehind: 1000 | ||
deepHistory: | ||
enabled: false | ||
url: '' | ||
cron: | ||
transactionProcessor: false | ||
transactionProcessorMaxLookBehind: 1000 | ||
cacheWarmer: false | ||
flags: | ||
useRequestCaching: true | ||
useKeepAliveAgent: true | ||
useTracing: false | ||
collectionPropertiesFromGateway: false | ||
statusChecker: | ||
enabled: false | ||
thresholds: | ||
tokens: 1000 | ||
nodes: 5000 | ||
providers: 150 | ||
tokenSupplyCount: 100 | ||
tokenAssets: 100 | ||
tokenAccounts: 1000 | ||
tokenTransactions: 1000 | ||
nodeValidators: 3260 | ||
nftScamInfo: | ||
enabled: false | ||
processNfts: | ||
enabled: false | ||
nftQueueName: 'api-process-nfts' | ||
deadLetterQueueName: 'api-process-nfts-dlq' | ||
tps: | ||
enabled: false | ||
maxLookBehindNonces: 100 | ||
nodesFetch: | ||
enabled: false | ||
serviceUrl: 'https://api.multiversx.com' | ||
tokensFetch: | ||
enabled: false | ||
serviceUrl: 'https://api.multiversx.com' | ||
providersFetch: | ||
enabled: false | ||
serviceUrl: 'https://api.multiversx.com' | ||
assetsFetch: | ||
enabled: false | ||
assetesUrl: 'https://tools.multiversx.com/assets-cdn' | ||
image: | ||
width: 600 | ||
height: 600 | ||
type: 'png' | ||
aws: | ||
s3KeyId: '' | ||
s3Secret: '' | ||
s3Bucket: 'media.elrond.com' | ||
s3Region: '' | ||
urls: | ||
self: 'https://api.multiversx.com' | ||
self: 'http://localhost:3001' | ||
elastic: | ||
- 'https://index.multiversx.com' | ||
- 'http://localhost:9200' | ||
gateway: | ||
- 'https://gateway.multiversx.com' | ||
- 'http://localhost:8085' | ||
verifier: 'https://play-api.multiversx.com' | ||
redis: '127.0.0.1' | ||
rabbitmq: 'amqp://127.0.0.1:5672' | ||
providers: 'https://internal-delegation-api.multiversx.com/providers' | ||
providers: 'https://delegation-api.multiversx.com/providers' | ||
delegation: 'https://delegation-api.multiversx.com' | ||
media: 'https://media.elrond.com' | ||
nftThumbnails: 'https://media.elrond.com/nfts/thumbnail' | ||
tmp: '/tmp' | ||
ipfs: 'https://ipfs.io/ipfs' | ||
socket: 'socket-api-fra.multiversx.com' | ||
maiarId: 'https://id-api.multiversx.com' | ||
indexer: | ||
type: 'elastic' | ||
maxPagination: 10000 | ||
database: | ||
enabled: false | ||
url: 'mongodb://127.0.0.1:27017/api?authSource=admin' | ||
type: 'mysql' | ||
host: 'localhost' | ||
port: 3306 | ||
username: 'root' | ||
|
@@ -50,7 +150,8 @@ database: | |
caching: | ||
cacheTtl: 6 | ||
processTtl: 600 | ||
poolLimit: 10 | ||
poolLimit: 50 | ||
cacheDuration: 3 | ||
keepAliveTimeout: | ||
downstream: 61000 | ||
upstream: 60000 | ||
|
@@ -69,14 +170,6 @@ inflation: | |
- 1130177 | ||
- 924690 | ||
- 719203 | ||
security: | ||
admins: | ||
jwtSecret: | ||
test: | ||
mockKeybases: false | ||
mockNodes: false | ||
mockTokens: false | ||
mockPath: './src/test/mocks/' | ||
transaction-action: | ||
mex: | ||
microServiceUrl: 'https://graph.xexchange.com/graphql' | ||
nftProcess: | ||
parallelism: 1 | ||
maxRetries: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from "axios"; | ||
import { fundAddress } from "./chain.simulator.operations"; | ||
|
||
const CHAIN_SIMULATOR_URL = 'http://localhost:8085'; | ||
//const ELASTIC_SEARCH_URL = 'http://localhost:9200'; | ||
const API_SERVICE_URL = 'http://localhost:3001'; | ||
const ALICE_ADDRESS = 'erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th'; | ||
|
||
describe('EventProcessor e2e tests with chain simulator', () => { | ||
beforeAll(async () => { | ||
try { | ||
const response = await axios.get(`${CHAIN_SIMULATOR_URL}/simulator/observers`); | ||
|
||
let numRetries = 0; | ||
while (true) { | ||
if (response.status === 200) { | ||
await axios.post(`${CHAIN_SIMULATOR_URL}/simulator/generate-blocks-until-epoch-reached/2`, {}); | ||
break; | ||
} | ||
|
||
numRetries += 1; | ||
if (numRetries > 50) { | ||
fail("Chain simulator not started!"); | ||
} | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('accounts endpoint should work', async () => { | ||
await fundAddress(CHAIN_SIMULATOR_URL, ALICE_ADDRESS); | ||
const csResponse = await axios.get(`${CHAIN_SIMULATOR_URL}/address/${ALICE_ADDRESS}`); | ||
console.log(csResponse); | ||
|
||
const apiServiceResponse = await axios.get(`${API_SERVICE_URL}/accounts/${ALICE_ADDRESS}`); | ||
console.log(apiServiceResponse); | ||
|
||
}, 100000); | ||
}); |
Oops, something went wrong.