diff --git a/config/tests/mod.rs b/config/tests/mod.rs index 031e44470..8d67c14dd 100644 --- a/config/tests/mod.rs +++ b/config/tests/mod.rs @@ -19,7 +19,7 @@ fn read_fixture(name: &str) -> String { #[test] fn config_toml_parser() { let config_toml = read_fixture("config.toml"); - let config = TendermintConfig::parse_toml(&config_toml).unwrap(); + let config = TendermintConfig::parse_toml(config_toml).unwrap(); // main base config options @@ -206,7 +206,7 @@ fn config_toml_parser() { #[test] fn node_key_parser() { let raw_node_key = read_fixture("node_key.json"); - let node_key = NodeKey::parse_json(&raw_node_key).unwrap(); + let node_key = NodeKey::parse_json(raw_node_key).unwrap(); assert_eq!( node_key.node_id().to_string(), "1a7b6bcf3d6fb055ab3aebca415847531b626699" @@ -217,7 +217,7 @@ fn node_key_parser() { #[test] fn priv_validator_json_parser() { let raw_priv_validator_key = read_fixture("priv_validator_key.json"); - let priv_validator_key = PrivValidatorKey::parse_json(&raw_priv_validator_key).unwrap(); + let priv_validator_key = PrivValidatorKey::parse_json(raw_priv_validator_key).unwrap(); assert_eq!( priv_validator_key.consensus_pubkey().to_hex(), "F26BF4B2A2E84CEB7A53C3F1AE77408779B20064782FBADBDF0E365959EE4534" @@ -229,7 +229,7 @@ fn priv_validator_json_parser() { #[test] fn parsing_roundtrip() { let config_toml = read_fixture("config.toml"); - let config = TendermintConfig::parse_toml(&config_toml).unwrap(); + let config = TendermintConfig::parse_toml(config_toml).unwrap(); let written_config_toml = toml::to_string(&config).unwrap(); let written_config = TendermintConfig::parse_toml(&written_config_toml).unwrap(); diff --git a/light-client/src/builder/light_client.rs b/light-client/src/builder/light_client.rs index a428a5a2b..46b383c14 100644 --- a/light-client/src/builder/light_client.rs +++ b/light-client/src/builder/light_client.rs @@ -82,6 +82,7 @@ impl LightClientBuilder { options: Options, timeout: Option, ) -> Self { + #[allow(clippy::box_default)] Self::custom( peer_id, options, diff --git a/p2p/src/secret_connection.rs b/p2p/src/secret_connection.rs index 272219764..75d104e5f 100644 --- a/p2p/src/secret_connection.rs +++ b/p2p/src/secret_connection.rs @@ -648,7 +648,7 @@ fn read_and_decrypt( if chunk_length as usize > DATA_MAX_SIZE { return Err(io::Error::new( io::ErrorKind::Other, - format!("chunk is too big: {}! max: {}", chunk_length, DATA_MAX_SIZE), + format!("chunk is too big: {chunk_length}! max: {DATA_MAX_SIZE}"), )); } diff --git a/proto/src/serializers/bytes.rs b/proto/src/serializers/bytes.rs index d1c5c28dd..f27ce4c03 100644 --- a/proto/src/serializers/bytes.rs +++ b/proto/src/serializers/bytes.rs @@ -43,8 +43,8 @@ pub mod base64string { D: Deserializer<'de>, Vec: Into, { - let string = Option::::deserialize(deserializer)?.unwrap_or_default(); - let v = base64::decode(&string).map_err(serde::de::Error::custom)?; + let s = Option::::deserialize(deserializer)?.unwrap_or_default(); + let v = base64::decode(s).map_err(serde::de::Error::custom)?; Ok(v.into()) } @@ -54,7 +54,7 @@ pub mod base64string { D: Deserializer<'de>, { let s = Option::::deserialize(deserializer)?.unwrap_or_default(); - String::from_utf8(base64::decode(&s).map_err(serde::de::Error::custom)?) + String::from_utf8(base64::decode(s).map_err(serde::de::Error::custom)?) .map_err(serde::de::Error::custom) } @@ -85,7 +85,7 @@ pub mod vec_base64string { Option::>::deserialize(deserializer)? .unwrap_or_default() .into_iter() - .map(|s| base64::decode(&s).map_err(serde::de::Error::custom)) + .map(|s| base64::decode(s).map_err(serde::de::Error::custom)) .collect() } @@ -117,8 +117,8 @@ pub mod option_base64string { where D: Deserializer<'de>, { - let string = Option::::deserialize(deserializer)?.unwrap_or_default(); - base64::decode(&string).map_err(serde::de::Error::custom) + let s = Option::::deserialize(deserializer)?.unwrap_or_default(); + base64::decode(s).map_err(serde::de::Error::custom) } /// Serialize from `T` into `Option` diff --git a/proto/src/serializers/txs.rs b/proto/src/serializers/txs.rs index fb5d46f54..44594c743 100644 --- a/proto/src/serializers/txs.rs +++ b/proto/src/serializers/txs.rs @@ -19,7 +19,7 @@ where } value_vec_base64string .into_iter() - .map(|s| base64::decode(&s).map_err(serde::de::Error::custom)) + .map(|s| base64::decode(s).map_err(serde::de::Error::custom)) .collect() } diff --git a/rpc/src/client/transport/mock.rs b/rpc/src/client/transport/mock.rs index 6739b61d0..f9f3f6e64 100644 --- a/rpc/src/client/transport/mock.rs +++ b/rpc/src/client/transport/mock.rs @@ -267,7 +267,7 @@ mod test { } async fn read_event(name: &str) -> Event { - Event::from_string(&read_json_fixture(name).await).unwrap() + Event::from_string(read_json_fixture(name).await).unwrap() } mod v0_34 { diff --git a/rpc/src/client/transport/websocket.rs b/rpc/src/client/transport/websocket.rs index 217b17efb..26fc349db 100644 --- a/rpc/src/client/transport/websocket.rs +++ b/rpc/src/client/transport/websocket.rs @@ -1155,7 +1155,7 @@ mod test { } async fn read_event(name: &str) -> Event { - Event::from_string(&read_json_fixture(name).await).unwrap() + Event::from_string(read_json_fixture(name).await).unwrap() } #[tokio::test] diff --git a/rpc/src/serializers/tm_hash_base64.rs b/rpc/src/serializers/tm_hash_base64.rs index b8626a825..b57e33c3e 100644 --- a/rpc/src/serializers/tm_hash_base64.rs +++ b/rpc/src/serializers/tm_hash_base64.rs @@ -12,7 +12,7 @@ where D: Deserializer<'de>, { let s = Option::::deserialize(deserializer)?.unwrap_or_default(); - let decoded = base64::decode(&s).map_err(serde::de::Error::custom)?; + let decoded = base64::decode(s).map_err(serde::de::Error::custom)?; if decoded.len() != SHA256_HASH_SIZE { return Err(serde::de::Error::custom( "unexpected transaction length for hash", diff --git a/rpc/src/serializers/tx_hash_base64.rs b/rpc/src/serializers/tx_hash_base64.rs index feded9a5c..aa289fd07 100644 --- a/rpc/src/serializers/tx_hash_base64.rs +++ b/rpc/src/serializers/tx_hash_base64.rs @@ -12,7 +12,7 @@ where D: Deserializer<'de>, { let s = Option::::deserialize(deserializer)?.unwrap_or_default(); - let decoded = base64::decode(&s).map_err(serde::de::Error::custom)?; + let decoded = base64::decode(s).map_err(serde::de::Error::custom)?; let hash = Hash::from_bytes(Algorithm::Sha256, &decoded).map_err(serde::de::Error::custom)?; Ok(hash) } diff --git a/tendermint/src/abci.rs b/tendermint/src/abci.rs index 3fa4de415..72a179ff7 100644 --- a/tendermint/src/abci.rs +++ b/tendermint/src/abci.rs @@ -44,8 +44,8 @@ pub mod request; pub mod response; pub mod types; -// pub use crate::v0_37::abci::request::Request; -// pub use crate::v0_37::abci::response::Response; +pub use crate::v0_37::abci::request::Request; +pub use crate::v0_37::abci::response::Response; pub use event::{Event, EventAttribute, EventAttributeIndexExt}; diff --git a/tendermint/src/abci/doc/request-applysnapshotchunk.md b/tendermint/src/abci/doc/request-applysnapshotchunk.md index fe1c35598..d79d42e57 100644 --- a/tendermint/src/abci/doc/request-applysnapshotchunk.md +++ b/tendermint/src/abci/doc/request-applysnapshotchunk.md @@ -5,7 +5,7 @@ appropriate. Tendermint will not do this unless instructed by the application. The application may want to verify each chunk, e.g., by attaching chunk -hashes in [`Snapshot::metadata`] and/or incrementally verifying contents +hashes in `Snapshot::metadata` and/or incrementally verifying contents against `app_hash`. When all chunks have been accepted, Tendermint will make an ABCI [`Info`] @@ -18,4 +18,4 @@ because no suitable peers are available), it will reject the snapshot and try a different one via `OfferSnapshot`. The application should be prepared to reset and accept it or abort as appropriate. -[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#applysnapshotchunk) \ No newline at end of file +[ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#applysnapshotchunk) diff --git a/tendermint/src/abci/doc/request-offersnapshot.md b/tendermint/src/abci/doc/request-offersnapshot.md index db0e60b17..41303e0d9 100644 --- a/tendermint/src/abci/doc/request-offersnapshot.md +++ b/tendermint/src/abci/doc/request-offersnapshot.md @@ -13,8 +13,8 @@ additional verification schemes to avoid denial-of-service attacks. The verified `app_hash` is automatically checked against the restored application at the end of snapshot restoration. -See also the [`Snapshot`] data type and the [ABCI state sync documentation][ssd]. +See also the `Snapshot` data type and the [ABCI state sync documentation][ssd]. [ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#offersnapshot) -[ssd]: https://docs.tendermint.com/master/spec/abci/apps.html#state-sync \ No newline at end of file +[ssd]: https://docs.tendermint.com/master/spec/abci/apps.html#state-sync diff --git a/tendermint/src/abci/doc/response-offersnapshot.md b/tendermint/src/abci/doc/response-offersnapshot.md index 0da7a66fa..42f0d076c 100644 --- a/tendermint/src/abci/doc/response-offersnapshot.md +++ b/tendermint/src/abci/doc/response-offersnapshot.md @@ -1,7 +1,7 @@ Returns the application's response to a snapshot offer. -See also the [`Snapshot`] data type and the [ABCI state sync documentation][ssd]. +See also the [`OfferSnapshot`] data type and the [ABCI state sync documentation][ssd]. [ABCI documentation](https://docs.tendermint.com/master/spec/abci/abci.html#offersnapshot) -[ssd]: https://docs.tendermint.com/master/spec/abci/apps.html#state-sync \ No newline at end of file +[ssd]: https://docs.tendermint.com/master/spec/abci/apps.html#state-sync diff --git a/tendermint/src/abci/request.rs b/tendermint/src/abci/request.rs index 7e3e8c307..a582b2ec0 100644 --- a/tendermint/src/abci/request.rs +++ b/tendermint/src/abci/request.rs @@ -1,8 +1,5 @@ //! ABCI requests and request data. //! -//! The [`Request`] enum records all possible ABCI requests. Requests that -//! contain data are modeled as a separate struct, to avoid duplication of field -//! definitions. // IMPORTANT NOTE ON DOCUMENTATION: // diff --git a/tendermint/src/abci/response.rs b/tendermint/src/abci/response.rs index feb2613c0..17ead4ae6 100644 --- a/tendermint/src/abci/response.rs +++ b/tendermint/src/abci/response.rs @@ -1,8 +1,4 @@ //! ABCI responses and response data. -//! -//! The [`Response`] enum records all possible ABCI responses. Responses that -//! contain data are modeled as a separate struct, to avoid duplication of field -//! definitions. // IMPORTANT NOTE ON DOCUMENTATION: // diff --git a/tendermint/src/hash.rs b/tendermint/src/hash.rs index b7c7deae5..e55229313 100644 --- a/tendermint/src/hash.rs +++ b/tendermint/src/hash.rs @@ -234,7 +234,7 @@ impl TryFrom for AppHash { type Error = Error; fn try_from(value: Bytes) -> Result { - Ok(AppHash(value.into())) + Ok(AppHash(value.to_vec())) } } impl From for Bytes { diff --git a/tendermint/src/public_key.rs b/tendermint/src/public_key.rs index 46e7b97fc..294adf994 100644 --- a/tendermint/src/public_key.rs +++ b/tendermint/src/public_key.rs @@ -425,7 +425,7 @@ where { use de::Error; let encoded = String::deserialize(deserializer)?; - let bytes = base64::decode(&encoded).map_err(D::Error::custom)?; + let bytes = base64::decode(encoded).map_err(D::Error::custom)?; Ed25519::from_bytes(&bytes).map_err(D::Error::custom) } @@ -436,7 +436,7 @@ where { use de::Error; let encoded = String::deserialize(deserializer)?; - let bytes = base64::decode(&encoded).map_err(D::Error::custom)?; + let bytes = base64::decode(encoded).map_err(D::Error::custom)?; Secp256k1::from_sec1_bytes(&bytes).map_err(|_| D::Error::custom("invalid secp256k1 key")) } diff --git a/testgen/src/tester.rs b/testgen/src/tester.rs index 6bc3b58ab..1f9d73b98 100644 --- a/testgen/src/tester.rs +++ b/testgen/src/tester.rs @@ -462,7 +462,7 @@ impl Tester { } if let Ok(kind) = entry.file_type() { let path = format!("{}", entry.path().display()); - let rel_path = self.env().unwrap().rel_path(&path).unwrap(); + let rel_path = self.env().unwrap().rel_path(path).unwrap(); if kind.is_file() || kind.is_symlink() { if rel_path.ends_with(".json") { self.run_for_file(&rel_path); @@ -499,7 +499,7 @@ impl Tester { print(" Successful tests: "); for path in tests { print(&format!(" {}", path)); - if let Some(logs) = env.read_file(&(path + "/log")) { + if let Some(logs) = env.read_file(path + "/log") { print(&logs) } } @@ -510,7 +510,7 @@ impl Tester { print(" Failed tests: "); for (path, message, location) in tests { print(&format!(" {}, '{}', {}", path, message, location)); - if let Some(logs) = env.read_file(&(path + "/log")) { + if let Some(logs) = env.read_file(path + "/log") { print(&logs) } }