Skip to content

Commit

Permalink
chore: update Rust to 1.72 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 authored Jan 16, 2024
1 parent 510305b commit 82c4088
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ target/

# Ignore state machine binary
ic-test-state-machine

.vscode
19 changes: 14 additions & 5 deletions cycles-ledger/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ pub fn transfer(

// if `amount` + `fee` overflows then the user doesn't have enough funds
let Some(amount_with_fee) = amount.checked_add(config::FEE) else {
return Err(InsufficientFunds { balance: balance_of(&from).into() });
return Err(InsufficientFunds {
balance: balance_of(&from).into(),
});
};

// check allowance
Expand Down Expand Up @@ -1315,7 +1317,9 @@ pub fn validate_created_at_time(
created_at_time: &Option<u64>,
now: u64,
) -> Result<(), CreatedAtTimeValidationError> {
let Some(created_at_time) = created_at_time else { return Ok(())};
let Some(created_at_time) = created_at_time else {
return Ok(());
};
if created_at_time
.saturating_add(config::TRANSACTION_WINDOW.as_nanos() as u64)
.saturating_add(config::PERMITTED_DRIFT.as_nanos() as u64)
Expand Down Expand Up @@ -1414,7 +1418,9 @@ pub async fn send(

// if `amount` + `fee` overflows then the user doesn't have enough funds
let Some(amount_with_fee) = amount.checked_add(config::FEE) else {
return Err(InsufficientFunds { balance: balance_of(&from).into() });
return Err(InsufficientFunds {
balance: balance_of(&from).into(),
});
};

// check that the `from` account has enough funds
Expand Down Expand Up @@ -1521,7 +1527,9 @@ pub async fn create_canister(

// if `amount` + `fee` overflows then the user doesn't have enough funds
let Some(amount_with_fee) = amount.checked_add(config::FEE) else {
return Err(InsufficientFunds { balance: balance_of(&from).into() });
return Err(InsufficientFunds {
balance: balance_of(&from).into(),
});
};

// check that the `from` account has enough funds
Expand Down Expand Up @@ -1856,7 +1864,8 @@ fn prune_transactions(now: u64, s: &mut State, limit: usize) {
pruned += 1;

let Some(block) = s.blocks.get(block_idx) else {
log!(P0,
log!(
P0,
"Cannot find block with id: {}. The block id was associated \
with the timestamp: {} and was selected for pruning from \
the timestamp and hashes pools",
Expand Down
18 changes: 12 additions & 6 deletions cycles-ledger/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn new_state_machine() -> StateMachine {
let platform: &str = "darwin";
#[cfg(target_os = "linux")]
let platform: &str = "linux";
let suggested_ic_commit = "a17247bd86c7aa4e87742bf74d108614580f216d";
let suggested_ic_commit = "072b2a6586c409efa88f2244d658307ff3a645d8";

// not run automatically because parallel test execution screws this up
panic!("state machine binary does not exist. Please run the following command and try again: ./download-state-machine.sh {suggested_ic_commit} {platform}");
Expand Down Expand Up @@ -128,7 +128,10 @@ fn install_fake_cmc(env: &StateMachine) {
})
.unwrap(),
)
.unwrap() else {panic!("Failed to create CMC")};
.unwrap()
else {
panic!("Failed to create CMC")
};
let response = Decode!(&response, ProvisionalCreateResponse).unwrap();
assert_eq!(response.canister_id, CMC_PRINCIPAL);
env.add_cycles(CMC_PRINCIPAL, u128::MAX / 2);
Expand Down Expand Up @@ -1685,6 +1688,7 @@ fn test_icrc1_test_suite() {
assert_eq!(deposit_res.balance, 1_000_000_000_000_000_u128);
assert_eq!(1_000_000_000_000_000, balance_of(&env, ledger_id, user));

#[allow(clippy::arc_with_non_send_sync)]
let ledger_env =
icrc1_test_env_state_machine::SMLedger::new(Arc::new(env), ledger_id, user.owner);
let tests = icrc1_test_suite::test_suite(ledger_env)
Expand Down Expand Up @@ -2006,10 +2010,12 @@ fn test_create_canister() {
"No duplicate reported"
);
let CreateCanisterError::Duplicate {
canister_id: Some(duplicate_canister_id),
..
}
= duplicate else {panic!("No duplicate canister reported")};
canister_id: Some(duplicate_canister_id),
..
} = duplicate
else {
panic!("No duplicate canister reported")
};
assert_eq!(
canister, duplicate_canister_id,
"Different canister id returned"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.71.1"
channel = "1.72.0"
targets = ["wasm32-unknown-unknown"]
components = ["rustfmt", "clippy"]

0 comments on commit 82c4088

Please sign in to comment.