-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid calculating hashes of wasms during read operations
- Loading branch information
1 parent
744f468
commit 6e64de2
Showing
11 changed files
with
123 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,50 @@ | ||
use super::*; | ||
|
||
use crate::pb::v1 as pb; | ||
|
||
use ic_base_types::PrincipalId; | ||
use ic_crypto_sha2::Sha256; | ||
use ic_nns_governance_api::pb::v1 as pb_api; | ||
|
||
#[test] | ||
fn install_code_internal_to_api() { | ||
fn install_code_request_to_internal() { | ||
let test_cases = vec![ | ||
( | ||
pb::InstallCode { | ||
pb_api::InstallCodeRequest { | ||
canister_id: Some(PrincipalId::new_user_test_id(1)), | ||
install_mode: Some(pb::install_code::CanisterInstallMode::Install as i32), | ||
skip_stopping_before_installing: None, | ||
wasm_module: Some(vec![1, 2, 3]), | ||
arg: Some(vec![]), | ||
}, | ||
pb_api::InstallCode { | ||
pb::InstallCode { | ||
canister_id: Some(PrincipalId::new_user_test_id(1)), | ||
install_mode: Some(pb_api::install_code::CanisterInstallMode::Install as i32), | ||
skip_stopping_before_installing: None, | ||
wasm_module: Some(vec![1, 2, 3]), | ||
arg: Some(vec![]), | ||
wasm_module_hash: Some(Sha256::hash(&[1, 2, 3]).to_vec()), | ||
arg_hash: Some(vec![]), | ||
}, | ||
), | ||
( | ||
pb::InstallCode { | ||
pb_api::InstallCodeRequest { | ||
canister_id: Some(PrincipalId::new_user_test_id(1)), | ||
install_mode: Some(pb::install_code::CanisterInstallMode::Upgrade as i32), | ||
skip_stopping_before_installing: Some(true), | ||
wasm_module: Some(vec![1, 2, 3]), | ||
arg: Some(vec![4, 5, 6]), | ||
}, | ||
pb_api::InstallCode { | ||
pb::InstallCode { | ||
canister_id: Some(PrincipalId::new_user_test_id(1)), | ||
install_mode: Some(pb_api::install_code::CanisterInstallMode::Upgrade as i32), | ||
skip_stopping_before_installing: Some(true), | ||
wasm_module: Some(vec![1, 2, 3]), | ||
arg: Some(vec![4, 5, 6]), | ||
wasm_module_hash: Some(Sha256::hash(&[1, 2, 3]).to_vec()), | ||
arg_hash: Some(Sha256::hash(&[4, 5, 6]).to_vec()), | ||
}, | ||
), | ||
]; | ||
|
||
for (internal, api) in test_cases { | ||
assert_eq!(pb_api::InstallCode::from(internal), api); | ||
for (request, internal) in test_cases { | ||
assert_eq!(pb::InstallCode::from(request), internal); | ||
} | ||
} |
Oops, something went wrong.