File tree Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,34 @@ describe('ChainlinkPlugin Tests', () => {
2424 let requestManagerSendSpy : jest . SpyInstance ;
2525
2626 beforeAll ( ( ) => {
27- web3Context = new Web3 ( 'https://rpc.ankr.com/eth' ) ;
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' ,
Original file line number Diff line number Diff line change @@ -23,13 +23,34 @@ describe('ChainlinkPlugin Tests', () => {
2323 let requestManagerSendSpy : jest . SpyInstance ;
2424
2525 beforeAll ( ( ) => {
26- web3Context = new Web3 ( 'https://rpc.ankr.com/eth' ) ;
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' ,
You can’t perform that action at this time.
0 commit comments