From 7195f59f9503da24e13f24868699b2f23b6efe2b Mon Sep 17 00:00:00 2001 From: Yevhen_H <33688931+SoA432@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:27:09 +0200 Subject: [PATCH] Firehose and substream endpoints tests for testnets,cl and evms (#24) * Firehose and substream endpoints tests for testnets,cl and evms * updated excluded chains for tests --- scripts/known-issues-chains.js | 13 ++++- scripts/run-grpcurl-firehose.js | 86 ++++++++++++++++++++--------- scripts/run-grpcurl-substreams.js | 89 +++++++++++++++++++++---------- 3 files changed, 135 insertions(+), 53 deletions(-) diff --git a/scripts/known-issues-chains.js b/scripts/known-issues-chains.js index 89decbc..8fed733 100644 --- a/scripts/known-issues-chains.js +++ b/scripts/known-issues-chains.js @@ -1,7 +1,18 @@ const affectedChains = [ { id: 'cosmoshub', - affected_services: ['firehose'], + affected_services: ['firehose', 'substreams'], + standard: 'cosmos', + }, + { + id: 'theta', + affected_services: ['firehose', 'substreams'], + standard: 'cosmos', + }, + { + id: 'osmosis', + affected_services: ['firehose', 'substreams'], + standard: 'cosmos', }, ]; diff --git a/scripts/run-grpcurl-firehose.js b/scripts/run-grpcurl-firehose.js index 129ddc4..2ec45ca 100644 --- a/scripts/run-grpcurl-firehose.js +++ b/scripts/run-grpcurl-firehose.js @@ -3,9 +3,7 @@ const path = require('path'); const { exec } = require('child_process'); const { affectedChains } = require('./known-issues-chains'); const filePath = path.resolve(__dirname, '../data/chains/V2/chains.json'); -const chains = JSON.parse( - fs.readFileSync(filePath, 'utf8'), -); +const chains = JSON.parse(fs.readFileSync(filePath, 'utf8')); function runGrpcurl(chainId, serviceName) { return new Promise((resolve, reject) => { @@ -14,14 +12,14 @@ function runGrpcurl(chainId, serviceName) { exec(command, (error, stdout, stderr) => { if (error) { - console.error(`Error: ${error.message}`); + console.error(`❌ Error: ${error.message}`); reject(new Error(`Command failed: ${command}`)); return; } if (stderr) { console.error(`Stderr: ${stderr}`); } - console.log(`Response: ${stdout}`); + console.log(`✅ Response: ${stdout}`); resolve(`Success: ${command}`); }); }); @@ -29,37 +27,75 @@ function runGrpcurl(chainId, serviceName) { async function run() { try { - for (const chain of chains) { - const firehoseService = chain.supported_services.firehose; + for (const [chainIndex, chain] of chains.entries()) { + const firehoseMainnetService = chain.supported_services.firehose; - if ( - affectedChains.some( - (affectedChain) => - affectedChain.id === chain.id && - affectedChain.affected_services.includes('firehose'), - ) - ) { + const testnets = chain?.testnets || []; + const consensus = chain?.consensus || []; + const evms = chain?.evms || []; + + console.log( + `⏳ Running grpcurl for mainnet ==${chain.id}== (${chainIndex + 1} / ${chains?.length})`, + ); + await runTest(chain, firehoseMainnetService); + + for (const [index, testnet] of testnets.entries()) { console.log( - `${chain.id} is affected by known issues. Endpoint: ${chain.id}.firehose.pinax.network`, + `⏳ Running grpcurl for testnets ==${testnet.id}== (${index + 1} / ${testnets?.length})`, ); - return; + const firehoseService = testnet.supported_services.firehose; + await runTest(testnet, firehoseService); } - if ( - firehoseService && - firehoseService.deprecated_at === null && - (firehoseService.beta_released_at || firehoseService.full_released_at) - ) { + + for (const [index, cons] of consensus.entries()) { console.log( - `Running grpcurl for substreams service on chain ${chain.id}`, + `⏳ Running grpcurl for consensus-layers ==${cons.id}== (${index + 1} / ${consensus?.length})`, ); - await runGrpcurl(chain.id, 'firehose'); + const firehoseService = cons.supported_services.firehose; + await runTest(cons, firehoseService); + } + + for (const [index, evm] of evms.entries()) { + console.log( + `⏳ Running grpcurl for EVMs ==${evm.id}== (${index + 1} / ${evms?.length})`, + ); + const firehoseService = evm.supported_services.firehose; + await runTest(evm, firehoseService); } } - console.log('All grpcurl commands executed successfully.'); + console.log('✅✅✅ All grpcurl commands executed successfully.'); } catch (error) { - console.error('Error during grpcurl execution:', error.message); + console.error('❌❌❌ Error during grpcurl execution:', error.message); process.exit(1); } } +const runTest = async (chain, service) => { + if ( + affectedChains.some( + (affectedChain) => + affectedChain.id === chain.id && + affectedChain.affected_services.includes('firehose'), + ) + ) { + console.log( + `🟡🟡🟡 ${chain.id} is affected by known issues. Endpoint: ${chain.id}.substreams.pinax.network`, + ); + return; + } + + if ( + service && + service.deprecated_at === null && + (service.beta_released_at || service.full_released_at) + ) { + console.log( + `⏳⏳⏳ Running grpcurl for substreams service on chain ${chain.id}`, + ); + return await runGrpcurl(chain.id, 'firehose'); + } + + console.log(`⚪️⚪️⚪️ ${chain.id} is deprecated or not released yet.`); +}; + run(); diff --git a/scripts/run-grpcurl-substreams.js b/scripts/run-grpcurl-substreams.js index 975da11..f1c78f9 100644 --- a/scripts/run-grpcurl-substreams.js +++ b/scripts/run-grpcurl-substreams.js @@ -3,24 +3,23 @@ const path = require('path'); const { exec } = require('child_process'); const { affectedChains } = require('./known-issues-chains'); const filePath = path.resolve(__dirname, '../data/chains/V2/chains.json'); -const chains = JSON.parse( - fs.readFileSync(filePath, 'utf8'), -); +const chains = JSON.parse(fs.readFileSync(filePath, 'utf8')); + function runGrpcurl(chainId, serviceName) { return new Promise((resolve, reject) => { const command = `grpcurl ${chainId}.${serviceName}.pinax.network:443 sf.${serviceName}.rpc.v2.EndpointInfo/Info`; - console.log(`Executing: ${command}`); + console.log(`⏳ Executing: ${command}`); exec(command, (error, stdout, stderr) => { if (error) { - console.error(`Error: ${error.message}`); + console.error(`❌ Error: ${error.message}`); reject(new Error(`Command failed: ${command}`)); return; } if (stderr) { console.error(`Stderr: ${stderr}`); } - console.log(`Response: ${stdout}`); + console.log(`✅ Response: ${stdout}`); resolve(`Success: ${command}`); }); }); @@ -28,39 +27,75 @@ function runGrpcurl(chainId, serviceName) { async function run() { try { - for (const chain of chains) { - const substreamsService = chain.supported_services.substreams; + for (const [chainIndex, chain] of chains.entries()) { + const substreamsMainnetService = chain.supported_services.substreams; + + const testnets = chain?.testnets || []; + const consensus = chain?.consensus || []; + const evms = chain?.evms || []; - if ( - affectedChains.some( - (affectedChain) => - affectedChain.id === chain.id && - affectedChain.affected_services.includes('substreams'), - ) - ) { + console.log( + `⏳ Running grpcurl for mainnet ==${chain.id}== (${chainIndex + 1} / ${chains?.length})`, + ); + await runTest(chain, substreamsMainnetService); + + for (const [index, testnet] of testnets.entries()) { console.log( - `${chain.id} is affected by known issues. Endpoint: ${chain.id}.substreams.pinax.network`, + `⏳ Running grpcurl for testnets ==${testnet.id}== (${index + 1} / ${testnets?.length})`, ); - return; + const substreamsService = testnet.supported_services.substreams; + await runTest(testnet, substreamsService); } - if ( - substreamsService && - substreamsService.deprecated_at === null && - (substreamsService.beta_released_at || - substreamsService.full_released_at) - ) { + for (const [index, cons] of consensus.entries()) { console.log( - `Running grpcurl for substreams service on chain ${chain.id}`, + `⏳ Running grpcurl for consensus-layers ==${cons.id}== (${index + 1} / ${consensus?.length})`, ); - await runGrpcurl(chain.id, 'substreams'); + const substreamsService = cons.supported_services.substreams; + await runTest(cons, substreamsService); + } + + for (const [index, evm] of evms.entries()) { + console.log( + `⏳ Running grpcurl for EVMs ==${evm.id}== (${index + 1} / ${evms?.length})`, + ); + const substreamsService = evm.supported_services.substreams; + await runTest(evm, substreamsService); } } - console.log('All grpcurl commands executed successfully.'); + console.log('✅✅✅ All grpcurl commands executed successfully.'); } catch (error) { - console.error('Error during grpcurl execution:', error.message); + console.error('❌❌❌ Error during grpcurl execution:', error.message); process.exit(1); } } +const runTest = async (chain, service) => { + if ( + affectedChains.some( + (affectedChain) => + affectedChain.id === chain.id && + affectedChain.affected_services.includes('substreams'), + ) + ) { + console.log( + `🟡🟡🟡 ${chain.id} is affected by known issues. Endpoint: ${chain.id}.substreams.pinax.network`, + ); + return; + } + + if ( + service && + service.deprecated_at === null && + (service.beta_released_at || service.full_released_at) + ) { + console.log( + `⏳⏳⏳ Running grpcurl for substreams service on chain ${chain.id}`, + ); + return await runGrpcurl(chain.id, 'substreams'); + } + + console.log(`⚪️⚪️⚪️ ${chain.id} is deprecated or not released yet.`); +}; + run();