Bump Rust version to 1.50.0

This commit is contained in:
Michael Vines 2021-03-15 22:35:48 -07:00
parent ced24cb55a
commit af5fdb3146
9 changed files with 21 additions and 40 deletions

View File

@ -18,14 +18,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.49.0
stable_version=1.50.0
fi
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
# nightly 2021-01-13 fails due to https://github.com/rust-lang/rust/issues/80956
nightly_version=2021-01-12
nightly_version=2021-02-18
fi

View File

@ -75,14 +75,10 @@ impl PreciseNumber {
/// Convert a precise number back to u128
pub fn to_imprecise(&self) -> Option<u128> {
match self
.value
self.value
.checked_add(Self::rounding_correction())?
.checked_div(one())
{
Some(v) => Some(v.as_u128()),
None => None,
}
.map(|v| v.as_u128())
}
/// Checks that two PreciseNumbers are equal within some tolerance

View File

@ -66,8 +66,7 @@ pub mod tests {
#[test]
fn serialize_data() {
let mut expected = vec![];
expected.push(TEST_VERSION);
let mut expected = vec![TEST_VERSION];
expected.extend_from_slice(&TEST_PUBKEY.to_bytes());
expected.extend_from_slice(&TEST_DATA.bytes);
assert_eq!(TEST_RECORD_DATA.try_to_vec().unwrap(), expected);
@ -80,8 +79,7 @@ pub mod tests {
#[test]
fn deserialize_invalid_slice() {
let data = [200; Data::DATA_SIZE - 1];
let mut expected = vec![];
expected.push(TEST_VERSION);
let mut expected = vec![TEST_VERSION];
expected.extend_from_slice(&TEST_PUBKEY.to_bytes());
expected.extend_from_slice(&data);
let err: ProgramError = RecordData::try_from_slice(&expected).unwrap_err().into();

View File

@ -1414,8 +1414,8 @@ fn main() {
command_create_pool(
&config,
PoolFee {
numerator,
denominator,
numerator,
},
)
}

View File

@ -150,10 +150,10 @@ impl Obligation {
self.liquidate(decimal_repay_amount, collateral_withdraw_amount)?;
Ok(RepayResult {
decimal_repay_amount,
integer_repay_amount,
collateral_withdraw_amount,
obligation_token_amount,
decimal_repay_amount,
integer_repay_amount,
})
}
}
@ -329,11 +329,7 @@ mod test {
(deposited_collateral_tokens, obligation_tokens) in collateral_amounts(),
) {
let borrowed_liquidity_wads = Decimal::from_scaled_val(borrowed_liquidity);
let mut state = Obligation {
borrowed_liquidity_wads,
deposited_collateral_tokens,
..Obligation::default()
};
let mut state = Obligation { deposited_collateral_tokens, borrowed_liquidity_wads, ..Obligation::default() };
let repay_result = state.repay(liquidity_amount, obligation_tokens)?;
assert!(repay_result.decimal_repay_amount <= Decimal::from(repay_result.integer_repay_amount));
@ -354,11 +350,7 @@ mod test {
(deposited_collateral_tokens, obligation_tokens) in collateral_amounts(),
) {
let borrowed_liquidity_wads = Decimal::from_scaled_val(borrowed_liquidity);
let mut state = Obligation {
borrowed_liquidity_wads,
deposited_collateral_tokens,
..Obligation::default()
};
let mut state = Obligation { deposited_collateral_tokens, borrowed_liquidity_wads, ..Obligation::default() } ;
let repay_result = state.repay(liquidity_amount, obligation_tokens)?;
assert!(repay_result.decimal_repay_amount <= Decimal::from(repay_result.integer_repay_amount));
@ -376,11 +368,7 @@ mod test {
) {
let borrowed_liquidity_wads = Decimal::from(borrowed_liquidity);
let cumulative_borrow_rate_wads = Decimal::one().try_add(Decimal::from_scaled_val(current_borrow_rate))?;
let mut state = Obligation {
borrowed_liquidity_wads,
cumulative_borrow_rate_wads,
..Obligation::default()
};
let mut state = Obligation { cumulative_borrow_rate_wads, borrowed_liquidity_wads, ..Obligation::default() };
let next_cumulative_borrow_rate = Decimal::one().try_add(Decimal::from_scaled_val(new_borrow_rate))?;
state.accrue_interest(next_cumulative_borrow_rate)?;

View File

@ -172,8 +172,8 @@ impl Reserve {
Ok(LiquidateResult {
withdraw_amount,
repay_amount,
settle_amount,
repay_amount,
})
} else {
Err(LendingError::LiquidationTooSmall.into())
@ -918,13 +918,7 @@ mod test {
available_amount: total_liquidity - borrowed_amount_wads.try_round_u64()?,
..ReserveLiquidity::default()
},
config: ReserveConfig {
min_borrow_rate,
optimal_borrow_rate,
max_borrow_rate,
optimal_utilization_rate,
..ReserveConfig::default()
},
config: ReserveConfig { optimal_utilization_rate, min_borrow_rate, optimal_borrow_rate, max_borrow_rate, ..ReserveConfig::default() },
..Reserve::default()
};

View File

@ -1,6 +1,6 @@
#![allow(dead_code)]
use assert_matches::*;
use assert_matches::assert_matches;
use solana_program::{program_option::COption, program_pack::Pack, pubkey::Pubkey};
use solana_program_test::*;
use solana_sdk::{
@ -55,6 +55,7 @@ pub const SRM_USDC_BIDS: &str = "AuL9JzRJ55MdqzubK4EutJgAumtkuFcRVuPUvTX39pN8";
pub const SRM_USDC_ASKS: &str = "8Lx9U9wdE3afdqih1mCAXy3unJDfzSaXFqAvoLMjhwoD";
#[allow(non_camel_case_types)]
#[allow(clippy::upper_case_acronyms)]
pub enum TestDexMarketPair {
SRM_USDC,
SOL_USDC,

View File

@ -756,6 +756,8 @@ fn command_revoke(config: &Config, account: Pubkey, delegate: Option<Pubkey>) ->
.rpc_client
.get_token_account(&account)?
.ok_or_else(|| format!("Could not find token account {}", account))?;
#[allow(clippy::manual_map)]
if let Some(string) = source_account.delegate {
Some(Pubkey::from_str(&string)?)
} else {

View File

@ -159,6 +159,7 @@ impl Processor {
let source_account_info = next_account_info(account_info_iter)?;
#[allow(clippy::manual_map)]
let expected_mint_info = if let Some(expected_decimals) = expected_decimals {
Some((next_account_info(account_info_iter)?, expected_decimals))
} else {
@ -266,6 +267,8 @@ impl Processor {
let account_info_iter = &mut accounts.iter();
let source_account_info = next_account_info(account_info_iter)?;
#[allow(clippy::manual_map)]
let expected_mint_info = if let Some(expected_decimals) = expected_decimals {
Some((next_account_info(account_info_iter)?, expected_decimals))
} else {