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

fix(ibc-clients/tendermint): disallow empty proof-specs and empty depth range in proof-specs #1104

38 changes: 36 additions & 2 deletions ibc-clients/ics07-tendermint/types/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ pub(crate) mod serde_tests {

#[cfg(test)]
mod tests {
use ibc_core_commitment_types::proto::ics23::ProofSpec as Ics23ProofSpec;
use ibc_core_commitment_types::proto::ics23::{
HashOp, InnerSpec, LeafOp, LengthOp, ProofSpec as Ics23ProofSpec,
};

use super::*;

Expand Down Expand Up @@ -460,6 +462,30 @@ mod tests {
want_pass: bool,
}

let leaf = LeafOp {
hash: HashOp::Sha256.into(),
prehash_key: 0,
prehash_value: HashOp::Sha256.into(),
length: LengthOp::VarProto.into(),
prefix: vec![0_u8],
};
let inner = InnerSpec {
child_order: vec![0, 1],
min_prefix_length: 1,
max_prefix_length: 1,
child_size: 32,
empty_child: vec![],
hash: HashOp::Sha256.into(),
};

let empty_depth_range_proof_specs: Vec<Ics23ProofSpec> = vec![Ics23ProofSpec {
leaf_spec: Some(leaf),
inner_spec: Some(inner),
min_depth: 2,
max_depth: 1,
prehash_key_before_comparison: false,
}];

let tests: Vec<Test> = vec![
Test {
name: "Valid parameters".to_string(),
Expand Down Expand Up @@ -568,7 +594,15 @@ mod tests {
name: "Invalid (empty) proof specs".to_string(),
params: ClientStateParams {
proof_specs: ProofSpecs::from(Vec::<Ics23ProofSpec>::new()),
..default_params
..default_params.clone()
},
want_pass: false,
},
Test {
name: "Invalid (empty) proof specs depth range".to_string(),
params: ClientStateParams {
proof_specs: ProofSpecs::from(empty_depth_range_proof_specs),
rnbguy marked this conversation as resolved.
Show resolved Hide resolved
..default_params.clone()
},
want_pass: false,
},
Expand Down