From 18dcd3ef94eb110f5e1b0b332f1addfeedf9fe73 Mon Sep 17 00:00:00 2001 From: Toni Tabak Date: Wed, 3 Apr 2024 12:07:07 +0200 Subject: [PATCH] test: default node rpc versions --- __tests__/defaultNodes.test.ts | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 __tests__/defaultNodes.test.ts diff --git a/__tests__/defaultNodes.test.ts b/__tests__/defaultNodes.test.ts new file mode 100644 index 000000000..4c0cc3446 --- /dev/null +++ b/__tests__/defaultNodes.test.ts @@ -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) }); + return { + network, + nodeUrl: provider.channel.nodeUrl, + version: await provider.getSpecVersion(), + }; + }) + ); + }) + ); + + console.table(result.flat()); + }); +});