Skip to content

Commit 8aea66d

Browse files
committed
refactor(ibc-testkit): remove Default() of ClientId, ConnectionId,...
1 parent d0562e0 commit 8aea66d

File tree

11 files changed

+67
-62
lines changed

11 files changed

+67
-62
lines changed

ibc-testkit/src/fixtures/core/connection/conn_open_ack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn dummy_raw_msg_conn_open_ack(
3838
}),
3939
client_state: Some(MockClientState::new(MockHeader::new(client_state_height)).into()),
4040
proof_client: dummy_proof(),
41-
version: Some(get_compatible_versions()[0].into()),
41+
version: Some(get_compatible_versions()[0].clone().into()),
4242
signer: dummy_bech32_account(),
4343
host_consensus_state_proof: vec![],
4444
}

ibc-testkit/src/fixtures/core/connection/conn_open_init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn dummy_raw_msg_conn_open_init() -> RawMsgConnectionOpenInit {
7373
RawMsgConnectionOpenInit {
7474
client_id: ClientId::from("07-tendermint-0").to_string(),
7575
counterparty: Some(dummy_raw_counterparty_conn(None)),
76-
version: Some(get_compatible_versions()[0].into()),
76+
version: Some(get_compatible_versions()[0].clone().into()),
7777
delay_period: 0,
7878
signer: dummy_bech32_account(),
7979
}

ibc-testkit/src/testapp/ibc/clients/mock/misbehaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl TryFrom<RawMisbehaviour> for Misbehaviour {
2323

2424
fn try_from(raw: RawMisbehaviour) -> Result<Self, Self::Error> {
2525
Ok(Self {
26-
client_id: Default::default(),
26+
client_id: ClientId::from("07-tendermint-0"),
2727
header1: raw
2828
.header1
2929
.ok_or(ClientError::MissingRawMisbehaviour)?

ibc-testkit/src/testapp/ibc/core/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub struct MockContext {
125125
pub struct MockClientConfig {
126126
#[builder(default = ChainId::new("mockZ-1").expect("no error"))]
127127
client_chain_id: ChainId,
128-
#[builder(default)]
128+
#[builder(default = ClientId::from("07-tendermint-0"))]
129129
client_id: ClientId,
130130
#[builder(default = mock_client_type())]
131131
client_type: ClientType,

ibc-testkit/tests/core/ics02_client/update_client.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Fixture {
4343

4444
#[fixture]
4545
fn fixture() -> Fixture {
46-
let client_id = ClientId::default();
46+
let client_id = ClientId::from("07-tendermint-0");
4747

4848
let ctx = MockContext::default().with_client_config(
4949
MockClientConfig::builder()
@@ -82,7 +82,7 @@ fn test_update_client_ok(fixture: Fixture) {
8282
mut router,
8383
} = fixture;
8484

85-
let client_id = ClientId::default();
85+
let client_id = ClientId::from("07-tendermint-0");
8686
let signer = dummy_account_id();
8787
let timestamp = Timestamp::now();
8888

@@ -114,7 +114,7 @@ fn test_update_client_ok(fixture: Fixture) {
114114
// client's height and ensures that `ConsensusState` is stored at the correct
115115
// path (header height).
116116
fn test_update_client_with_prev_header() {
117-
let client_id = ClientId::default();
117+
let client_id = ClientId::from("07-tendermint-0");
118118
let chain_id_b = ChainId::new("mockgaiaA-0").unwrap();
119119
let latest_height = Height::new(0, 42).unwrap();
120120
let height_1 = Height::new(0, 43).unwrap();
@@ -677,7 +677,7 @@ fn test_update_synthetic_tendermint_client_duplicate_ok() {
677677
.unwrap()
678678
.into(),
679679
),
680-
proof_specs: ProofSpecs::default().into(),
680+
proof_specs: ProofSpecs::cosmos().into(),
681681
upgrade_path: Vec::new(),
682682
frozen_height: Some(RawHeight {
683683
revision_number: 0,
@@ -778,7 +778,7 @@ fn test_update_client_events(fixture: Fixture) {
778778
mut router,
779779
} = fixture;
780780

781-
let client_id = ClientId::default();
781+
let client_id = ClientId::from("07-tendermint-0");
782782
let signer = dummy_account_id();
783783
let timestamp = Timestamp::now();
784784

@@ -839,7 +839,7 @@ fn test_misbehaviour_client_ok(fixture: Fixture) {
839839
mut router,
840840
} = fixture;
841841

842-
let client_id = ClientId::default();
842+
let client_id = ClientId::from("07-tendermint-0");
843843
let msg_envelope = msg_update_client(&client_id);
844844

845845
let res = validate(&ctx, &router, msg_envelope.clone());

ibc-testkit/tests/core/ics04_channel/acknowledgement.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use ibc::core::channel::types::msgs::{MsgAcknowledgement, PacketMsg};
44
use ibc::core::channel::types::Version;
55
use ibc::core::client::context::ClientExecutionContext;
66
use ibc::core::client::types::Height;
7+
use ibc::core::commitment_types::commitment::CommitmentPrefix;
78
use ibc::core::connection::types::version::get_compatible_versions;
89
use ibc::core::connection::types::{
910
ConnectionEnd, Counterparty as ConnectionCounterparty, State as ConnectionState,
@@ -59,7 +60,7 @@ fn fixture() -> Fixture {
5960
State::Open,
6061
Order::Unordered,
6162
Counterparty::new(packet.port_id_on_b, Some(packet.chan_id_on_b)),
62-
vec![ConnectionId::default()],
63+
vec![ConnectionId::new(0)],
6364
Version::new("ics20-1".to_string()),
6465
)
6566
.unwrap();
@@ -69,11 +70,11 @@ fn fixture() -> Fixture {
6970

7071
let conn_end_on_a = ConnectionEnd::new(
7172
ConnectionState::Open,
72-
ClientId::default(),
73+
ClientId::from("07-tendermint-0"),
7374
ConnectionCounterparty::new(
74-
ClientId::default(),
75-
Some(ConnectionId::default()),
76-
Default::default(),
75+
ClientId::from("07-tendermint-0"),
76+
Some(ConnectionId::new(0)),
77+
CommitmentPrefix::empty(),
7778
),
7879
get_compatible_versions(),
7980
ZERO_DURATION,
@@ -131,7 +132,7 @@ fn ack_success_no_packet_commitment(fixture: Fixture) {
131132
ChannelId::zero(),
132133
chan_end_on_a_unordered,
133134
)
134-
.with_connection(ConnectionId::default(), conn_end_on_a);
135+
.with_connection(ConnectionId::new(0), conn_end_on_a);
135136

136137
let msg_envelope = MsgEnvelope::from(PacketMsg::from(msg));
137138

@@ -166,7 +167,7 @@ fn ack_success_happy_path(fixture: Fixture) {
166167
ChannelId::zero(),
167168
chan_end_on_a_unordered,
168169
)
169-
.with_connection(ConnectionId::default(), conn_end_on_a)
170+
.with_connection(ConnectionId::new(0), conn_end_on_a)
170171
.with_packet_commitment(
171172
msg.packet.port_id_on_a.clone(),
172173
msg.packet.chan_id_on_a.clone(),
@@ -175,7 +176,7 @@ fn ack_success_happy_path(fixture: Fixture) {
175176
);
176177
ctx.get_client_execution_context()
177178
.store_update_meta(
178-
ClientId::default(),
179+
ClientId::from("07-tendermint-0"),
179180
client_height,
180181
Timestamp::from_nanoseconds(1000).unwrap(),
181182
Height::new(0, 4).unwrap(),
@@ -209,7 +210,7 @@ fn ack_unordered_chan_execute(fixture: Fixture) {
209210
ChannelId::zero(),
210211
chan_end_on_a_unordered,
211212
)
212-
.with_connection(ConnectionId::default(), conn_end_on_a)
213+
.with_connection(ConnectionId::new(0), conn_end_on_a)
213214
.with_packet_commitment(
214215
msg.packet.port_id_on_a.clone(),
215216
msg.packet.chan_id_on_a.clone(),
@@ -246,7 +247,7 @@ fn ack_ordered_chan_execute(fixture: Fixture) {
246247
} = fixture;
247248
let mut ctx = ctx
248249
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a_ordered)
249-
.with_connection(ConnectionId::default(), conn_end_on_a)
250+
.with_connection(ConnectionId::new(0), conn_end_on_a)
250251
.with_packet_commitment(
251252
msg.packet.port_id_on_a.clone(),
252253
msg.packet.chan_id_on_a.clone(),

ibc-testkit/tests/core/ics04_channel/chan_open_init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn fixture() -> Fixture {
5252
.latest_height(client_height)
5353
.build(),
5454
)
55-
.with_connection(ConnectionId::default(), conn_end_on_a);
55+
.with_connection(ConnectionId::new(0), conn_end_on_a);
5656

5757
Fixture { ctx, router, msg }
5858
}

ibc-testkit/tests/core/ics04_channel/recv_packet.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use ibc::core::channel::types::packet::Packet;
44
use ibc::core::channel::types::Version;
55
use ibc::core::client::context::ClientExecutionContext;
66
use ibc::core::client::types::Height;
7+
use ibc::core::commitment_types::commitment::CommitmentPrefix;
78
use ibc::core::connection::types::version::get_compatible_versions;
89
use ibc::core::connection::types::{
910
ConnectionEnd, Counterparty as ConnectionCounterparty, State as ConnectionState,
@@ -51,18 +52,18 @@ fn fixture() -> Fixture {
5152
State::Open,
5253
Order::Unordered,
5354
Counterparty::new(packet.port_id_on_a, Some(packet.chan_id_on_a)),
54-
vec![ConnectionId::default()],
55+
vec![ConnectionId::new(0)],
5556
Version::new("ics20-1".to_string()),
5657
)
5758
.unwrap();
5859

5960
let conn_end_on_b = ConnectionEnd::new(
6061
ConnectionState::Open,
61-
ClientId::default(),
62+
ClientId::from("07-tendermint-0"),
6263
ConnectionCounterparty::new(
63-
ClientId::default(),
64-
Some(ConnectionId::default()),
65-
Default::default(),
64+
ClientId::from("07-tendermint-0"),
65+
Some(ConnectionId::new(0)),
66+
CommitmentPrefix::empty(),
6667
),
6768
get_compatible_versions(),
6869
ZERO_DURATION,
@@ -119,7 +120,7 @@ fn recv_packet_validate_happy_path(fixture: Fixture) {
119120
.latest_height(client_height)
120121
.build(),
121122
)
122-
.with_connection(ConnectionId::default(), conn_end_on_b)
123+
.with_connection(ConnectionId::new(0), conn_end_on_b)
123124
.with_channel(
124125
packet.port_id_on_b.clone(),
125126
packet.chan_id_on_b.clone(),
@@ -141,7 +142,7 @@ fn recv_packet_validate_happy_path(fixture: Fixture) {
141142
context
142143
.get_client_execution_context()
143144
.store_update_meta(
144-
ClientId::default(),
145+
ClientId::from("07-tendermint-0"),
145146
client_height,
146147
Timestamp::from_nanoseconds(1000).unwrap(),
147148
Height::new(0, 5).unwrap(),
@@ -197,7 +198,7 @@ fn recv_packet_timeout_expired(fixture: Fixture) {
197198
.latest_height(client_height)
198199
.build(),
199200
)
200-
.with_connection(ConnectionId::default(), conn_end_on_b)
201+
.with_connection(ConnectionId::new(0), conn_end_on_b)
201202
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_b)
202203
.with_send_sequence(PortId::transfer(), ChannelId::zero(), 1.into())
203204
.with_height(host_height);
@@ -227,7 +228,7 @@ fn recv_packet_execute_happy_path(fixture: Fixture) {
227228
.latest_height(client_height)
228229
.build(),
229230
)
230-
.with_connection(ConnectionId::default(), conn_end_on_b)
231+
.with_connection(ConnectionId::new(0), conn_end_on_b)
231232
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_b);
232233

233234
let msg_env = MsgEnvelope::from(PacketMsg::from(msg));

ibc-testkit/tests/core/ics04_channel/send_packet.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ibc::core::channel::types::channel::{ChannelEnd, Counterparty, Order, State}
66
use ibc::core::channel::types::packet::Packet;
77
use ibc::core::channel::types::Version;
88
use ibc::core::client::types::Height;
9+
use ibc::core::commitment_types::commitment::CommitmentPrefix;
910
use ibc::core::connection::types::version::get_compatible_versions;
1011
use ibc::core::connection::types::{
1112
ConnectionEnd, Counterparty as ConnectionCounterparty, State as ConnectionState,
@@ -32,18 +33,18 @@ fn send_packet_processing() {
3233
State::Open,
3334
Order::Unordered,
3435
Counterparty::new(PortId::transfer(), Some(ChannelId::zero())),
35-
vec![ConnectionId::default()],
36+
vec![ConnectionId::new(0)],
3637
Version::new("ics20-1".to_string()),
3738
)
3839
.unwrap();
3940

4041
let conn_end_on_a = ConnectionEnd::new(
4142
ConnectionState::Open,
42-
ClientId::default(),
43+
ClientId::from("07-tendermint-0"),
4344
ConnectionCounterparty::new(
44-
ClientId::default(),
45-
Some(ConnectionId::default()),
46-
Default::default(),
45+
ClientId::from("07-tendermint-0"),
46+
Some(ConnectionId::new(0)),
47+
CommitmentPrefix::empty(),
4748
),
4849
get_compatible_versions(),
4950
ZERO_DURATION,
@@ -97,7 +98,7 @@ fn send_packet_processing() {
9798
.latest_height(client_height)
9899
.build(),
99100
)
100-
.with_connection(ConnectionId::default(), conn_end_on_a.clone())
101+
.with_connection(ConnectionId::new(0), conn_end_on_a.clone())
101102
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone())
102103
.with_send_sequence(PortId::transfer(), ChannelId::zero(), 1.into()),
103104
packet,
@@ -112,7 +113,7 @@ fn send_packet_processing() {
112113
.latest_height(client_height)
113114
.build(),
114115
)
115-
.with_connection(ConnectionId::default(), conn_end_on_a.clone())
116+
.with_connection(ConnectionId::new(0), conn_end_on_a.clone())
116117
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone())
117118
.with_send_sequence(PortId::transfer(), ChannelId::zero(), 1.into()),
118119
packet: packet_timeout_equal_client_height,
@@ -127,7 +128,7 @@ fn send_packet_processing() {
127128
.latest_height(client_height)
128129
.build(),
129130
)
130-
.with_connection(ConnectionId::default(), conn_end_on_a.clone())
131+
.with_connection(ConnectionId::new(0), conn_end_on_a.clone())
131132
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone())
132133
.with_send_sequence(PortId::transfer(), ChannelId::zero(), 1.into()),
133134
packet: packet_timeout_one_before_client_height,
@@ -141,7 +142,7 @@ fn send_packet_processing() {
141142
.latest_height(client_height)
142143
.build(),
143144
)
144-
.with_connection(ConnectionId::default(), conn_end_on_a)
145+
.with_connection(ConnectionId::new(0), conn_end_on_a)
145146
.with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a)
146147
.with_send_sequence(PortId::transfer(), ChannelId::zero(), 1.into()),
147148
packet: packet_with_timestamp_old,

0 commit comments

Comments
 (0)