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

Handler for channel open init #452

Merged
merged 35 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
79caad1
handler for channel open init
cezarad Dec 17, 2020
b177fe5
formated
cezarad Dec 17, 2020
3cd7b8f
Update modules/src/ics04_channel/handler/chan_open_init.rs
cezarad Dec 21, 2020
d2e1dff
Update modules/src/ics04_channel/handler/chan_open_init.rs
cezarad Dec 21, 2020
4beb025
Update modules/src/ics04_channel/context.rs
cezarad Dec 21, 2020
0a7aa38
chan open init Romains comments
cezarad Dec 21, 2020
af514ec
added port verification
cezarad Jan 7, 2021
5a62fd5
Merge branch 'master' into Cezara
cezarad Jan 7, 2021
1054aee
chan open init
cezarad Jan 7, 2021
d899101
chan open init
cezarad Jan 7, 2021
08b54fb
minor fmt
cezarad Jan 8, 2021
0f5f16d
chan open init
cezarad Jan 8, 2021
17fe71f
Update modules/src/ics04_channel/channel.rs
cezarad Jan 12, 2021
791f5a1
Update modules/src/ics04_channel/channel.rs
cezarad Jan 12, 2021
bffcb1a
Update modules/src/ics04_channel/context.rs
cezarad Jan 12, 2021
8580c2c
Update modules/src/ics04_channel/context.rs
cezarad Jan 12, 2021
b2f8105
Update error.rs
cezarad Jan 12, 2021
f57b658
Update modules/src/ics04_channel/error.rs
cezarad Jan 12, 2021
e0afeb1
Update modules/src/ics04_channel/channel.rs
cezarad Jan 14, 2021
823eb49
Update modules/src/ics04_channel/context.rs
cezarad Jan 14, 2021
0f37d37
Update context.rs
cezarad Jan 14, 2021
3e40a36
minor
cezarad Jan 14, 2021
cbcaa41
minor
cezarad Jan 14, 2021
e4876e1
test for port
cezarad Jan 14, 2021
2448106
connetion features
cezarad Jan 15, 2021
24a3ae8
connetion features
cezarad Jan 15, 2021
839f675
connetion features
cezarad Jan 15, 2021
a9611fa
review comments
cezarad Jan 15, 2021
ea84402
Merge branch 'master' into Cezara
cezarad Jan 15, 2021
053f0e0
Small refactor to improve readability
romac Jan 15, 2021
1426985
Cleanup ics05_port::capabilities
romac Jan 15, 2021
2d7bc35
Replace panic! with unwrap and avoid some clones in mock context
romac Jan 15, 2021
107236e
Avoid clones in MockContext::add_port
romac Jan 15, 2021
768dfd6
Only clone the channel id
romac Jan 15, 2021
05017f5
Fix a couple comments
romac Jan 15, 2021
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
Prev Previous commit
Next Next commit
chan open init
  • Loading branch information
cezarad committed Jan 7, 2021
commit d8991011f8ff8bf11a8d0231117b3bf6c1e6b695
2 changes: 1 addition & 1 deletion modules/src/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub mod test_util {
state: 1,
ordering: 0,
counterparty: Some(get_dummy_raw_counterparty()),
connection_hops: vec!["srcconnection".to_string()],
connection_hops: vec!["defaultConnection-0".to_string()],
version: "ics20".to_string(), // The version is not validated.
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics04_channel/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait ChannelKeeper {

self.store_connection_channels(
&result.channel_end.connection_hops()[0].clone(),
&(result.port_id.clone(), channel_id.clone()),
&(result.port_id.clone(), channel_id),
)?;
}
State::TryOpen => {
Expand Down
23 changes: 10 additions & 13 deletions modules/src/ics04_channel/handler/chan_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ mod tests {
msg_conn_init.delay_period,
);

// let cid = ConnectionId::default();
let ccid = <ConnectionId as FromStr>::from_str("srcconnection");
let ccid = <ConnectionId as FromStr>::from_str("defaultConnection-0");
let cid = match ccid {
Ok(v) => v,
Err(_e) => ConnectionId::default(),
Expand All @@ -136,17 +135,15 @@ mod tests {
},
Test {
name: "Good parameters".to_string(),
ctx: context
.with_connection_capability(
MsgChannelOpenInit::try_from(get_dummy_raw_msg_chan_open_init())
.unwrap()
.port_id()
.clone(),
cid.clone(),
init_conn_end.clone(),
)
.clone(),
msg: ChannelMsg::ChannelOpenInit(msg_chan_init.clone()),
ctx: context.with_connection_capability(
MsgChannelOpenInit::try_from(get_dummy_raw_msg_chan_open_init())
.unwrap()
.port_id()
.clone(),
cid,
init_conn_end,
),
msg: ChannelMsg::ChannelOpenInit(msg_chan_init),
want_pass: true,
},
]
Expand Down
6 changes: 6 additions & 0 deletions modules/src/ics05_port/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ impl Capability {
Self { index: 0x0 }
}
}

impl Default for Capability {
fn default() -> Self {
Self::new()
}
}
2 changes: 2 additions & 0 deletions modules/src/ics26_routing/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ mod tests {
res
);

ctx = MockContext::add_port(&mut ctx, msg_chan_init.port_id().clone());

// Figure out the ID of the client that was just created.
// TODO: Create a "search by attribute key" API for HandlerOutput to simplify the following
let mut events = res.unwrap().events;
Expand Down
21 changes: 15 additions & 6 deletions modules/src/mock/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ impl MockContext {
}
Ok(())
}
pub fn add_port(&self, port_id: PortId) -> Self {
let mut port_capabilities = self.port_capabilities.clone();
port_capabilities.insert(port_id, Capability::new());
Self {
port_capabilities,
..self.clone()
}
}
}

impl ICS26Context for MockContext {}
Expand All @@ -329,7 +337,7 @@ impl PortReader for MockContext {
}

fn autenthenticate(&self, _cap: &Capability, _port_id: &PortId) -> bool {
return true;
true
}
}

Expand Down Expand Up @@ -391,11 +399,11 @@ impl ChannelReader for MockContext {
}

fn port_capability(&self, port_id: &PortId) -> Option<Capability> {
return PortReader::lookup_module_by_port(self, port_id);
PortReader::lookup_module_by_port(self, port_id)
}

fn capability_authentification(&self, port_id: &PortId, cap: &Capability) -> bool {
return PortReader::autenthenticate(self, cap, port_id);
PortReader::autenthenticate(self, cap, port_id)
}
}

Expand Down Expand Up @@ -449,19 +457,20 @@ impl ChannelKeeper for MockContext {
cid: &ConnectionId,
port_channel_id: &(PortId, ChannelId),
) -> Result<(), ICS4Error> {
Ok(match self.connection_channels.get(cid) {
match self.connection_channels.get(cid) {
Some(v) => {
let mut modv = v.clone();
modv.push(port_channel_id.clone());
&self.connection_channels.remove(cid);
self.connection_channels.remove(cid);
self.connection_channels.insert(cid.clone(), modv);
}
None => {
let mut modv = Vec::new();
modv.push(port_channel_id.clone());
self.connection_channels.insert(cid.clone(), modv);
}
})
}
Ok(())
}
}

Expand Down