Skip to content

Commit

Permalink
fix: use from instead of try_from
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Jul 10, 2024
1 parent b61bf54 commit 8534eeb
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions ibc-core/ics03-connection/types/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use core::fmt::{Display, Error as FmtError, Formatter};
use core::time::Duration;

use ibc_core_client_types::error::ClientError;
use ibc_core_commitment_types::commitment::CommitmentPrefix;
use ibc_core_host_types::identifiers::{ClientId, ConnectionId};
use ibc_primitives::prelude::*;
Expand Down Expand Up @@ -392,8 +391,7 @@ impl TryFrom<RawCounterparty> for Counterparty {
.prefix
.ok_or(ConnectionError::MissingCounterparty)?
.key_prefix
.try_into()
.map_err(|_| ConnectionError::Client(ClientError::EmptyPrefix))?,
.into(),
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion ibc-testkit/src/testapp/ibc/core/core_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ where
fn commitment_prefix(&self) -> CommitmentPrefix {
// this is prefix of ibc store
// using a dummy prefix as in our mock context
CommitmentPrefix::try_from(b"mock".to_vec()).expect("Never fails")
CommitmentPrefix::from(b"mock".to_vec())
}

fn connection_counter(&self) -> Result<u64, ContextError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn conn_open_ack_fixture(ctx: Ctx) -> Fixture<MsgConnectionOpenAck> {
Counterparty::new(
client_id.clone(),
Some(msg.conn_id_on_b.clone()),
CommitmentPrefix::try_from(b"ibc".to_vec()).unwrap(),
CommitmentPrefix::from(b"ibc".to_vec()),
),
vec![msg.version.clone()],
ZERO_DURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn conn_open_confirm_fixture(ctx: Ctx) -> Fixture<MsgConnectionOpenConfirm> {
let counterparty = Counterparty::new(
client_id.clone(),
Some(msg.conn_id_on_b.clone()),
CommitmentPrefix::try_from(b"ibc".to_vec()).unwrap(),
CommitmentPrefix::from(b"ibc".to_vec()),
);

let ctx_default = MockContext::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn fixture() -> Fixture {
ConnectionCounterparty::new(
default_client_id,
Some(ConnectionId::zero()),
CommitmentPrefix::try_from(vec![0]).expect("no error"),
CommitmentPrefix::from(vec![0]),
),
ConnectionVersion::compatibles(),
ZERO_DURATION,
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/core/ics04_channel/recv_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn fixture() -> Fixture {
ConnectionCounterparty::new(
client_id.clone(),
Some(ConnectionId::zero()),
CommitmentPrefix::try_from(vec![0]).expect("no error"),
CommitmentPrefix::from(vec![0]),
),
ConnectionVersion::compatibles(),
ZERO_DURATION,
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/core/ics04_channel/send_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn send_packet_processing() {
ConnectionCounterparty::new(
default_client_id,
Some(ConnectionId::zero()),
CommitmentPrefix::try_from(vec![0]).expect("no error"),
CommitmentPrefix::from(vec![0]),
),
ConnectionVersion::compatibles(),
ZERO_DURATION,
Expand Down
2 changes: 1 addition & 1 deletion tests-integration/tests/core/ics04_channel/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn fixture() -> Fixture {
ConnectionCounterparty::new(
client_id.clone(),
Some(ConnectionId::zero()),
CommitmentPrefix::try_from(vec![0]).expect("no error"),
CommitmentPrefix::from(vec![0]),
),
ConnectionVersion::compatibles(),
ZERO_DURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn fixture() -> Fixture {
ConnectionCounterparty::new(
default_client_id,
Some(ConnectionId::zero()),
CommitmentPrefix::try_from(vec![0]).expect("no error"),
CommitmentPrefix::from(vec![0]),
),
ConnectionVersion::compatibles(),
ZERO_DURATION,
Expand Down

0 comments on commit 8534eeb

Please sign in to comment.