Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
dfinity-ryancroote committed Jan 27, 2024
1 parent 5774a60 commit d5bd285
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/monitor-canister/src/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ mod test {
xrc.calls
.read()
.map(|calls| {
let call = calls.get(0).expect("there should be 1 call");
let call = calls.first().expect("there should be 1 call");
assert_eq!(call.base_asset, request.base_asset);
assert_eq!(call.quote_asset, request.quote_asset);
assert_eq!(call.timestamp, request.timestamp);
Expand Down Expand Up @@ -398,7 +398,7 @@ mod test {
xrc.calls
.read()
.map(|calls| {
let call = calls.get(0).expect("there should be 1 call");
let call = calls.first().expect("there should be 1 call");
assert_eq!(call.base_asset, request.base_asset);
assert_eq!(call.quote_asset, request.quote_asset);
assert_eq!(call.timestamp, request.timestamp);
Expand Down Expand Up @@ -484,7 +484,7 @@ mod test {
xrc.calls
.read()
.map(|calls| {
let call = calls.get(0).expect("there should be 1 call");
let call = calls.first().expect("there should be 1 call");
assert_eq!(call.base_asset, request.base_asset);
assert_eq!(call.quote_asset, request.quote_asset);
assert_eq!(call.timestamp, request.timestamp);
Expand Down
14 changes: 7 additions & 7 deletions src/xrc/src/api/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn get_exchange_rate_will_not_charge_cycles_if_caller_is_privileged() {
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
assert_eq!(
call_exchanges_impl
.get_cryptocurrency_usdt_rate_calls
Expand Down Expand Up @@ -312,7 +312,7 @@ fn get_exchange_rate_will_charge_cycles() {
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
assert_eq!(
call_exchanges_impl
.get_cryptocurrency_usdt_rate_calls
Expand Down Expand Up @@ -351,7 +351,7 @@ fn get_exchange_rate_will_charge_the_base_cost_worth_of_cycles() {
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
assert_eq!(
call_exchanges_impl
.get_cryptocurrency_usdt_rate_calls
Expand Down Expand Up @@ -391,7 +391,7 @@ fn get_exchange_rate_will_charge_the_base_cost_plus_outbound_cycles_worth_of_cyc
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
assert_eq!(
call_exchanges_impl
.get_cryptocurrency_usdt_rate_calls
Expand Down Expand Up @@ -927,7 +927,7 @@ fn get_exchange_rate_will_retrieve_rates_if_inflight_tracking_does_not_contain_s
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
}

/// This function tests that [get_exchange_rate] charges the maximum fee for usage when the request
Expand Down Expand Up @@ -1051,7 +1051,7 @@ mod privileged_callers_can_bypass_pending {
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
}

/// This function tests that [get_exchange_rate] allows privileged callers to bypass the pending check (crypto-fiat pair).
Expand Down Expand Up @@ -1081,7 +1081,7 @@ mod privileged_callers_can_bypass_pending {
let result = get_exchange_rate_internal(&env, &call_exchanges_impl, &request)
.now_or_never()
.expect("future should complete");
assert!(matches!(result, Ok(_)));
assert!(result.is_ok());
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/xrc/src/exchanges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ impl IsExchange for KuCoin {
extract_rate(bytes, |response: KuCoinResponse| {
response
.data
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.1.clone()))
})
}
Expand Down Expand Up @@ -338,7 +338,7 @@ impl IsExchange for Okx {
extract_rate(bytes, |response: OkxResponse| {
response
.data
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.1.clone()))
})
}
Expand Down Expand Up @@ -372,7 +372,7 @@ impl IsExchange for GateIo {
fn extract_rate(&self, bytes: &[u8]) -> Result<u64, ExtractError> {
extract_rate(bytes, |response: GateIoResponse| {
response
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.3.clone()))
})
}
Expand All @@ -397,7 +397,7 @@ impl IsExchange for Mexc {
extract_rate(bytes, |response: MexcResponse| {
response
.data
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.1.clone()))
})
}
Expand Down Expand Up @@ -440,7 +440,7 @@ impl IsExchange for Poloniex {
fn extract_rate(&self, bytes: &[u8]) -> Result<u64, ExtractError> {
extract_rate(bytes, |response: PoloniexResponse| {
response
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.2.clone()))
})
}
Expand Down Expand Up @@ -485,7 +485,7 @@ impl IsExchange for CryptoCom {
response
.result
.data
.get(0)
.first()
.map(|kline| ExtractedValue::Str(kline.o.clone()))
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrc/src/forex/georgia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl IsForex for CentralBankOfGeorgia {
.map_err(|err| ExtractError::json_deserialize(bytes, err.to_string()))?;

let timestamp = (timestamp / ONE_DAY_SECONDS) * ONE_DAY_SECONDS;
let obj = response.get(0).ok_or(ExtractError::RateNotFound {
let obj = response.first().ok_or(ExtractError::RateNotFound {
filter: "Cannot find data for timestamp".to_string(),
})?;
let extracted_timestamp = NaiveDateTime::parse_from_str(&obj.date, "%Y-%m-%dT%H:%M:%S%.3fZ")
Expand Down
2 changes: 1 addition & 1 deletion src/xrc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ mod test {
a_b_rate.forex_timestamp = Some(1);
b_c_rate.forex_timestamp = Some(2);
let a_c_rate = a_b_rate * b_c_rate;
assert!(matches!(a_c_rate.forex_timestamp, None));
assert!(a_c_rate.forex_timestamp.is_none());
}

/// The function verifies that that [QueriedExchangeRate] structs are divided correctly.
Expand Down
8 changes: 4 additions & 4 deletions src/xrc/src/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl ForexSources for ForexSourcesImpl {
// Await all futures to complete
let joined = join_all(futures).await;
// Zip times and results
let results = times.into_iter().zip(joined.into_iter());
let results = times.into_iter().zip(joined);
let mut rates = vec![];
let mut errors = vec![];

Expand Down Expand Up @@ -402,7 +402,7 @@ mod test {

#[test]
fn check_forex_status_weekend() {
let forex = FOREX_SOURCES.get(0).expect("Myanmar expected"); // Myanmar
let forex = FOREX_SOURCES.first().expect("Myanmar expected"); // Myanmar
assert!(matches!(
check_forex_status(forex, 1680372000),
Err(ForexStatusError::Weekend)
Expand All @@ -412,7 +412,7 @@ mod test {
#[test]
fn check_forex_status_already_collected() {
let timestamp = 1680220800;
let forex = FOREX_SOURCES.get(0).expect("Myanmar expected"); // Myanmar
let forex = FOREX_SOURCES.first().expect("Myanmar expected"); // Myanmar
with_forex_rate_collector_mut(|collector| {
collector.update(
forex.to_string(),
Expand All @@ -429,7 +429,7 @@ mod test {
#[test]
fn check_forex_status_is_ok() {
let timestamp = 1680220800;
let forex = FOREX_SOURCES.get(0).expect("Myanmar expected"); // Myanmar
let forex = FOREX_SOURCES.first().expect("Myanmar expected"); // Myanmar
let result = check_forex_status(forex, timestamp);
assert!(matches!(result, Ok(())));
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrc/src/stablecoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) fn get_stablecoin_rate(
return Err(StablecoinRateError::TooFewRates(stablecoin_rates.len()));
}
let quote_asset = &stablecoin_rates
.get(0)
.first()
.expect("There should always be at least one rate")
.quote_asset;

Expand Down

0 comments on commit d5bd285

Please sign in to comment.