@@ -60,16 +60,14 @@ async fn eth_to_fri_rate_uses_cache_on_quantized_hit() {
6060 let client = ExchangeRateOracleClient :: new ( config. clone ( ) ) ;
6161
6262 // First request should fail because the cache is empty.
63- assert ! ( client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
63+ assert ! ( client. fetch_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
6464 // Wait for the query to resolve.
65- while client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err ( ) {
65+ while client. fetch_rate ( TIMESTAMP1 ) . await . is_err ( ) {
6666 tokio:: task:: yield_now ( ) . await ; // Don't block the executor.
6767 }
68- let rate1 = client. eth_to_fri_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
69- let rate2 = client
70- . eth_to_fri_rate ( TIMESTAMP2 )
71- . await
72- . expect ( "Should resolve immediately due to the cache" ) ;
68+ let rate1 = client. fetch_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
69+ let rate2 =
70+ client. fetch_rate ( TIMESTAMP2 ) . await . expect ( "Should resolve immediately due to the cache" ) ;
7371 assert_eq ! ( rate1, rate2) ;
7472}
7573
@@ -134,28 +132,28 @@ async fn eth_to_fri_rate_uses_prev_cache_when_query_not_ready() {
134132 let client = ExchangeRateOracleClient :: new ( config. clone ( ) ) ;
135133
136134 // First request should fail because the cache is empty.
137- assert ! ( client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
135+ assert ! ( client. fetch_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
138136 // Wait for the query to resolve.
139- while client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err ( ) {
137+ while client. fetch_rate ( TIMESTAMP1 ) . await . is_err ( ) {
140138 tokio:: task:: yield_now ( ) . await ; // Don't block the executor.
141139 }
142- let rate1 = client. eth_to_fri_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
140+ let rate1 = client. fetch_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
143141 assert_eq ! ( rate1, EXPECTED_RATE ) ;
144142 // Second request should resolve immediately due to the cache.
145- let rate2 = client. eth_to_fri_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
143+ let rate2 = client. fetch_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
146144 assert_eq ! ( rate2, EXPECTED_RATE ) ;
147145
148146 // Wait for the query to resolve, and the price to be updated.
149147 for _ in 0 ..100 {
150- let current_rate = client. eth_to_fri_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
148+ let current_rate = client. fetch_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
151149 if current_rate > EXPECTED_RATE {
152150 break ;
153151 }
154152 tokio:: time:: sleep ( Duration :: from_millis ( 1 ) ) . await ;
155153 }
156154
157155 // Third request should already successfully get the query from the server.
158- let rate3 = client. eth_to_fri_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
156+ let rate3 = client. fetch_rate ( TIMESTAMP2 ) . await . unwrap ( ) ;
159157 assert_eq ! ( rate3, different_rate) ;
160158}
161159
@@ -194,22 +192,22 @@ async fn eth_to_fri_rate_two_urls() {
194192 } ;
195193 let client = ExchangeRateOracleClient :: new ( config. clone ( ) ) ;
196194 // First request should fail because the cache is empty.
197- assert ! ( client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
195+ assert ! ( client. fetch_rate ( TIMESTAMP1 ) . await . is_err( ) ) ;
198196 // Wait for the query to resolve.
199- while client. eth_to_fri_rate ( TIMESTAMP1 ) . await . is_err ( ) {
197+ while client. fetch_rate ( TIMESTAMP1 ) . await . is_err ( ) {
200198 tokio:: task:: yield_now ( ) . await ; // Don't block the executor.
201199 }
202- let rate1 = client. eth_to_fri_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
200+ let rate1 = client. fetch_rate ( TIMESTAMP1 ) . await . unwrap ( ) ;
203201 assert_eq ! ( rate1, EXPECTED_RATE ) ;
204202
205203 // Note this server fails on missing "decimals", not "price".
206204 let _mock_response3 =
207205 make_server ( & mut server2, json ! ( { "price" : & expected_rate_hex, "bar" : 18 } ) ) . await ;
208206 // First request should fail because the cache is empty.
209- assert ! ( client. eth_to_fri_rate ( TIMESTAMP2 ) . await . is_err( ) ) ;
207+ assert ! ( client. fetch_rate ( TIMESTAMP2 ) . await . is_err( ) ) ;
210208 // Wait for the query to resolve.
211209 loop {
212- match client. eth_to_fri_rate ( TIMESTAMP2 ) . await {
210+ match client. fetch_rate ( TIMESTAMP2 ) . await {
213211 Ok ( _) => panic ! ( "Both servers should be returning bad JSON!" ) ,
214212 Err ( ExchangeRateOracleClientError :: QueryNotReadyError ( _) ) => { }
215213 Err ( ExchangeRateOracleClientError :: AllUrlsFailedError ( _, index) ) => {
0 commit comments