Skip to content

Commit

Permalink
Convert frozen height to None when raw frozen height is zero (#1640)
Browse files Browse the repository at this point in the history
* Convert frozen height to None when raw frozen height is zero

* Fix Python E2E test
  • Loading branch information
soareschen authored Dec 6, 2021
1 parent fd65565 commit d18cc90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/e2e/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AllowUpdate:
@dataclass
class ClientState:
chain_id: ChainId
frozen_height: Height
frozen_height: Optional[Height]
latest_height: Height
max_clock_drift: Duration
trust_level: TrustLevel
Expand Down
11 changes: 10 additions & 1 deletion modules/src/clients/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ impl TryFrom<RawClientState> for ClientState {
.clone()
.ok_or_else(Error::missing_trusting_period)?;

let frozen_height = raw.frozen_height.and_then(|raw_height| {
let height = raw_height.into();
if height == Height::zero() {
None
} else {
Some(height)
}
});

Ok(Self {
chain_id: ChainId::from_string(raw.chain_id.as_str()),
trust_level: trust_level
Expand All @@ -224,7 +233,7 @@ impl TryFrom<RawClientState> for ClientState {
.latest_height
.ok_or_else(Error::missing_latest_height)?
.into(),
frozen_height: raw.frozen_height.map(|h| h.into()),
frozen_height,
upgrade_path: raw.upgrade_path,
allow_update: AllowUpdate {
after_expiry: raw.allow_update_after_expiry,
Expand Down

0 comments on commit d18cc90

Please sign in to comment.