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

Test RPC default Providers Services #1061

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions __tests__/defaultNodes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Provider, constants } from '../src';

describe('Default RPC Nodes', () => {
test('Default lib configured version', async () => {
const result = await Promise.all(
Object.keys(constants.RPC_NODES).map(async (network: any) => {
return Promise.all(
constants.RPC_NODES[network as keyof typeof constants.RPC_NODES].map(async (it: any) => {
const provider = new Provider({ nodeUrl: it });
return {
network,
nodeUrl: provider.channel.nodeUrl,
version: await provider.getSpecVersion(),
};
})
);
})
);

console.table(result.flat());
});
test('Default RPC configured version on base route', async () => {
function getBaseUrl(url: string) {
const pathArray = url.split('/');
// Hotfix for juno but not generic
const net = pathArray[3].includes('juno') ? `${pathArray[3]}` : '';
return `${pathArray[0]}//${pathArray[2]}/${net}`;
}
const result = await Promise.all(
Object.keys(constants.RPC_NODES).map(async (network: any) => {
return Promise.all(
constants.RPC_NODES[network as keyof typeof constants.RPC_NODES].map(async (it: any) => {
const provider = new Provider({ nodeUrl: getBaseUrl(it) });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except for getBaseUrl(it) the test here and above are the same, so we can extract it maybe and send as param!

return {
network,
nodeUrl: provider.channel.nodeUrl,
version: await provider.getSpecVersion(),
};
})
);
})
);

console.table(result.flat());
});
});