Skip to content

Commit 138958b

Browse files
update tests to try with multiple mainnet providers
1 parent f54c819 commit 138958b

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

cypress/plugins/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ const webpackOptions = require('../webpack.config.js');
2121
// eslint-disable-next-line no-unused-vars
2222
module.exports = (on, config) => {
2323
on('file:preprocessor', webpackPreprocessor({ webpackOptions }));
24-
2524
return config;
2625
};

test/black_box/test/chainlink_plugin.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ describe('ChainlinkPlugin Tests', () => {
2424
let requestManagerSendSpy: jest.SpyInstance;
2525

2626
beforeAll(() => {
27-
web3Context = new Web3('https://eth.public-rpc.com');
27+
web3Context = new Web3();
2828
web3Context.registerPlugin(new ChainlinkPlugin());
2929
requestManagerSendSpy = jest.spyOn(web3Context.chainlink.requestManager, 'send');
3030
});
3131

3232
it('should call ChainlinkPlugin.getPrice with expected RPC object', async () => {
33-
const result = await web3Context.chainlink.getPrice(MainnetPriceFeeds.LinkEth);
33+
const providers = [
34+
'https://eth.public-rpc.com',
35+
'https://nodes.mewapi.io/rpc/eth',
36+
'https://ethereum.publicnode.com',
37+
'https://rpc.ankr.com/eth',
38+
'https://rpc.flashbots.net/',
39+
];
40+
let result: unknown;
41+
let counter = 0;
42+
do {
43+
try {
44+
web3Context.setProvider(providers[counter]);
45+
// eslint-disable-next-line no-await-in-loop
46+
result = await web3Context.chainlink.getPrice(MainnetPriceFeeds.LinkEth);
47+
} catch (error) {
48+
counter += 1;
49+
}
50+
} while (!result && counter < providers.length);
51+
52+
if (!result) {
53+
throw new Error('It seems all Providers endpoints, used for the test, had issues');
54+
}
3455
expect(Object.keys(result as object)).toEqual(
3556
expect.arrayContaining([
3657
'roundId',

test/e2e/chainlink_plugin.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,34 @@ describe('ChainlinkPlugin Tests', () => {
2323
let requestManagerSendSpy: jest.SpyInstance;
2424

2525
beforeAll(() => {
26-
web3Context = new Web3('https://eth.public-rpc.com');
26+
web3Context = new Web3();
2727
web3Context.registerPlugin(new ChainlinkPlugin());
2828
requestManagerSendSpy = jest.spyOn(web3Context.chainlink.requestManager, 'send');
2929
});
3030

3131
it('should call ChainlinkPlugin.getPrice with expected RPC object', async () => {
32-
const result = await web3Context.chainlink.getPrice(MainnetPriceFeeds.LinkEth);
32+
const providers = [
33+
'https://eth.public-rpc.com',
34+
'https://nodes.mewapi.io/rpc/eth',
35+
'https://ethereum.publicnode.com',
36+
'https://rpc.ankr.com/eth',
37+
'https://rpc.flashbots.net/',
38+
];
39+
let result: unknown;
40+
let counter = 0;
41+
do {
42+
try {
43+
web3Context.setProvider(providers[counter]);
44+
// eslint-disable-next-line no-await-in-loop
45+
result = await web3Context.chainlink.getPrice(MainnetPriceFeeds.LinkEth);
46+
} catch (error) {
47+
counter += 1;
48+
}
49+
} while (!result && counter < providers.length);
50+
51+
if (!result) {
52+
throw new Error('It seems all Providers endpoints, used for the test, had issues');
53+
}
3354
expect(Object.keys(result as object)).toEqual(
3455
expect.arrayContaining([
3556
'roundId',

0 commit comments

Comments
 (0)