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 @@ -22,13 +22,34 @@ describe('ChainlinkPlugin Tests', () => {
2222 let requestManagerSendSpy : jest . SpyInstance ;
2323
2424 beforeAll ( ( ) => {
25- web3Context = new Web3 ( 'https://rpc.ankr.com/eth' ) ;
25+ web3Context = new Web3 ( ) ;
2626 web3Context . registerPlugin ( new ChainlinkPlugin ( ) ) ;
2727 requestManagerSendSpy = jest . spyOn ( web3Context . chainlink . requestManager , 'send' ) ;
2828 } ) ;
2929
3030 it ( 'should call ChainlinkPlugin.getPrice with expected RPC object' , async ( ) => {
31- const result = await web3Context . chainlink . getPrice ( MainnetPriceFeeds . LinkEth ) ;
31+ const providers = [
32+ 'https://eth.public-rpc.com' ,
33+ 'https://nodes.mewapi.io/rpc/eth' ,
34+ 'https://ethereum.publicnode.com' ,
35+ 'https://rpc.ankr.com/eth' ,
36+ 'https://rpc.flashbots.net/' ,
37+ ] ;
38+ let result : unknown ;
39+ let counter = 0 ;
40+ do {
41+ try {
42+ web3Context . setProvider ( providers [ counter ] ) ;
43+ // eslint-disable-next-line no-await-in-loop
44+ result = await web3Context . chainlink . getPrice ( MainnetPriceFeeds . LinkEth ) ;
45+ } catch ( error ) {
46+ counter += 1 ;
47+ }
48+ } while ( ! result && counter < providers . length ) ;
49+
50+ if ( ! result ) {
51+ throw new Error ( 'It seems all Providers endpoints, used for the test, had issues' ) ;
52+ }
3253 expect ( Object . keys ( result as object ) ) . toEqual (
3354 expect . arrayContaining ( [
3455 'roundId' ,
Original file line number Diff line number Diff line change @@ -21,13 +21,34 @@ describe('ChainlinkPlugin Tests', () => {
2121 let requestManagerSendSpy : jest . SpyInstance ;
2222
2323 beforeAll ( ( ) => {
24- web3Context = new Web3 ( 'https://rpc.ankr.com/eth' ) ;
24+ web3Context = new Web3 ( ) ;
2525 web3Context . registerPlugin ( new ChainlinkPlugin ( ) ) ;
2626 requestManagerSendSpy = jest . spyOn ( web3Context . chainlink . requestManager , 'send' ) ;
2727 } ) ;
2828
2929 it ( 'should call ChainlinkPlugin.getPrice with expected RPC object' , async ( ) => {
30- const result = await web3Context . chainlink . getPrice ( MainnetPriceFeeds . LinkEth ) ;
30+ const providers = [
31+ 'https://eth.public-rpc.com' ,
32+ 'https://nodes.mewapi.io/rpc/eth' ,
33+ 'https://ethereum.publicnode.com' ,
34+ 'https://rpc.ankr.com/eth' ,
35+ 'https://rpc.flashbots.net/' ,
36+ ] ;
37+ let result : unknown ;
38+ let counter = 0 ;
39+ do {
40+ try {
41+ web3Context . setProvider ( providers [ counter ] ) ;
42+ // eslint-disable-next-line no-await-in-loop
43+ result = await web3Context . chainlink . getPrice ( MainnetPriceFeeds . LinkEth ) ;
44+ } catch ( error ) {
45+ counter += 1 ;
46+ }
47+ } while ( ! result && counter < providers . length ) ;
48+
49+ if ( ! result ) {
50+ throw new Error ( 'It seems all Providers endpoints, used for the test, had issues' ) ;
51+ }
3152 expect ( Object . keys ( result as object ) ) . toEqual (
3253 expect . arrayContaining ( [
3354 'roundId' ,
You can’t perform that action at this time.
0 commit comments