Skip to content

Commit

Permalink
cosmwasm: accounting: change str.try_into().unwrap() to str.into() be…
Browse files Browse the repository at this point in the history
…cause conversion is infallible… (#3623)

Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
  • Loading branch information
bingyuyap authored Jan 3, 2024
1 parent 8b39c1a commit 738a68a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions cosmwasm/contracts/global-accountant/tests/modify_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn simple_modify() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

let resp = contract.modify_balance(m.clone(), &wh).unwrap();
Expand Down Expand Up @@ -61,7 +61,7 @@ fn duplicate_modify() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

contract.modify_balance(m.clone(), &wh).unwrap();
Expand All @@ -86,7 +86,7 @@ fn round_trip() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

contract.modify_balance(m.clone(), &wh).unwrap();
Expand All @@ -97,7 +97,7 @@ fn round_trip() {
// Now reverse the modification.
m.sequence += 1;
m.kind = Kind::Sub;
m.reason = "reverse".try_into().unwrap();
m.reason = "reverse".into();

contract.modify_balance(m.clone(), &wh).unwrap();

Expand Down Expand Up @@ -125,7 +125,7 @@ fn missing_guardian_set() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

let err = contract
Expand Down Expand Up @@ -156,7 +156,7 @@ fn expired_guardian_set() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};
let err = contract
.modify_balance(m, &wh)
Expand All @@ -178,7 +178,7 @@ fn no_quorum() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

let newlen = wh
Expand Down Expand Up @@ -211,7 +211,7 @@ fn repeat() {
token_address: [0x7c; 32].into(),
kind: Kind::Add,
amount: Uint256::from(300u128),
reason: "test".try_into().unwrap(),
reason: "test".into(),
};

for _ in 0..ITERATIONS {
Expand Down
4 changes: 2 additions & 2 deletions cosmwasm/contracts/global-accountant/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn create_accounts(wh: &fake::WormholeKeeper, contract: &mut Contract, count: us
token_address: [i as u8; 32].into(),
kind: Kind::Add,
amount: Uint256::from(j as u128),
reason: "create_accounts".try_into().unwrap(),
reason: "create_accounts".into(),
};

contract.modify_balance(m, wh).unwrap();
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn create_modifications(
token_address: [i as u8; 32].into(),
kind: Kind::Add,
amount: Uint256::from(i as u128),
reason: format!("{i}").as_str().try_into().unwrap(),
reason: format!("{i}").as_str().into(),
};

contract.modify_balance(m.clone(), wh).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ fn missing_native_account() {
token_address: token_address.into(),
kind: Kind::Add,
amount: Uint256::new(amount.0),
reason: "fake wrapped balance for testing".try_into().unwrap(),
reason: "fake wrapped balance for testing".into(),
};
contract.modify_balance(m, &wh).unwrap();

Expand Down Expand Up @@ -657,7 +657,7 @@ fn wrapped_to_wrapped() {
token_address: token_address.into(),
kind: Kind::Add,
amount: Uint256::new(amount.0),
reason: "fake wrapped balance for testing".try_into().unwrap(),
reason: "fake wrapped balance for testing".into(),
};
contract.modify_balance(m, &wh).unwrap();

Expand Down

0 comments on commit 738a68a

Please sign in to comment.