-
Notifications
You must be signed in to change notification settings - Fork 352
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
Re-enable tests in ics02_client
and foreign_client
#535
Changes from all commits
ec00b02
6518cb8
14c5cac
8ce3bb6
f0227bf
85e7e46
9966edf
5c37cc5
9355d4f
4092026
ba4a39d
e0c7383
9f6f639
6658b10
90b64e4
59f2036
25be8ae
0741e75
b991020
6ada439
e338044
da8c37a
03c2469
4ffe9bb
935742f
1db5815
84885c7
e0db63c
c5f2af9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,7 @@ Cargo.lock | |
.idea | ||
|
||
# Ignore VisualStudio | ||
.vscode | ||
.vscode | ||
|
||
# Ignore chain's data | ||
data |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ | |
use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState}; | ||
use crate::ics02_client::client_type::ClientType; | ||
use crate::ics02_client::error::Error; | ||
use crate::ics02_client::handler::ClientResult::{Create, Update}; | ||
use crate::ics02_client::handler::{ClientEvent, ClientResult}; | ||
use crate::ics02_client::handler::ClientResult::{self, Create, Update}; | ||
use crate::ics24_host::identifier::ClientId; | ||
use crate::Height; | ||
|
||
|
@@ -15,25 +14,28 @@ pub trait ClientReader { | |
fn client_type(&self, client_id: &ClientId) -> Option<ClientType>; | ||
fn client_state(&self, client_id: &ClientId) -> Option<AnyClientState>; | ||
fn consensus_state(&self, client_id: &ClientId, height: Height) -> Option<AnyConsensusState>; | ||
|
||
/// Returns a natural number, counting how many clients have been created thus far. | ||
/// The value of this counter should increase only via method `ClientKeeper::increase_client_counter`. | ||
fn client_counter(&self) -> u64; | ||
} | ||
|
||
/// Defines the write-only part of ICS2 (client functions) context. | ||
pub trait ClientKeeper { | ||
fn store_client_result( | ||
&mut self, | ||
handler_res: ClientResult, | ||
) -> Result<Vec<ClientEvent>, Error> { | ||
fn store_client_result(&mut self, handler_res: ClientResult) -> Result<(), Error> { | ||
match handler_res { | ||
Create(res) => { | ||
let client_id = self.next_client_id(); | ||
let client_id = res.client_id.clone(); | ||
|
||
self.store_client_type(client_id.clone(), res.client_type)?; | ||
self.store_client_state(client_id.clone(), res.client_state.clone())?; | ||
self.store_consensus_state( | ||
client_id.clone(), | ||
client_id, | ||
res.client_state.latest_height(), | ||
res.consensus_state, | ||
)?; | ||
Ok(vec![ClientEvent::ClientCreated(client_id)]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Events were being created both here and at the handlers. Now they're only created at the handlers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks better & cleaner! Just to note that In future (or in other handlers) we may find it useful to create events both from the |
||
self.increase_client_counter(); | ||
Ok(()) | ||
} | ||
Update(res) => { | ||
self.store_client_state(res.client_id.clone(), res.client_state.clone())?; | ||
|
@@ -42,13 +44,11 @@ pub trait ClientKeeper { | |
res.client_state.latest_height(), | ||
res.consensus_state, | ||
)?; | ||
Ok(vec![ClientEvent::ClientUpdated(res.client_id)]) | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
fn next_client_id(&mut self) -> ClientId; | ||
|
||
/// Called upon successful client creation | ||
fn store_client_type( | ||
&mut self, | ||
|
@@ -70,4 +70,9 @@ pub trait ClientKeeper { | |
height: Height, | ||
consensus_state: AnyConsensusState, | ||
) -> Result<(), Error>; | ||
|
||
/// Called upon client creation. | ||
/// Increases the counter which keeps track of how many clients have been created. | ||
/// Should never fail. | ||
fn increase_client_counter(&mut self); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wish, I suggest once we're done with this we do a follow-up PR to update ADR003 events section, making it clear that handlers are using the strongly-typed events, not these loosely-typed events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we open an issue for that? It's probably better if someone familiar with that ADR does the change.