@@ -20,6 +20,7 @@ import 'mocha';
2020const nock = require ( 'nock' ) ;
2121import { GasPriceOracle } from '../GasPriceOracle' ;
2222import { AbstractEthereumService } from "../eth/AbstractEthereumService" ;
23+ import { LoomHooks } from "../eth/LoomHooks" ;
2324
2425export const GasPriceOracleTests = async function ( ) {
2526
@@ -32,74 +33,79 @@ export const GasPriceOracleTests = async function() {
3233 expect ( gpo . gasPrice ) . toEqual ( ethereumService . unitToWei ( 20 , 'gwei' ) ) ;
3334 } ) ;
3435
35- it ( `can get price from Provider in gwei` , async ( ) => {
36- const gpo : GasPriceOracle = GasPriceOracle . Instance ;
37-
38- // @ts -ignore
39- let providerPrice = await gpo . getProviderOracleGasPrice ( ) ;
40-
41- // geth-poa image always generates 18 gwei
42- expect ( providerPrice ) . toEqual ( 18 ) ;
43- } ) ;
44-
45- it ( `can get price from EthGasStation` , async ( ) => {
46- const gpo : GasPriceOracle = GasPriceOracle . Instance ;
47-
48- nock ( 'https://ethgasstation.info' )
49- . get ( '/json/ethgasAPI.json' )
50- . times ( 3 )
51- . reply ( 200 , {
52- fast : 500 ,
53- fastest : 600 ,
54- average : 400 ,
55- safeLow : 300 ,
56- safeLowWait : 2.0 ,
57- avgWait : 1.5 ,
58- fastWait : 1.0 ,
59- fastestWait : 0.5
60- } ) ;
61-
62- // @ts -ignore
63- let ethGasStationPrice = await gpo . getEthGasStationBestPrice ( ) ;
64-
65- // Based on DESIRED_WAIT_TIME of 2 minutes, this should pick safeLow
66- expect ( ethGasStationPrice . price ) . toEqual ( 30 ) ;
67- } ) ;
68-
69- it ( `can get default price from EthGasStation if no desired time match` , async ( ) => {
70- const gpo : GasPriceOracle = GasPriceOracle . Instance ;
71-
72- nock ( 'https://ethgasstation.info' )
73- . get ( '/json/ethgasAPI.json' )
74- . times ( 3 )
75- . reply ( 200 , {
76- fast : 500 ,
77- fastest : 600 ,
78- average : 400 ,
79- safeLow : 300 ,
80- safeLowWait : 10.0 ,
81- avgWait : 10.0 ,
82- fastWait : 10.0 ,
83- fastestWait : 10.0
84- } ) ;
85-
86- // @ts -ignore
87- let ethGasStationPrice = await gpo . getEthGasStationBestPrice ( ) ;
88-
89- // Based on DESIRED_WAIT_TIME of 2 minutes, this should default to fastest
90- expect ( ethGasStationPrice . price ) . toEqual ( 60 ) ;
91- } ) ;
92-
93- it ( `returns only Provider price when not in PROD` , async ( ) => {
94- const gpo : GasPriceOracle = GasPriceOracle . Instance ;
95-
96- // @ts -ignore
97- await gpo . calculateGasPrice ( ) ;
98-
99- // @ts -ignore
100- const ethereumService : AbstractEthereumService = gpo . ethereumService ;
101-
102- expect ( gpo . gasPrice ) . toEqual ( ethereumService . unitToWei ( 18 , 'gwei' ) ) ;
103- } ) ;
104-
105- } ;
36+ if ( LoomHooks . enabled ) {
37+ console . log ( '\n\nSKIPPING - GasPriceOracleTests test because Loom does not have gas\n' ) ;
38+ } else {
39+
40+ it ( `can get price from Provider in gwei` , async ( ) => {
41+ const gpo : GasPriceOracle = GasPriceOracle . Instance ;
42+
43+ // @ts -ignore
44+ let providerPrice = await gpo . getProviderOracleGasPrice ( ) ;
45+
46+ // geth-poa image always generates 18 gwei
47+ expect ( providerPrice ) . toEqual ( 18 ) ;
48+ } ) ;
49+
50+ it ( `can get price from EthGasStation` , async ( ) => {
51+ const gpo : GasPriceOracle = GasPriceOracle . Instance ;
52+
53+ nock ( 'https://ethgasstation.info' )
54+ . get ( '/json/ethgasAPI.json' )
55+ . times ( 3 )
56+ . reply ( 200 , {
57+ fast : 500 ,
58+ fastest : 600 ,
59+ average : 400 ,
60+ safeLow : 300 ,
61+ safeLowWait : 2.0 ,
62+ avgWait : 1.5 ,
63+ fastWait : 1.0 ,
64+ fastestWait : 0.5
65+ } ) ;
66+
67+ // @ts -ignore
68+ let ethGasStationPrice = await gpo . getEthGasStationBestPrice ( ) ;
69+
70+ // Based on DESIRED_WAIT_TIME of 2 minutes, this should pick safeLow
71+ expect ( ethGasStationPrice . price ) . toEqual ( 30 ) ;
72+ } ) ;
73+
74+ it ( `can get default price from EthGasStation if no desired time match` , async ( ) => {
75+ const gpo : GasPriceOracle = GasPriceOracle . Instance ;
76+
77+ nock ( 'https://ethgasstation.info' )
78+ . get ( '/json/ethgasAPI.json' )
79+ . times ( 3 )
80+ . reply ( 200 , {
81+ fast : 500 ,
82+ fastest : 600 ,
83+ average : 400 ,
84+ safeLow : 300 ,
85+ safeLowWait : 10.0 ,
86+ avgWait : 10.0 ,
87+ fastWait : 10.0 ,
88+ fastestWait : 10.0
89+ } ) ;
90+
91+ // @ts -ignore
92+ let ethGasStationPrice = await gpo . getEthGasStationBestPrice ( ) ;
93+
94+ // Based on DESIRED_WAIT_TIME of 2 minutes, this should default to fastest
95+ expect ( ethGasStationPrice . price ) . toEqual ( 60 ) ;
96+ } ) ;
97+
98+ it ( `returns only Provider price when not in PROD` , async ( ) => {
99+ const gpo : GasPriceOracle = GasPriceOracle . Instance ;
100+
101+ // @ts -ignore
102+ await gpo . calculateGasPrice ( ) ;
103+
104+ // @ts -ignore
105+ const ethereumService : AbstractEthereumService = gpo . ethereumService ;
106+
107+ expect ( gpo . gasPrice ) . toEqual ( ethereumService . unitToWei ( 18 , 'gwei' ) ) ;
108+ } ) ;
109+ }
110+
111+ } ;
0 commit comments