Skip to content

Commit

Permalink
Avoid exceeding ingress message size limit in tests (#4820)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Nov 22, 2023
1 parent 7b71028 commit 302ec00
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 53 deletions.
100 changes: 99 additions & 1 deletion backend/integration_tests/src/client/group_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ generate_update_call!(add_local_group_index_canister);
generate_update_call!(delete_frozen_group);
generate_update_call!(freeze_group);
generate_update_call!(unfreeze_group);
generate_update_call!(upgrade_community_canister_wasm);
generate_update_call!(upgrade_group_canister_wasm);
generate_update_call!(upgrade_local_group_index_canister_wasm);

pub mod happy_path {
use crate::User;
use candid::Principal;
use pocket_ic::PocketIc;
use types::{CanisterId, CommunityMatch, GroupMatch};
use types::{CanisterId, CanisterWasm, CommunityMatch, GroupMatch};

pub fn explore_communities(env: &PocketIc, sender: &User, group_index_canister_id: CanisterId) -> Vec<CommunityMatch> {
let response = super::explore_communities(
Expand Down Expand Up @@ -56,4 +60,98 @@ pub mod happy_path {
panic!("'explore_groups' error: {response:?}");
}
}

pub fn upgrade_local_group_index_canister_wasm(
env: &mut PocketIc,
sender: Principal,
group_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_local_group_index_canister_wasm(
env,
sender,
group_index_canister_id,
&group_index_canister::upgrade_local_group_index_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
group_index_canister::upgrade_local_group_index_canister_wasm::Response::Success
));
}

pub fn upgrade_group_canister_wasm(
env: &mut PocketIc,
sender: Principal,
group_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_group_canister_wasm(
env,
sender,
group_index_canister_id,
&group_index_canister::upgrade_group_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
group_index_canister::upgrade_group_canister_wasm::Response::Success
));
}

pub fn upgrade_community_canister_wasm(
env: &mut PocketIc,
sender: Principal,
group_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_community_canister_wasm(
env,
sender,
group_index_canister_id,
&group_index_canister::upgrade_community_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
group_index_canister::upgrade_community_canister_wasm::Response::Success
));
}

pub fn add_local_group_index_canister(
env: &mut PocketIc,
sender: Principal,
group_index_canister_id: CanisterId,
local_group_index_canister_id: CanisterId,
local_user_index_canister_id: CanisterId,
notifications_canister_id: CanisterId,
) {
let response = super::add_local_group_index_canister(
env,
sender,
group_index_canister_id,
&group_index_canister::add_local_group_index_canister::Args {
canister_id: local_group_index_canister_id,
local_user_index_canister_id,
notifications_canister_id,
},
);

assert!(matches!(
response,
group_index_canister::add_local_group_index_canister::Response::Success
));
}
}
54 changes: 54 additions & 0 deletions backend/integration_tests/src/client/notifications_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,57 @@ use notifications_index_canister::*;
// Updates
generate_update_call!(add_notifications_canister);
generate_update_call!(push_subscription);
generate_update_call!(upgrade_notifications_canister_wasm);

pub mod happy_path {
use candid::Principal;
use pocket_ic::PocketIc;
use types::{CanisterId, CanisterWasm};

pub fn upgrade_notifications_canister_wasm(
env: &mut PocketIc,
sender: Principal,
notifications_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_notifications_canister_wasm(
env,
sender,
notifications_index_canister_id,
&notifications_index_canister::upgrade_notifications_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
notifications_index_canister::upgrade_notifications_canister_wasm::Response::Success
));
}

pub fn add_notifications_canister(
env: &mut PocketIc,
sender: Principal,
notifications_index_canister_id: CanisterId,
notifications_canister_id: CanisterId,
local_user_index_canister_id: CanisterId,
local_group_index_canister_id: CanisterId,
) {
let response = super::add_notifications_canister(
env,
sender,
notifications_index_canister_id,
&notifications_index_canister::add_notifications_canister::Args {
canister_id: notifications_canister_id,
authorizers: vec![local_user_index_canister_id, local_group_index_canister_id],
},
);

assert!(matches!(
response,
notifications_index_canister::add_notifications_canister::Response::Success
));
}
}
25 changes: 24 additions & 1 deletion backend/integration_tests/src/client/storage_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod happy_path {
use pocket_ic::PocketIc;
use storage_index_canister::add_or_update_users::UserConfig;
use storage_index_canister::user::UserRecord;
use types::CanisterId;
use types::{CanisterId, CanisterWasm};
use utils::hasher::hash_bytes;

pub fn add_or_update_users(env: &mut PocketIc, sender: Principal, canister_id: CanisterId, users: Vec<UserConfig>) {
Expand Down Expand Up @@ -75,4 +75,27 @@ pub mod happy_path {
panic!("'user' error: {response:?}");
}
}

pub fn upgrade_notifications_canister_wasm(
env: &mut PocketIc,
sender: Principal,
storage_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_bucket_canister_wasm(
env,
sender,
storage_index_canister_id,
&storage_index_canister::upgrade_bucket_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
storage_index_canister::upgrade_bucket_canister_wasm::Response::Success
));
}
}
74 changes: 73 additions & 1 deletion backend/integration_tests/src/client/user_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ generate_update_call!(set_display_name);
generate_update_call!(set_username);
generate_update_call!(suspend_user);
generate_update_call!(unsuspend_user);
generate_update_call!(upgrade_local_user_index_canister_wasm);
generate_update_call!(upgrade_user_canister_wasm);

pub mod happy_path {
use candid::Principal;
use pocket_ic::PocketIc;
use types::{CanisterId, Cryptocurrency, DiamondMembershipDetails, DiamondMembershipPlanDuration, UserId, UserSummary};
use types::{
CanisterId, CanisterWasm, Cryptocurrency, DiamondMembershipDetails, DiamondMembershipPlanDuration, UserId, UserSummary,
};
use user_index_canister::users_v2::UserGroup;

pub fn current_user(
Expand Down Expand Up @@ -105,4 +108,73 @@ pub mod happy_path {

result.users
}

pub fn upgrade_local_user_index_canister_wasm(
env: &mut PocketIc,
sender: Principal,
user_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_local_user_index_canister_wasm(
env,
sender,
user_index_canister_id,
&user_index_canister::upgrade_local_user_index_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
user_index_canister::upgrade_local_user_index_canister_wasm::Response::Success
));
}

pub fn upgrade_user_canister_wasm(
env: &mut PocketIc,
sender: Principal,
user_index_canister_id: CanisterId,
wasm: CanisterWasm,
) {
let response = super::upgrade_user_canister_wasm(
env,
sender,
user_index_canister_id,
&user_index_canister::upgrade_user_canister_wasm::Args {
wasm,
filter: None,
use_for_new_canisters: None,
},
);

assert!(matches!(
response,
user_index_canister::upgrade_user_canister_wasm::Response::Success
));
}

pub fn add_local_user_index_canister(
env: &mut PocketIc,
sender: Principal,
user_index_canister_id: CanisterId,
local_user_index_canister_id: CanisterId,
notifications_canister_id: CanisterId,
) {
let response = super::add_local_user_index_canister(
env,
sender,
user_index_canister_id,
&user_index_canister::add_local_user_index_canister::Args {
canister_id: local_user_index_canister_id,
notifications_canister_id,
},
);

assert!(matches!(
response,
user_index_canister::add_local_user_index_canister::Response::Success
));
}
}
Loading

0 comments on commit 302ec00

Please sign in to comment.