Skip to content

Commit

Permalink
Hardcode expected values
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Jan 24, 2023
1 parent 817a440 commit dc20ce7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 33 deletions.
19 changes: 4 additions & 15 deletions crates/ibc/src/core/ics02_client/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ impl From<UpgradeClient> for abci::Event {
#[cfg(test)]
mod tests {
use super::*;
use crate::mock::client_state::client_type as mock_client_type;
use crate::mock::header::MockHeader;
use ibc_proto::google::protobuf::Any;
use tendermint::abci::Event as AbciEvent;
Expand All @@ -405,12 +404,12 @@ mod tests {
kind: IbcEventType,
event: AbciEvent,
expected_keys: Vec<&'static str>,
expected_values: Vec<String>,
expected_values: Vec<&'static str>,
}

let client_type = mock_client_type();
let client_type = ClientType::new("07-tendermint".to_string());
let client_id = ClientId::new(client_type.clone(), 0).unwrap();
let consensus_height = Height::new(0, 10).unwrap();
let consensus_height = Height::new(0, 5).unwrap();
let consensus_heights = vec![Height::new(0, 5).unwrap(), Height::new(0, 7).unwrap()];
let header: Any = MockHeader::new(consensus_height).into();
let expected_keys = vec![
Expand All @@ -420,17 +419,7 @@ mod tests {
"consensus_heights",
"header",
];
let expected_values = vec![
client_id.to_string(),
"9999-mock".to_string(),
consensus_height.to_string(),
consensus_heights
.iter()
.map(|h| h.to_string())
.collect::<Vec<_>>()
.join(","),
String::from_utf8(hex::encode(header.clone().value)).unwrap(),
];
let expected_values = vec!["07-tendermint-0", "07-tendermint", "0-5", "0-5,0-7"];

let tests: Vec<Test> = vec![
Test {
Expand Down
19 changes: 10 additions & 9 deletions crates/ibc/src/core/ics03_connection/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl From<OpenConfirm> for abci::Event {
#[cfg(test)]
mod tests {
use super::*;
use crate::mock::client_state::client_type as mock_client_type;
use crate::core::ics02_client::client_type::ClientType;
use tendermint::abci::Event as AbciEvent;

#[test]
Expand All @@ -294,24 +294,25 @@ mod tests {
kind: IbcEventType,
event: AbciEvent,
expected_keys: Vec<&'static str>,
expected_values: Vec<String>,
expected_values: Vec<&'static str>,
}

let client_type = ClientType::new("07-tendermint".to_string());
let conn_id_on_a = ConnectionId::default();
let client_id_on_a = ClientId::default();
let client_id_on_a = ClientId::new(client_type.clone(), 0).unwrap();
let conn_id_on_b = ConnectionId::new(1);
let client_id_on_b = ClientId::new(mock_client_type(), 0).unwrap();
let client_id_on_b = ClientId::new(client_type, 1).unwrap();
let expected_keys = vec![
"connection_id",
"client_id",
"counterparty_client_id",
"counterparty_connection_id",
];
let expected_values = vec![
conn_id_on_a.to_string(),
client_id_on_a.to_string(),
client_id_on_b.to_string(),
conn_id_on_b.to_string(),
"connection-0",
"07-tendermint-0",
"07-tendermint-1",
"connection-1",
];

let tests: Vec<Test> = vec![
Expand All @@ -327,7 +328,7 @@ mod tests {
expected_values: expected_values
.iter()
.enumerate()
.map(|(i, v)| if i == 3 { "".to_string() } else { v.clone() })
.map(|(i, v)| if i == 3 { "" } else { v })
.collect(),
},
Test {
Expand Down
18 changes: 9 additions & 9 deletions crates/ibc/src/core/ics04_channel/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,15 +1070,15 @@ mod tests {
kind: IbcEventType,
event: AbciEvent,
expected_keys: Vec<&'static str>,
expected_values: Vec<String>,
expected_values: Vec<&'static str>,
}

let port_id = PortId::default();
let channel_id = ChannelId::default();
let connection_id = ConnectionId::default();
let counterparty_port_id = PortId::default();
let counterparty_channel_id = ChannelId::new(1);
let version = Version::default();
let version = Version::new("ics20".to_string());
let expected_keys = vec![
"port_id",
"channel_id",
Expand All @@ -1088,12 +1088,12 @@ mod tests {
"version",
];
let expected_values = vec![
port_id.to_string(),
channel_id.to_string(),
counterparty_port_id.to_string(),
counterparty_channel_id.to_string(),
connection_id.to_string(),
version.to_string(),
"defaultPort",
"channel-0",
"defaultPort",
"channel-1",
"connection-0",
"ics20",
];

let tests: Vec<Test> = vec![
Expand All @@ -1111,7 +1111,7 @@ mod tests {
expected_values: expected_values
.iter()
.enumerate()
.map(|(i, v)| if i == 3 { "".to_string() } else { v.clone() })
.map(|(i, v)| if i == 3 { "" } else { v })
.collect(),
},
Test {
Expand Down

0 comments on commit dc20ce7

Please sign in to comment.