Skip to content

Commit

Permalink
Firehose and substream endpoints tests for testnets,cl and evms (#24)
Browse files Browse the repository at this point in the history
* Firehose and substream endpoints tests for testnets,cl and evms

* updated excluded chains for tests
  • Loading branch information
SoA432 authored Sep 18, 2024
1 parent d844de9 commit 7195f59
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 53 deletions.
13 changes: 12 additions & 1 deletion scripts/known-issues-chains.js
Original file line number Diff line number Diff line change
@@ -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',
},
];

Expand Down
86 changes: 61 additions & 25 deletions scripts/run-grpcurl-firehose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -14,52 +12,90 @@ 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}`);
});
});
}

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();
89 changes: 62 additions & 27 deletions scripts/run-grpcurl-substreams.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,99 @@ 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}`);
});
});
}

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();

0 comments on commit 7195f59

Please sign in to comment.