Skip to content

Commit

Permalink
fix: clippy issues in omni-types
Browse files Browse the repository at this point in the history
  • Loading branch information
frolvanya committed Feb 1, 2025
1 parent 8f96e55 commit 5b46185
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions near/omni-types/src/evm/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};

use crate::utils::keccak256;

#[allow(clippy::module_name_repetitions)]
#[derive(Default, Debug, Clone)]
pub struct BlockHeader {
pub parent_hash: H256,
Expand Down
35 changes: 18 additions & 17 deletions near/omni-types/src/tests/lib_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn test_h160_serialization() {
);

assert_eq!(
format!(r#""{}""#, h160.to_string()),
format!(r#""{h160}""#),
serialized,
"Serialization does not preserve format from to_string()"
);
Expand Down Expand Up @@ -182,7 +182,7 @@ fn test_omni_address_from_evm_address() {
);

for chain_kind in [ChainKind::Near, ChainKind::Sol] {
let expected_error = format!("{:?} is not an EVM chain", chain_kind);
let expected_error = format!("{chain_kind:?} is not an EVM chain");
assert_eq!(
OmniAddress::new_from_evm_address(chain_kind, evm_address.clone()),
Err(expected_error)
Expand All @@ -195,7 +195,7 @@ fn test_omni_address_from_str() {
let evm_addr = "0x5a08feed678c056650b3eb4a5cb1b9bb6f0fe265";
let test_cases = vec![
(
format!("eth:{}", evm_addr),
format!("eth:{evm_addr}"),
Ok(OmniAddress::Eth(H160::from_str(evm_addr).unwrap())),
"Should parse ETH address",
),
Expand All @@ -212,12 +212,12 @@ fn test_omni_address_from_str() {
"Should parse SOL address",
),
(
format!("arb:{}", evm_addr),
format!("arb:{evm_addr}"),
Ok(OmniAddress::Arb(H160::from_str(evm_addr).unwrap())),
"Should parse ARB address",
),
(
format!("base:{}", evm_addr),
format!("base:{evm_addr}"),
Ok(OmniAddress::Base(H160::from_str(evm_addr).unwrap())),
"Should parse BASE address",
),
Expand All @@ -235,7 +235,7 @@ fn test_omni_address_from_str() {

for (input, expected, message) in test_cases {
let result = OmniAddress::from_str(&input);
assert_eq!(result, expected, "{}", message);
assert_eq!(result, expected, "{message}");
}
}

Expand All @@ -246,7 +246,7 @@ fn test_omni_address_display() {
let test_cases = vec![
(
OmniAddress::Eth(evm_addr.clone()),
format!("eth:{}", evm_addr),
format!("eth:{evm_addr}"),
"ETH address should format as eth:0x...",
),
(
Expand All @@ -261,18 +261,18 @@ fn test_omni_address_display() {
),
(
OmniAddress::Arb(evm_addr.clone()),
format!("arb:{}", evm_addr),
format!("arb:{evm_addr}"),
"ARB address should format as arb:0x...",
),
(
OmniAddress::Base(evm_addr.clone()),
format!("base:{}", evm_addr),
format!("base:{evm_addr}"),
"BASE address should format as base:0x...",
),
];

for (address, expected, message) in test_cases {
assert_eq!(address.to_string(), expected, "{}", message);
assert_eq!(address.to_string(), expected, "{message}");
}
}

Expand All @@ -285,7 +285,7 @@ fn test_omni_address_visitor_expecting() {

let result: Result<OmniAddress, _> = serde_json::from_value(serde_json::json!(invalid_value));
let error = result.unwrap_err().to_string();
assert_eq!(error, expected_error, "{}", message);
assert_eq!(error, expected_error, "{message}");
}

#[test]
Expand Down Expand Up @@ -326,7 +326,7 @@ fn test_fee_is_zero() {
];

for (fee, expected, message) in test_cases {
assert_eq!(fee.is_zero(), expected, "{}", message);
assert_eq!(fee.is_zero(), expected, "{message}");
}
}

Expand All @@ -344,7 +344,7 @@ fn test_transfer_message_getters() {
recipient: OmniAddress::Near("bob.near".parse().unwrap()),
fee: Fee::default(),
sender: OmniAddress::Eth(evm_addr.clone()),
msg: "".to_string(),
msg: String::new(),
},
ChainKind::Eth,
TransferId {
Expand All @@ -362,7 +362,7 @@ fn test_transfer_message_getters() {
recipient: OmniAddress::Eth(evm_addr.clone()),
fee: Fee::default(),
sender: OmniAddress::Near("alice.near".parse().unwrap()),
msg: "".to_string(),
msg: String::new(),
},
ChainKind::Near,
TransferId {
Expand All @@ -380,7 +380,7 @@ fn test_transfer_message_getters() {
recipient: OmniAddress::Near("carol.near".parse().unwrap()),
fee: Fee::default(),
sender: OmniAddress::Sol("11111111111111111111111111111111".parse().unwrap()),
msg: "".to_string(),
msg: String::new(),
},
ChainKind::Sol,
TransferId {
Expand All @@ -392,8 +392,8 @@ fn test_transfer_message_getters() {
];

for (message, expected_chain, expected_id, error_msg) in test_cases {
assert_eq!(message.get_origin_chain(), expected_chain, "{}", error_msg);
assert_eq!(message.get_transfer_id(), expected_id, "{}", error_msg);
assert_eq!(message.get_origin_chain(), expected_chain, "{error_msg}");
assert_eq!(message.get_transfer_id(), expected_id, "{error_msg}");
}
}

Expand All @@ -404,6 +404,7 @@ fn test_stringify() {
assert_eq!(stringify(true), "true", "Should stringify booleans");
assert_eq!(stringify('a'), "a", "Should stringify chars");

#[allow(clippy::items_after_statements)]
#[derive(Debug)]
struct CustomType(i32);
impl std::fmt::Display for CustomType {
Expand Down

0 comments on commit 5b46185

Please sign in to comment.