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

Function assert_initial_accounts

tests/integration/src/install_tests.rs:925–977  ·  view source on GitHub ↗
(
    env: &PocketIc,
    canister_id: Principal,
    requester: Principal,
    expected_accounts: &Vec<InitAccountInput>,
)

Source from the content-addressed store, hash-verified

923}
924
925fn assert_initial_accounts(
926 env: &PocketIc,
927 canister_id: Principal,
928 requester: Principal,
929 expected_accounts: &Vec<InitAccountInput>,
930) -> Result<(), String> {
931 let listed_accounts = list_accounts(env, canister_id, requester)
932 .expect("failed to get account")
933 .0
934 .expect("failed to get account");
935
936 if expected_accounts.len() != listed_accounts.accounts.len() {
937 return Err(format!(
938 "expected {} accounts, got {}",
939 expected_accounts.len(),
940 listed_accounts.accounts.len()
941 ));
942 }
943
944 for expected_account in expected_accounts {
945 let account = listed_accounts
946 .accounts
947 .iter()
948 .find(|account| account.name == expected_account.name)
949 .ok_or(format!("account {} not found", expected_account.name))?;
950
951 if !expected_account.assets.is_empty() && account.addresses.is_empty() {
952 return Err(format!(
953 "account {} has no addresses, expected some",
954 expected_account.name
955 ));
956 }
957
958 if account.name != expected_account.name
959 || account.metadata != expected_account.metadata
960 || !compare_arrays(
961 &account
962 .assets
963 .iter()
964 .map(|asset| asset.asset_id.clone())
965 .collect::<Vec<String>>(),
966 &expected_account.assets,
967 )
968 {
969 return Err(format!(
970 "account {} does not match expected account",
971 account.id
972 ));
973 }
974 }
975
976 Ok(())
977}
978
979fn assert_default_groups_exist(env: &PocketIc, canister_id: Principal, requester: Principal) {
980 let listed_user_groups = list_user_groups(env, canister_id, requester)

Callers 3

install_with_all_entriesFunction · 0.85

Calls 6

compare_arraysFunction · 0.85
iterMethod · 0.80
mapMethod · 0.80
list_accountsFunction · 0.50
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected