Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy warnings introduced in Rust 1.53 #1102

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ data
.mypy_cache/
__pycache__/

# Ignore modelator aritfacts
.modelator
mc.log
2 changes: 1 addition & 1 deletion modules/src/ics03_connection/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub trait ConnectionKeeper {
// Also associate the connection end to its client identifier.
self.store_connection_to_client(
result.connection_id.clone(),
&result.connection_end.client_id(),
result.connection_end.client_id(),
)?;
}

Expand Down
12 changes: 6 additions & 6 deletions modules/src/ics03_connection/handler/conn_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"conn_open_ack: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have OPEN state.
let res: ConnectionResult = proto_output.result;
Expand All @@ -249,15 +249,15 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"conn_open_ack: failed for test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
test.ctx.clone(),
e,
);

// Verify that the error kind matches
if let Some(expected_kind) = test.error_kind {
assert_eq!(
Expand Down
11 changes: 5 additions & 6 deletions modules/src/ics03_connection/handler/conn_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"conn_open_confirm: test passed but was supposed to fail for: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have OPEN state.
let res: ConnectionResult = proto_output.result;
Expand All @@ -179,9 +179,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"conn_open_confirm: failed for test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
Expand Down
11 changes: 5 additions & 6 deletions modules/src/ics03_connection/handler/conn_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"conn_open_init: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have init state.
let res: ConnectionResult = proto_output.result;
Expand All @@ -121,9 +121,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"conn_open_init: did not pass test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
Expand Down
11 changes: 5 additions & 6 deletions modules/src/ics03_connection/handler/conn_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"conn_open_try: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have TryOpen state.
let res: ConnectionResult = proto_output.result;
Expand All @@ -250,9 +250,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"conn_open_try: failed for test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
Expand Down
14 changes: 7 additions & 7 deletions modules/src/ics04_channel/handler/acknowledgement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn process(
// Verify the acknowledgement proof
verify_packet_acknowledgement_proofs(
ctx,
&packet,
packet,
msg.acknowledgement().clone(),
client_id,
msg.proofs(),
Expand Down Expand Up @@ -249,23 +249,23 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"ack_packet: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

for e in proto_output.events.iter() {
assert!(matches!(e, &IbcEvent::AcknowledgePacket(_)));
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"ack_packet: did not pass test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg.clone(),
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics04_channel/handler/chan_close_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub(crate) fn process(
&channel_end,
&conn,
&expected_channel_end,
&msg.proofs(),
msg.proofs(),
)
.map_err(|e| Kind::FailedChanneOpenTryVerification.context(e))?;

Expand Down
13 changes: 6 additions & 7 deletions modules/src/ics04_channel/handler/chan_open_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub(crate) fn process(
&channel_end,
&conn,
&expected_channel_end,
&msg.proofs(),
msg.proofs(),
)
.map_err(|e| Kind::ChanOpenAckProofVerification.context(e))?;

Expand Down Expand Up @@ -304,15 +304,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"chan_open_ack: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have init state.
let res: ChannelResult = proto_output.result;
Expand All @@ -324,9 +324,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"chan_open_ack: did not pass test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
Expand Down
13 changes: 6 additions & 7 deletions modules/src/ics04_channel/handler/chan_open_confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(crate) fn process(
&channel_end,
&conn,
&expected_channel_end,
&msg.proofs(),
msg.proofs(),
)
.map_err(|e| Kind::ChanOpenConfirmProofVerification.context(e))?;

Expand Down Expand Up @@ -180,15 +180,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"chan_open_confirm: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ConnectionEnd, should have init state.
let res: ChannelResult = proto_output.result;
Expand All @@ -200,9 +200,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"chan_open_ack: did not pass test: {}, \nparams {:?} {:?}\nerror: {:?}",
test.name,
test.msg,
Expand Down
11 changes: 5 additions & 6 deletions modules/src/ics04_channel/handler/chan_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"chan_open_init: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

// The object in the output is a ChannelEnd, should have init state.
let res: ChannelResult = proto_output.result;
Expand All @@ -191,9 +191,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"chan_open_init: did not pass test: {}, \nparams {:?} {:?} error: {:?}",
test.name,
test.msg,
Expand Down
17 changes: 8 additions & 9 deletions modules/src/ics04_channel/handler/chan_open_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub(crate) fn process(

// Validate that existing channel end matches with the one we're trying to establish.
if old_channel_end.state_matches(&State::Init)
&& old_channel_end.order_matches(&msg.channel.ordering())
&& old_channel_end.connection_hops_matches(&msg.channel.connection_hops())
&& old_channel_end.order_matches(msg.channel.ordering())
&& old_channel_end.connection_hops_matches(msg.channel.connection_hops())
&& old_channel_end.counterparty_matches(msg.channel.counterparty())
&& old_channel_end.version_matches(&msg.channel.version())
{
Expand Down Expand Up @@ -122,7 +122,7 @@ pub(crate) fn process(
&new_channel_end,
&conn,
&expected_channel_end,
&msg.proofs(),
msg.proofs(),
)
.map_err(|e| Kind::FailedChanneOpenTryVerification.context(e))?;

Expand Down Expand Up @@ -353,15 +353,15 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(handler_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"chan_open_ack: test passed but was supposed to fail for test: {}, \nparams {:?} {:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(handler_output.events.is_empty(), true); // Some events must exist.

assert!(!handler_output.events.is_empty()); // Some events must exist.

// The object in the output is a channel end, should have TryOpen state.
let res: ChannelResult = handler_output.result;
Expand All @@ -372,9 +372,8 @@ mod tests {
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"chan_open_try: did not pass test: {}, \nparams:\n\tmsg={:?}\n\tcontext={:?}\nerror: {:?}",
test.name,
test.msg,
Expand Down
14 changes: 7 additions & 7 deletions modules/src/ics04_channel/handler/recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn process(ctx: &dyn ChannelReader, msg: MsgRecvPacket) -> HandlerResult<Pac
return Err(Kind::LowPacketTimestamp.into());
}

verify_packet_recv_proofs(ctx, &packet, client_id, &msg.proofs)?;
verify_packet_recv_proofs(ctx, packet, client_id, &msg.proofs)?;

let result = if dest_channel_end.order_matches(&Order::Ordered) {
let next_seq_recv = ctx
Expand Down Expand Up @@ -280,23 +280,23 @@ mod tests {
// Additionally check the events and the output objects in the result.
match res {
Ok(proto_output) => {
assert_eq!(
assert!(
test.want_pass,
true,
"recv_packet: test passed but was supposed to fail for test: {}, \nparams \n msg={:?}\nctx:{:?}",
test.name,
test.msg.clone(),
test.ctx.clone()
);
assert_ne!(proto_output.events.is_empty(), true); // Some events must exist.

assert!(!proto_output.events.is_empty()); // Some events must exist.

for e in proto_output.events.iter() {
assert!(matches!(e, &IbcEvent::ReceivePacket(_)));
}
}
Err(e) => {
assert_eq!(
test.want_pass,
false,
assert!(
!test.want_pass,
"recv_packet: did not pass test: {}, \nparams \nmsg={:?}\nctx={:?}\nerror={:?}",
test.name,
test.msg.clone(),
Expand Down
Loading