MCPcopy Create free account
hub / github.com/dfinity/orbit / assert_initial_assets

Function assert_initial_assets

tests/integration/src/install_tests.rs:874–917  ·  view source on GitHub ↗
(
    env: &PocketIc,
    canister_id: Principal,
    requester: Principal,
    expected_assets: &Vec<InitAssetInput>,
)

Source from the content-addressed store, hash-verified

872}
873
874fn assert_initial_assets(
875 env: &PocketIc,
876 canister_id: Principal,
877 requester: Principal,
878 expected_assets: &Vec<InitAssetInput>,
879) -> Result<(), String> {
880 let listed_assets = list_assets(env, canister_id, requester)
881 .expect("failed to call list_assets")
882 .0
883 .expect("failed to list assets");
884
885 if expected_assets.len() != listed_assets.assets.len() {
886 return Err(format!(
887 "expected {} assets, got {}",
888 expected_assets.len(),
889 listed_assets.assets.len()
890 ));
891 }
892
893 for expected_asset in expected_assets {
894 let asset = listed_assets
895 .assets
896 .iter()
897 .find(|asset| asset.name == expected_asset.name)
898 .ok_or(format!("asset {} not found", expected_asset.name))?;
899
900 if expected_asset
901 .id
902 .as_ref()
903 .map(|id| id != &asset.id)
904 .unwrap_or(false)
905 || asset.name != expected_asset.name
906 || asset.blockchain != expected_asset.blockchain
907 || asset.standards != expected_asset.standards
908 || asset.metadata != expected_asset.metadata
909 || asset.symbol != expected_asset.symbol
910 || asset.decimals != expected_asset.decimals
911 {
912 return Err(format!("asset {} does not match expected asset", asset.id));
913 }
914 }
915
916 Ok(())
917}
918
919fn compare_arrays<T: PartialEq>(a: &[T], b: &[T]) -> bool {
920 a.len() == b.len()

Callers 2

install_with_all_entriesFunction · 0.85

Calls 4

iterMethod · 0.80
mapMethod · 0.80
list_assetsFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected