Skip to content

Commit

Permalink
Merge pull request #346 from CESSProject/fix/ces-types_unittest
Browse files Browse the repository at this point in the history
fix: [ces-types] enable unit tests to run normally
  • Loading branch information
0xbillw authored May 10, 2024
2 parents 42ef77c + 9f01754 commit f2a909d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/ces-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sgx-attestation = { workspace = true }


[dev-dependencies]
frame-support = { workspace = true }
frame-support = { workspace = true, features = ["std"] }


[features]
Expand Down
5 changes: 3 additions & 2 deletions crates/ces-types/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn fixed_measurement_hash(data: &[u8]) -> H256 {
}

#[cfg(not(feature = "full_crypto"))]
fn fixed_measurement_hash(data: &[u8]) -> H256 {
fn fixed_measurement_hash(_data: &[u8]) -> H256 {
log::error!("The measurement hash must be in SGX enviroment with \"full_crypto\" feature, now return zero");
H256::default()
}
Expand Down Expand Up @@ -279,14 +279,15 @@ mod test {
Err(Error::CesealRejected)
);

let m_hash = fixed_measurement_hash(&hex::decode(PRUNTIME_HASH).unwrap());
assert_ok!(validate_ias_report(
commit,
report,
&signature,
&raw_signing_cert,
ATTESTATION_TIMESTAMP,
true,
vec![hex::decode(PRUNTIME_HASH).unwrap()]
vec![m_hash]
));
}
}
4 changes: 3 additions & 1 deletion crates/ces-types/src/attestation/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pub fn validate_ias_report(
mod test {
use super::*;
use frame_support::assert_ok;
use crate::attestation::fixed_measurement_hash;

pub const ATTESTATION_SAMPLE: &[u8] = include_bytes!("../../sample/ias_attestation.json");
pub const ATTESTATION_TIMESTAMP: u64 = 1631441180; // 2021-09-12T18:06:20.402478
Expand All @@ -176,13 +177,14 @@ mod test {
Err(Error::CesealRejected)
);

let m_hash = fixed_measurement_hash(&hex::decode(PRUNTIME_HASH).unwrap());
assert_ok!(validate_ias_report(
report,
&signature,
&raw_signing_cert,
ATTESTATION_TIMESTAMP,
true,
vec![hex::decode(PRUNTIME_HASH).unwrap()]
vec![m_hash]
));
}
}

0 comments on commit f2a909d

Please sign in to comment.