Skip to content

Commit

Permalink
add InvalidUpgradePath
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Aug 8, 2024
1 parent 45fe2e5 commit cc4bff4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ibc-clients/ics07-tendermint/src/client_state/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ impl ClientStateCommon for ClientState {
let upgrade_path = &self.inner().upgrade_path;
let (upgrade_path_prefix, upgrade_path) = match upgrade_path.len() {
0 => {
return Err(ClientError::ClientSpecific {
description: "cannot upgrade client as no upgrade path has been set"
.to_string(),
});
return Err(UpgradeClientError::InvalidUpgradePath {
reason: "no upgrade path has been set".to_string(),
}
.into());
}
1 => (CommitmentPrefix::empty(), upgrade_path[0].clone()),
2 => (
upgrade_path[0].as_bytes().to_vec().into(),
upgrade_path[1].clone(),

Check warning on line 67 in ibc-clients/ics07-tendermint/src/client_state/common.rs

View check run for this annotation

Codecov / codecov/patch

ibc-clients/ics07-tendermint/src/client_state/common.rs#L51-L67

Added lines #L51 - L67 were not covered by tests
),
_ => {
return Err(ClientError::ClientSpecific {
description: "upgrade client failed: upgrade path is too long".to_string(),
})
return Err(UpgradeClientError::InvalidUpgradePath {
reason: "upgrade path is too long".to_string(),
}

Check warning on line 72 in ibc-clients/ics07-tendermint/src/client_state/common.rs

View check run for this annotation

Codecov / codecov/patch

ibc-clients/ics07-tendermint/src/client_state/common.rs#L69-L72

Added lines #L69 - L72 were not covered by tests
.into());
}
};

Expand Down
2 changes: 2 additions & 0 deletions ibc-core/ics02-client/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ pub enum UpgradeClientError {
upgraded_height: Height,
client_height: Height,
},
/// Invalid upgrade path: `{reason}`
InvalidUpgradePath { reason: String },
/// invalid upgrade proposal: `{reason}`
InvalidUpgradeProposal { reason: String },
/// invalid upgrade plan: `{reason}`
Expand Down

0 comments on commit cc4bff4

Please sign in to comment.