diff --git a/contracts/burner/src/contract.rs b/contracts/burner/src/contract.rs index d6a96a0e08..06332db0d7 100644 --- a/contracts/burner/src/contract.rs +++ b/contracts/burner/src/contract.rs @@ -127,7 +127,7 @@ mod tests { let res = migrate(deps.as_mut(), mock_env(), msg).unwrap(); // check payout assert_eq!(1, res.messages.len()); - let msg = res.messages.get(0).expect("no message"); + let msg = res.messages.first().expect("no message"); assert_eq!( msg, &SubMsg::new(BankMsg::Send { diff --git a/contracts/burner/tests/integration.rs b/contracts/burner/tests/integration.rs index c783a6fa3c..a72a3f6fb2 100644 --- a/contracts/burner/tests/integration.rs +++ b/contracts/burner/tests/integration.rs @@ -67,7 +67,7 @@ fn migrate_sends_funds() { let res: Response = migrate(&mut deps, mock_env(), msg).unwrap(); // check payout assert_eq!(1, res.messages.len()); - let msg = res.messages.get(0).expect("no message"); + let msg = res.messages.first().expect("no message"); assert_eq!( msg, &SubMsg::new(BankMsg::Send { diff --git a/contracts/hackatom/src/contract.rs b/contracts/hackatom/src/contract.rs index f62ffcb319..a78c21db37 100644 --- a/contracts/hackatom/src/contract.rs +++ b/contracts/hackatom/src/contract.rs @@ -416,7 +416,7 @@ mod tests { }; let res = sudo(deps.as_mut(), mock_env(), sys_msg).unwrap(); assert_eq!(1, res.messages.len()); - let msg = res.messages.get(0).expect("no message"); + let msg = res.messages.first().expect("no message"); assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount })); } @@ -466,7 +466,7 @@ mod tests { ) .unwrap(); assert_eq!(execute_res.messages.len(), 1); - let msg = execute_res.messages.get(0).expect("no message"); + let msg = execute_res.messages.first().expect("no message"); assert_eq!( msg, &SubMsg::new(BankMsg::Send { diff --git a/contracts/hackatom/tests/integration.rs b/contracts/hackatom/tests/integration.rs index 890309ffd6..6d16eeeef8 100644 --- a/contracts/hackatom/tests/integration.rs +++ b/contracts/hackatom/tests/integration.rs @@ -170,7 +170,7 @@ fn sudo_can_steal_tokens() { }; let res: Response = sudo(&mut deps, mock_env(), sys_msg).unwrap(); assert_eq!(1, res.messages.len()); - let msg = res.messages.get(0).expect("no message"); + let msg = res.messages.first().expect("no message"); assert_eq!(msg, &SubMsg::new(BankMsg::Send { to_address, amount })); } @@ -237,7 +237,7 @@ fn execute_release_works() { let execute_res: Response = execute(&mut deps, mock_env(), execute_info, ExecuteMsg::Release {}).unwrap(); assert_eq!(execute_res.messages.len(), 1); - let msg = execute_res.messages.get(0).expect("no message"); + let msg = execute_res.messages.first().expect("no message"); assert_eq!( msg, &SubMsg::new(BankMsg::Send { diff --git a/contracts/staking/src/contract.rs b/contracts/staking/src/contract.rs index 72b20818e6..88fe864157 100644 --- a/contracts/staking/src/contract.rs +++ b/contracts/staking/src/contract.rs @@ -322,13 +322,14 @@ pub fn _bond_all_tokens( // we deduct pending claims from our account balance before reinvesting. // if there is not enough funds, we just return a no-op - match update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { + let updated = update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { balance.amount = balance.amount.checked_sub(supply.claims)?; // this just triggers the "no op" case if we don't have min_withdrawal left to reinvest balance.amount.checked_sub(invest.min_withdrawal)?; supply.bonded += balance.amount; Ok(supply) - }) { + }); + match updated { Ok(_) => {} // if it is below the minimum, we do a no-op (do not revert other state from withdrawal) Err(StdError::Overflow { .. }) => return Ok(Response::default()), diff --git a/packages/std/src/errors/std_error.rs b/packages/std/src/errors/std_error.rs index 60a8a8dc0a..b8293e3f28 100644 --- a/packages/std/src/errors/std_error.rs +++ b/packages/std/src/errors/std_error.rs @@ -877,8 +877,8 @@ mod tests { #[test] fn from_std_str_utf8error_works() { - let broken = b"Hello \xF0\x90\x80World"; - let error: StdError = str::from_utf8(broken).unwrap_err().into(); + let broken = Vec::from(b"Hello \xF0\x90\x80World" as &[u8]); + let error: StdError = str::from_utf8(&broken).unwrap_err().into(); match error { StdError::InvalidUtf8 { msg, .. } => { assert_eq!(msg, "invalid utf-8 sequence of 3 bytes from index 6") diff --git a/packages/std/src/testing/assertions.rs b/packages/std/src/testing/assertions.rs index d6ffecff0d..694c71752f 100644 --- a/packages/std/src/testing/assertions.rs +++ b/packages/std/src/testing/assertions.rs @@ -169,6 +169,7 @@ mod tests { )] fn assert_approx_with_custom_panic_msg() { let adjective = "extra"; + #[allow(dead_code)] #[derive(Debug)] struct Foo(u32); assert_approx_eq!( diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 6686ce070b..0a14b24acc 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -469,6 +469,7 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult let mut file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(filepath) .map_err(|e| VmError::cache_err(format!("Error opening Wasm file for writing: {e}")))?; file.write_all(wasm)