diff --git a/backend/integration_tests/src/airdrop_bot_tests.rs b/backend/integration_tests/src/airdrop_bot_tests.rs index 023a27e498..e09055beb8 100644 --- a/backend/integration_tests/src/airdrop_bot_tests.rs +++ b/backend/integration_tests/src/airdrop_bot_tests.rs @@ -53,13 +53,7 @@ fn airdrop_end_to_end(v2: bool) { ); for user in users.iter() { - client::local_user_index::happy_path::join_channel( - env, - user.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user.principal, community_id, channel_id); } tick_many(env, 10); @@ -75,7 +69,7 @@ fn airdrop_end_to_end(v2: bool) { client::local_user_index::happy_path::invite_users_to_channel( env, &owner, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![airdrop_bot_user_id], diff --git a/backend/integration_tests/src/batched_summary_and_event_tests.rs b/backend/integration_tests/src/batched_summary_and_event_tests.rs index b79f5bd1af..9acc4400ea 100644 --- a/backend/integration_tests/src/batched_summary_and_event_tests.rs +++ b/backend/integration_tests/src/batched_summary_and_event_tests.rs @@ -46,7 +46,7 @@ fn get_batched_events_succeeds() { let local_user_index_canister::chat_events::Response::Success(result) = client::local_user_index::chat_events( env, user1.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, user1.canister()), &local_user_index_canister::chat_events::Args { requests: vec![ EventsArgs { @@ -99,11 +99,13 @@ fn get_batched_summaries_succeeds() { let start = now_millis(env); + let local_user_index = canister_ids.local_user_index(env, user1.canister()); + let local_user_index_canister::group_and_community_summary_updates::Response::Success(responses) = client::local_user_index::group_and_community_summary_updates( env, user1.principal, - canister_ids.local_user_index, + local_user_index, &local_user_index_canister::group_and_community_summary_updates::Args { requests: vec![ SummaryUpdatesArgs { @@ -142,7 +144,7 @@ fn get_batched_summaries_succeeds() { client::local_user_index::group_and_community_summary_updates( env, user1.principal, - canister_ids.local_user_index, + local_user_index, &local_user_index_canister::group_and_community_summary_updates::Args { requests: vec![ SummaryUpdatesArgs { diff --git a/backend/integration_tests/src/bot_tests.rs b/backend/integration_tests/src/bot_tests.rs index 8c59279798..219cbbf93a 100644 --- a/backend/integration_tests/src/bot_tests.rs +++ b/backend/integration_tests/src/bot_tests.rs @@ -78,7 +78,7 @@ fn e2e_bot_test() { env.tick(); // Confirm bot returned in `selected_initial` - let response = client::group::happy_path::selected_initial(env, &user, group_id); + let response = client::group::happy_path::selected_initial(env, user.principal, group_id); assert_eq!(response.bots.len(), 1); assert_eq!(response.bots[0].user_id, bot.id); @@ -99,8 +99,12 @@ fn e2e_bot_test() { }), chat, }; - let response = - client::local_user_index::access_token(env, user.principal, canister_ids.local_user_index, &access_token_args); + let response = client::local_user_index::access_token( + env, + user.principal, + canister_ids.local_user_index(env, group_id), + &access_token_args, + ); // Confirm bot is unauthorised assert!(matches!( @@ -119,11 +123,15 @@ fn e2e_bot_test() { assert_eq!(response.bots_added_or_updated[0].user_id, bot.id); // Try again to get an access token to call the greet command - let access_token = - match client::local_user_index::access_token(env, user.principal, canister_ids.local_user_index, &access_token_args) { - local_user_index_canister::access_token::Response::Success(access_token) => access_token, - response => panic!("'access_token' error: {response:?}"), - }; + let access_token = match client::local_user_index::access_token( + env, + user.principal, + canister_ids.local_user_index(env, group_id), + &access_token_args, + ) { + local_user_index_canister::access_token::Response::Success(access_token) => access_token, + response => panic!("'access_token' error: {response:?}"), + }; println!("ACCESS TOKEN: {access_token}"); @@ -133,7 +141,7 @@ fn e2e_bot_test() { let response = client::local_user_index::execute_bot_command( env, bot_principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::execute_bot_command::Args { action: BotAction::SendMessage(BotMessageAction { content: MessageContent::Text(TextContent { text: text.clone() }), @@ -167,7 +175,7 @@ fn e2e_bot_test() { let response = client::local_user_index::execute_bot_command( env, bot_principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::execute_bot_command::Args { action: BotAction::SendMessage(BotMessageAction { content: MessageContent::Text(TextContent { text: text.clone() }), diff --git a/backend/integration_tests/src/change_group_role_tests.rs b/backend/integration_tests/src/change_group_role_tests.rs index bb2b95f453..d66e4ae5e6 100644 --- a/backend/integration_tests/src/change_group_role_tests.rs +++ b/backend/integration_tests/src/change_group_role_tests.rs @@ -20,12 +20,12 @@ fn owner_can_promote_to_and_demote_from_owner() { client::group::happy_path::change_role(env, user1.principal, group_id, user2.user_id, GroupRole::Owner); - let summary1 = client::group::happy_path::summary(env, &user2, group_id); + let summary1 = client::group::happy_path::summary(env, user2.principal, group_id); assert!(matches!(summary1.role, GroupRole::Owner)); client::group::happy_path::change_role(env, user1.principal, group_id, user2.user_id, GroupRole::Admin); - let summary1 = client::group::happy_path::summary(env, &user2, group_id); + let summary1 = client::group::happy_path::summary(env, user2.principal, group_id); assert!(matches!(summary1.role, GroupRole::Admin)); } @@ -36,7 +36,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let group_name = random_string(); let group_id = client::user::happy_path::create_group(env, &user1, &group_name, true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); TestData { user1, user2, group_id } } diff --git a/backend/integration_tests/src/client/community.rs b/backend/integration_tests/src/client/community.rs index 265306182e..b9e834d641 100644 --- a/backend/integration_tests/src/client/community.rs +++ b/backend/integration_tests/src/client/community.rs @@ -8,6 +8,7 @@ pub const STABLE_MEMORY_MAP_MEMORY_ID: MemoryId = MemoryId::new(3); generate_msgpack_query_call!(channel_summary); generate_msgpack_query_call!(events); generate_msgpack_query_call!(events_by_index); +generate_msgpack_query_call!(local_user_index); generate_msgpack_query_call!(search_channel); generate_msgpack_query_call!(selected_channel_initial); generate_msgpack_query_call!(selected_channel_updates_v2); @@ -53,10 +54,10 @@ pub mod happy_path { use pocket_ic::PocketIc; use testing::rng::random_from_u128; use types::{ - AccessGate, ChannelId, ChatId, CommunityCanisterChannelSummary, CommunityCanisterCommunitySummary, - CommunityCanisterCommunitySummaryUpdates, CommunityId, CommunityRole, EventIndex, EventsResponse, GroupReplyContext, - GroupRole, MessageContentInitial, MessageId, MessageIndex, PollVotes, Reaction, Rules, SlashCommandPermissions, - TextContent, TimestampMillis, UserId, VoteOperation, + AccessGate, CanisterId, ChannelId, ChatId, CommunityCanisterChannelSummary, CommunityCanisterCommunitySummary, + CommunityCanisterCommunitySummaryUpdates, CommunityId, CommunityRole, Empty, EventIndex, EventsResponse, + GroupReplyContext, GroupRole, MessageContentInitial, MessageId, MessageIndex, PollVotes, Reaction, Rules, + SlashCommandPermissions, TextContent, TimestampMillis, UserId, VoteOperation, }; pub fn create_channel( @@ -126,6 +127,20 @@ pub mod happy_path { } } + pub fn join_community( + env: &mut PocketIc, + sender: Principal, + community_id: CommunityId, + ) -> CommunityCanisterCommunitySummary { + let local_user_index = local_user_index(env, community_id); + crate::client::local_user_index::happy_path::join_community(env, sender, local_user_index, community_id, None) + } + + pub fn join_channel(env: &mut PocketIc, sender: Principal, community_id: CommunityId, channel_id: ChannelId) { + let local_user_index = local_user_index(env, community_id); + crate::client::local_user_index::happy_path::join_channel(env, sender, local_user_index, community_id, channel_id); + } + pub fn leave_channel(env: &mut PocketIc, sender: Principal, community_id: CommunityId, channel_id: ChannelId) { let response = super::leave_channel( env, @@ -414,10 +429,10 @@ pub mod happy_path { } } - pub fn summary(env: &PocketIc, sender: &User, community_id: CommunityId) -> CommunityCanisterCommunitySummary { + pub fn summary(env: &PocketIc, sender: Principal, community_id: CommunityId) -> CommunityCanisterCommunitySummary { let response = super::summary( env, - sender.principal, + sender, community_id.into(), &community_canister::summary::Args { on_behalf_of: None, @@ -433,13 +448,13 @@ pub mod happy_path { pub fn summary_updates( env: &PocketIc, - sender: &User, + sender: Principal, community_id: CommunityId, updates_since: TimestampMillis, ) -> Option { match super::summary_updates( env, - sender.principal, + sender, community_id.into(), &community_canister::summary_updates::Args { on_behalf_of: None, @@ -455,12 +470,12 @@ pub mod happy_path { pub fn selected_initial( env: &PocketIc, - sender: &User, + sender: Principal, community_id: CommunityId, ) -> community_canister::selected_initial::SuccessResult { let response = super::selected_initial( env, - sender.principal, + sender, community_id.into(), &community_canister::selected_initial::Args { invite_code: None }, ); @@ -742,4 +757,11 @@ pub mod happy_path { response => panic!("'update_bot' error: {response:?}"), } } + + pub fn local_user_index(env: &PocketIc, community_id: CommunityId) -> CanisterId { + let community_canister::local_user_index::Response::Success(local_user_index) = + super::local_user_index(env, Principal::anonymous(), community_id.into(), &Empty {}); + + local_user_index + } } diff --git a/backend/integration_tests/src/client/group.rs b/backend/integration_tests/src/client/group.rs index b05a2394c5..7f1c6eb67b 100644 --- a/backend/integration_tests/src/client/group.rs +++ b/backend/integration_tests/src/client/group.rs @@ -8,6 +8,7 @@ pub const CHAT_EVENTS_MEMORY_ID: MemoryId = MemoryId::new(3); generate_msgpack_query_call!(events); generate_msgpack_query_call!(events_by_index); generate_msgpack_query_call!(events_window); +generate_msgpack_query_call!(local_user_index); generate_msgpack_query_call!(public_summary); generate_msgpack_query_call!(selected_initial); generate_msgpack_query_call!(selected_updates_v2); @@ -49,9 +50,10 @@ pub mod happy_path { use pocket_ic::PocketIc; use testing::rng::random_from_u128; use types::{ - ChatId, EventIndex, EventsResponse, GroupCanisterGroupChatSummary, GroupCanisterGroupChatSummaryUpdates, - GroupReplyContext, GroupRole, MessageContentInitial, MessageId, MessageIndex, Milliseconds, PollVotes, Reaction, - SlashCommandPermissions, TextContent, TimestampMillis, UserId, VideoCallType, VoteOperation, + CanisterId, ChatId, Empty, EventIndex, EventsResponse, GroupCanisterGroupChatSummary, + GroupCanisterGroupChatSummaryUpdates, GroupReplyContext, GroupRole, MessageContentInitial, MessageId, MessageIndex, + Milliseconds, PollVotes, Reaction, SlashCommandPermissions, TextContent, TimestampMillis, UserId, VideoCallType, + VoteOperation, }; pub fn send_text_message( @@ -159,6 +161,11 @@ pub mod happy_path { } } + pub fn join_group(env: &mut PocketIc, sender: Principal, group_chat_id: ChatId) { + let local_user_index = local_user_index(env, group_chat_id); + crate::client::local_user_index::happy_path::join_group(env, sender, local_user_index, group_chat_id); + } + pub fn update_group( env: &mut PocketIc, sender: Principal, @@ -325,15 +332,10 @@ pub mod happy_path { pub fn selected_initial( env: &PocketIc, - sender: &User, + sender: Principal, group_chat_id: ChatId, ) -> group_canister::selected_initial::SuccessResult { - let response = super::selected_initial( - env, - sender.principal, - group_chat_id.into(), - &group_canister::selected_initial::Args {}, - ); + let response = super::selected_initial(env, sender, group_chat_id.into(), &group_canister::selected_initial::Args {}); match response { group_canister::selected_initial::Response::Success(result) => result, @@ -361,10 +363,10 @@ pub mod happy_path { } } - pub fn summary(env: &PocketIc, sender: &User, group_chat_id: ChatId) -> GroupCanisterGroupChatSummary { + pub fn summary(env: &PocketIc, sender: Principal, group_chat_id: ChatId) -> GroupCanisterGroupChatSummary { let response = super::summary( env, - sender.principal, + sender, group_chat_id.into(), &group_canister::summary::Args { on_behalf_of: None }, ); @@ -377,13 +379,13 @@ pub mod happy_path { pub fn summary_updates( env: &PocketIc, - sender: &User, + sender: Principal, group_chat_id: ChatId, updates_since: TimestampMillis, ) -> Option { let response = super::summary_updates( env, - sender.principal, + sender, group_chat_id.into(), &group_canister::summary_updates::Args { on_behalf_of: None, @@ -604,4 +606,11 @@ pub mod happy_path { response => panic!("'update_bot' error: {response:?}"), } } + + pub fn local_user_index(env: &PocketIc, group_id: ChatId) -> CanisterId { + let group_canister::local_user_index::Response::Success(local_user_index) = + super::local_user_index(env, Principal::anonymous(), group_id.into(), &Empty {}); + + local_user_index + } } diff --git a/backend/integration_tests/src/client/local_user_index.rs b/backend/integration_tests/src/client/local_user_index.rs index 92941f9880..2a1c5e1f2d 100644 --- a/backend/integration_tests/src/client/local_user_index.rs +++ b/backend/integration_tests/src/client/local_user_index.rs @@ -53,6 +53,7 @@ pub mod happy_path { principal, user_id: res.user_id, public_key, + local_user_index: canister_id, }, response => panic!("'register_user' error: {response:?}"), } diff --git a/backend/integration_tests/src/client/mod.rs b/backend/integration_tests/src/client/mod.rs index 9f82380566..8afe6b7543 100644 --- a/backend/integration_tests/src/client/mod.rs +++ b/backend/integration_tests/src/client/mod.rs @@ -190,10 +190,12 @@ fn register_user_internal( true, ); + let local_user_index = user_index::happy_path::user_registration_canister(env, canister_ids.user_index); + let user = local_user_index::happy_path::register_user_with_referrer( env, Principal::self_authenticating(&create_identity_result.user_key), - canister_ids.local_user_index, + local_user_index, create_identity_result.user_key, referral_code, ); diff --git a/backend/integration_tests/src/client/registry.rs b/backend/integration_tests/src/client/registry.rs index 4315bba44f..7ed409ff12 100644 --- a/backend/integration_tests/src/client/registry.rs +++ b/backend/integration_tests/src/client/registry.rs @@ -13,6 +13,7 @@ generate_msgpack_update_call!(set_token_enabled); pub mod happy_path { use super::*; + use crate::client::INIT_CYCLES_BALANCE; use candid::Principal; use pocket_ic::PocketIc; use registry_canister::subnets::Subnet; @@ -37,6 +38,10 @@ pub mod happy_path { let subnets::Response::Success(subnets) = super::subnets(env, sender, registry_canister_id, &Empty {}); if let Some(subnet) = subnets.into_iter().find(|s| s.subnet_id == subnet_id) { + env.add_cycles(subnet.local_user_index, INIT_CYCLES_BALANCE); + env.add_cycles(subnet.local_group_index, INIT_CYCLES_BALANCE); + env.add_cycles(subnet.notifications_canister, INIT_CYCLES_BALANCE); + return subnet; } } diff --git a/backend/integration_tests/src/client/user_index.rs b/backend/integration_tests/src/client/user_index.rs index a16b7f0e76..7108480946 100644 --- a/backend/integration_tests/src/client/user_index.rs +++ b/backend/integration_tests/src/client/user_index.rs @@ -9,6 +9,7 @@ generate_msgpack_query_call!(platform_moderators); generate_msgpack_query_call!(platform_moderators_group); generate_query_call!(public_key); generate_msgpack_query_call!(user); +generate_msgpack_query_call!(user_registration_canister); generate_msgpack_query_call!(users); generate_msgpack_query_call!(users_chit); generate_msgpack_query_call!(bot_updates); @@ -314,6 +315,15 @@ pub mod happy_path { } } + pub fn user_registration_canister(env: &PocketIc, user_index_canister_id: CanisterId) -> CanisterId { + let response = super::user_registration_canister(env, Principal::anonymous(), user_index_canister_id, &Empty {}); + + match response { + user_index_canister::user_registration_canister::Response::Success(local_user_index) => local_user_index, + response => panic!("'user_registration_canister' error: {response:?}"), + } + } + fn upload_wasm_in_chunks( env: &mut PocketIc, sender: Principal, diff --git a/backend/integration_tests/src/communities/access_gate_expiry_tests.rs b/backend/integration_tests/src/communities/access_gate_expiry_tests.rs index 257cc2acd1..03c2e9d4ef 100644 --- a/backend/integration_tests/src/communities/access_gate_expiry_tests.rs +++ b/backend/integration_tests/src/communities/access_gate_expiry_tests.rs @@ -454,7 +454,7 @@ fn invited_users_pass_composite_gate_then_expire_later(container_type: Container fn has_user_lapsed(env: &mut PocketIc, user: &User, container: &Container) -> bool { match container { Container::Community(community_id) => { - let summary = client::community::happy_path::summary(env, user, *community_id); + let summary = client::community::happy_path::summary(env, user.principal, *community_id); summary.membership.map_or(false, |m| m.lapsed) } Container::Channel(community_id, channel_id) => { @@ -462,7 +462,7 @@ fn has_user_lapsed(env: &mut PocketIc, user: &User, container: &Container) -> bo summary.membership.map_or(false, |m| m.lapsed) } Container::Group(group_id) => { - let summary = client::group::happy_path::summary(env, user, *group_id); + let summary = client::group::happy_path::summary(env, user.principal, *group_id); summary.membership.map_or(false, |m| m.lapsed) } } @@ -482,76 +482,52 @@ fn join_container( client::local_user_index::happy_path::invite_users_to_community( env, owner, - canister_ids.local_user_index, + canister_ids.local_user_index(env, *community_id), *community_id, vec![user.user_id], ); } - client::local_user_index::happy_path::join_community( - env, - user.principal, - canister_ids.local_user_index, - *community_id, - None, - ); + client::community::happy_path::join_community(env, user.principal, *community_id); } Container::Channel(community_id, channel_id) => { if invite { client::local_user_index::happy_path::invite_users_to_community( env, owner, - canister_ids.local_user_index, + canister_ids.local_user_index(env, *community_id), *community_id, vec![user.user_id], ); - client::local_user_index::happy_path::join_community( - env, - user.principal, - canister_ids.local_user_index, - *community_id, - None, - ); + client::community::happy_path::join_community(env, user.principal, *community_id); } if invite { client::local_user_index::happy_path::invite_users_to_channel( env, owner, - canister_ids.local_user_index, + canister_ids.local_user_index(env, *community_id), *community_id, *channel_id, vec![user.user_id], ); } - client::local_user_index::happy_path::join_channel( - env, - user.principal, - canister_ids.local_user_index, - *community_id, - *channel_id, - ); + client::community::happy_path::join_channel(env, user.principal, *community_id, *channel_id); } Container::Group(group_id) => { if invite { client::local_user_index::happy_path::invite_users_to_group( env, owner, - canister_ids.local_user_index, + canister_ids.local_user_index(env, *group_id), *group_id, vec![user.user_id], ); } - client::local_user_index::happy_path::join_group( - // - env, - user.principal, - canister_ids.local_user_index, - *group_id, - ); + client::group::happy_path::join_group(env, user.principal, *group_id); } } } diff --git a/backend/integration_tests/src/communities/cancel_invites_tests.rs b/backend/integration_tests/src/communities/cancel_invites_tests.rs index 4486cda063..5d3b5a81c5 100644 --- a/backend/integration_tests/src/communities/cancel_invites_tests.rs +++ b/backend/integration_tests/src/communities/cancel_invites_tests.rs @@ -27,7 +27,7 @@ fn cancel_invites_succeeds() { client::local_user_index::happy_path::invite_users_to_community( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, vec![user2.user_id, user3.user_id], ); @@ -36,7 +36,7 @@ fn cancel_invites_succeeds() { env.tick(); - let community_details = client::community::happy_path::selected_initial(env, &user1, community_id); + let community_details = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!(community_details.invited_users, vec![user3.user_id]); } @@ -62,7 +62,7 @@ fn cancel_channel_invites_succeeds() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![user2.user_id, user3.user_id], @@ -70,7 +70,7 @@ fn cancel_channel_invites_succeeds() { client::community::happy_path::cancel_invites(env, user1.principal, community_id, vec![user2.user_id], Some(channel_id)); - let community_details = client::community::happy_path::selected_initial(env, &user1, community_id); + let community_details = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!( community_details.invited_users.into_iter().sorted().collect_vec(), vec![user2.user_id, user3.user_id].into_iter().sorted().collect_vec() @@ -103,7 +103,7 @@ fn cancelling_community_invites_cancels_all_channel_invites() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel1_id, vec![user2.user_id, user3.user_id], @@ -112,7 +112,7 @@ fn cancelling_community_invites_cancels_all_channel_invites() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel2_id, vec![user2.user_id, user3.user_id], @@ -120,7 +120,7 @@ fn cancelling_community_invites_cancels_all_channel_invites() { client::community::happy_path::cancel_invites(env, user1.principal, community_id, vec![user2.user_id], None); - let community_details = client::community::happy_path::selected_initial(env, &user1, community_id); + let community_details = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!(community_details.invited_users, vec![user3.user_id]); let channel1_details = client::community::happy_path::selected_channel_initial(env, &user1, community_id, channel1_id); @@ -150,18 +150,12 @@ fn cancel_invites_not_authorized() { client::local_user_index::happy_path::invite_users_to_community( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, vec![user2.user_id, user3.user_id], ); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); let response = client::community::cancel_invites( env, @@ -178,7 +172,7 @@ fn cancel_invites_not_authorized() { community_canister::cancel_invites::Response::NotAuthorized )); - let community_details = client::community::happy_path::selected_initial(env, &user2, community_id); + let community_details = client::community::happy_path::selected_initial(env, user2.principal, community_id); assert_eq!(community_details.invited_users, vec![user3.user_id]); } diff --git a/backend/integration_tests/src/communities/convert_group_into_community_tests.rs b/backend/integration_tests/src/communities/convert_group_into_community_tests.rs index 0c366b9960..e427e12265 100644 --- a/backend/integration_tests/src/communities/convert_group_into_community_tests.rs +++ b/backend/integration_tests/src/communities/convert_group_into_community_tests.rs @@ -51,19 +51,19 @@ fn convert_into_community_succeeds() { let expected_channel_names = vec![group_name]; - let summary1 = client::community::happy_path::summary(env, &user1, result.community_id); + let summary1 = client::community::happy_path::summary(env, user1.principal, result.community_id); assert_eq!( summary1.channels.into_iter().map(|c| c.name).collect_vec(), expected_channel_names ); - let summary2 = client::community::happy_path::summary(env, &user2, result.community_id); + let summary2 = client::community::happy_path::summary(env, user2.principal, result.community_id); assert_eq!( summary2.channels.into_iter().map(|c| c.name).collect_vec(), expected_channel_names ); - let selected_initial = client::community::happy_path::selected_initial(env, &user1, result.community_id); + let selected_initial = client::community::happy_path::selected_initial(env, user1.principal, result.community_id); assert_eq!(selected_initial.blocked_users.len(), 1); let selected_channel_initial = @@ -112,8 +112,8 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let group_name = random_string(); let group_id = client::user::happy_path::create_group(env, &user1, &group_name, true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); - client::local_user_index::happy_path::join_group(env, user3.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); + client::group::happy_path::join_group(env, user3.principal, group_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/communities/create_channel_tests.rs b/backend/integration_tests/src/communities/create_channel_tests.rs index 4a0e1b9c99..434cf7eaef 100644 --- a/backend/integration_tests/src/communities/create_channel_tests.rs +++ b/backend/integration_tests/src/communities/create_channel_tests.rs @@ -24,7 +24,7 @@ fn create_channel_succeeds(is_public: bool) { let channel_id = client::community::happy_path::create_channel(env, user.principal, community_id, is_public, channel_name.clone()); - let summary = client::community::happy_path::summary(env, &user, community_id); + let summary = client::community::happy_path::summary(env, user.principal, community_id); assert_eq!(summary.channels.len(), 2); assert!(summary @@ -48,20 +48,8 @@ fn existing_users_joined_to_new_public_channel() { let user2 = client::register_user(env, canister_ids); let user3 = client::register_user(env, canister_ids); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); - client::local_user_index::happy_path::join_community( - env, - user3.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); + client::community::happy_path::join_community(env, user3.principal, community_id); let create_channel_response = client::community::create_channel( env, @@ -89,8 +77,8 @@ fn existing_users_joined_to_new_public_channel() { panic!() }; - let user2_summary = client::community::happy_path::summary(env, &user2, community_id); - let user3_summary = client::community::happy_path::summary(env, &user3, community_id); + let user2_summary = client::community::happy_path::summary(env, user2.principal, community_id); + let user3_summary = client::community::happy_path::summary(env, user3.principal, community_id); assert!(user2_summary.channels.iter().any(|c| c.channel_id == channel_id)); assert!(user3_summary.channels.iter().any(|c| c.channel_id == channel_id)); diff --git a/backend/integration_tests/src/communities/delete_channel_tests.rs b/backend/integration_tests/src/communities/delete_channel_tests.rs index c69e27dccb..fca63e18c6 100644 --- a/backend/integration_tests/src/communities/delete_channel_tests.rs +++ b/backend/integration_tests/src/communities/delete_channel_tests.rs @@ -43,7 +43,7 @@ fn delete_channel_succeeds(as_owner: bool) { community_canister::delete_channel::Response::NotAuthorized )); } - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); assert_ne!(summary.channels.iter().any(|c| c.channel_id == channel_id1), as_owner); } @@ -112,14 +112,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_name = random_string(); let community_id = client::user::happy_path::create_community(env, &user1, &community_name, true, vec![random_string(), random_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::join_community(env, user2.principal, community_id); let channel_id1 = summary.channels.first().unwrap().channel_id; let channel_id2 = summary.channels.last().unwrap().channel_id; diff --git a/backend/integration_tests/src/communities/disappearing_message_tests.rs b/backend/integration_tests/src/communities/disappearing_message_tests.rs index b13fadbcf1..1a14bace2d 100644 --- a/backend/integration_tests/src/communities/disappearing_message_tests.rs +++ b/backend/integration_tests/src/communities/disappearing_message_tests.rs @@ -117,7 +117,7 @@ fn stable_memory_garbage_collected_after_messages_disappear() { let user = client::register_diamond_user(env, canister_ids, *controller); let community_id = client::user::happy_path::create_community(env, &user, &random_string(), true, vec![random_string()]); - let channel_id = client::community::happy_path::summary(env, &user, community_id) + let channel_id = client::community::happy_path::summary(env, user.principal, community_id) .channels .first() .unwrap() diff --git a/backend/integration_tests/src/communities/import_group_tests.rs b/backend/integration_tests/src/communities/import_group_tests.rs index 1e41c85270..d5a0c0f421 100644 --- a/backend/integration_tests/src/communities/import_group_tests.rs +++ b/backend/integration_tests/src/communities/import_group_tests.rs @@ -48,19 +48,19 @@ fn import_group_succeeds() { let expected_channel_names: Vec<_> = default_channels.into_iter().chain([group_name]).sorted().collect(); - let community_summary1 = client::community::happy_path::summary(env, &user1, community_id); + let community_summary1 = client::community::happy_path::summary(env, user1.principal, community_id); assert_eq!( community_summary1.channels.into_iter().map(|c| c.name).sorted().collect_vec(), expected_channel_names ); - let community_summary2 = client::community::happy_path::summary(env, &user2, community_id); + let community_summary2 = client::community::happy_path::summary(env, user2.principal, community_id); assert_eq!( community_summary2.channels.into_iter().map(|c| c.name).sorted().collect_vec(), expected_channel_names ); - let community_summary3 = client::community::happy_path::summary(env, &user3, community_id); + let community_summary3 = client::community::happy_path::summary(env, user3.principal, community_id); assert_eq!( community_summary3.channels.into_iter().map(|c| c.name).sorted().collect_vec(), expected_channel_names @@ -74,7 +74,7 @@ fn import_group_succeeds() { assert!(initial_state2.group_chats.summaries.is_empty()); assert_eq!(initial_state2.communities.summaries.len(), 1); - let selected_initial = client::community::happy_path::selected_initial(env, &user1, community_id); + let selected_initial = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!(selected_initial.blocked_users.len(), 1); let selected_channel_initial = @@ -355,18 +355,12 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_name = random_string(); let group_id = client::user::happy_path::create_group(env, &user1, &group_name, true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); let default_channels: Vec<_> = (1..5).map(|_| random_string()).collect(); let community_id = client::user::happy_path::create_community(env, &user1, &community_name, true, default_channels.clone()); - client::local_user_index::happy_path::join_community( - env, - user3.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user3.principal, community_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/communities/join_channel_tests.rs b/backend/integration_tests/src/communities/join_channel_tests.rs index 6b0b657e03..f375ed4d47 100644 --- a/backend/integration_tests/src/communities/join_channel_tests.rs +++ b/backend/integration_tests/src/communities/join_channel_tests.rs @@ -27,17 +27,11 @@ fn join_public_channel_succeeds() { // First user2 needs to leave the channel because they were joined automatically client::community::happy_path::leave_channel(env, user2.principal, community_id, channel_id); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); tick_many(env, 3); - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); assert!(summary.channels.iter().any(|c| c.channel_id == channel_id)); @@ -70,7 +64,7 @@ fn join_private_channel_fails() { let response = client::local_user_index::join_channel( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::join_channel::Args { community_id, channel_id, @@ -106,23 +100,17 @@ fn join_private_community_with_invitation_succeeds() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![user2.user_id], ); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); env.tick(); - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); assert!(summary.channels.iter().any(|c| c.channel_id == channel_id)); } @@ -149,7 +137,7 @@ fn join_community_and_channel_in_single_call_succeeds() { let response = client::local_user_index::join_channel( env, user3.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::join_channel::Args { community_id, channel_id, @@ -187,7 +175,7 @@ fn invite_non_community_member_to_channel_succeeds() { let invite_users_response = client::local_user_index::invite_users_to_channel( env, user1.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::invite_users_to_channel::Args { community_id, channel_id, @@ -204,7 +192,7 @@ fn invite_non_community_member_to_channel_succeeds() { let join_channel_response = client::local_user_index::join_channel( env, user3.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::join_channel::Args { community_id, channel_id, @@ -240,7 +228,7 @@ fn invite_to_channel_oc_bot_message_received() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![user2.user_id], @@ -285,21 +273,8 @@ fn channel_marked_as_read_after_joining() { let user3 = client::register_user(env, canister_ids); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); - - client::local_user_index::happy_path::join_channel( - env, - user3.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); + client::community::happy_path::join_channel(env, user3.principal, community_id, channel_id); tick_many(env, 3); @@ -337,13 +312,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_id = client::user::happy_path::create_community(env, &user1, &community_name, true, vec!["abcde".to_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); let channel_id = client::community::happy_path::create_channel(env, user1.principal, community_id, public, channel_name); diff --git a/backend/integration_tests/src/communities/join_community_tests.rs b/backend/integration_tests/src/communities/join_community_tests.rs index 3b435c1fac..29a67c4b0a 100644 --- a/backend/integration_tests/src/communities/join_community_tests.rs +++ b/backend/integration_tests/src/communities/join_community_tests.rs @@ -25,13 +25,7 @@ fn join_public_community_succeeds() { community_id, } = init_test_data(env, canister_ids, *controller, true); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); env.tick(); @@ -63,7 +57,7 @@ fn join_private_community_fails() { let response = client::local_user_index::join_community( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::join_community::Args { community_id, invite_code: None, @@ -97,18 +91,12 @@ fn join_private_community_with_invitation_succeeds() { client::local_user_index::happy_path::invite_users_to_community( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, vec![user2.user_id], ); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); env.tick(); @@ -148,7 +136,7 @@ fn join_private_community_using_invite_code_succeeds() { let response = client::local_user_index::join_community( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), &local_user_index_canister::join_community::Args { community_id, invite_code: Some(invite_code), @@ -192,7 +180,7 @@ fn invite_to_community_oc_bot_message_received() { client::local_user_index::happy_path::invite_users_to_community( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, vec![user2.user_id], ); @@ -244,13 +232,7 @@ fn default_channels_marked_as_read_after_joining() { client::community::happy_path::send_text_message(env, &user1, community_id, default3, None, random_string(), None); } - client::local_user_index::happy_path::join_community( - env, - user3.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user3.principal, community_id); tick_many(env, 3); @@ -304,13 +286,7 @@ fn user_joined_to_all_public_channels(diamond_member: bool) { AccessGate::DiamondMember, ); - let community_summary = client::local_user_index::happy_path::join_community( - env, - user.principal, - canister_ids.local_user_index, - community_id, - None, - ); + let community_summary = client::community::happy_path::join_community(env, user.principal, community_id); let channel_ids: HashSet<_> = community_summary.channels.iter().map(|c| c.channel_id).collect(); diff --git a/backend/integration_tests/src/communities/leave_community_tests.rs b/backend/integration_tests/src/communities/leave_community_tests.rs index 12205f0b8a..b3fd6a0779 100644 --- a/backend/integration_tests/src/communities/leave_community_tests.rs +++ b/backend/integration_tests/src/communities/leave_community_tests.rs @@ -22,13 +22,7 @@ fn leave_community_succeeds() { community_id, } = init_test_data(env, canister_ids, *controller, true); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); env.tick(); @@ -57,13 +51,7 @@ fn cannot_leave_community_if_last_owner() { community_id, } = init_test_data(env, canister_ids, *controller, true); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); let leave_community_response = client::user::leave_community( env, @@ -98,13 +86,7 @@ fn cannot_leave_community_if_last_owner_of_a_channel() { community_id, } = init_test_data(env, canister_ids, *controller, true); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); client::community::happy_path::change_role(env, user1.principal, community_id, user2.user_id, CommunityRole::Owner); client::community::happy_path::create_channel(env, user2.principal, community_id, true, random_string()); diff --git a/backend/integration_tests/src/communities/p2p_swap_tests.rs b/backend/integration_tests/src/communities/p2p_swap_tests.rs index 66e99d2368..2220833b8b 100644 --- a/backend/integration_tests/src/communities/p2p_swap_tests.rs +++ b/backend/integration_tests/src/communities/p2p_swap_tests.rs @@ -24,19 +24,13 @@ fn p2p_swap_in_channel_succeeds() { let user2 = client::register_user(env, canister_ids); let community_id = client::user::happy_path::create_community(env, &user1, &random_string(), true, vec![random_string()]); - let channel_id = client::community::happy_path::summary(env, &user1, community_id) + let channel_id = client::community::happy_path::summary(env, user1.principal, community_id) .channels .first() .unwrap() .channel_id; - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); client::ledger::happy_path::transfer( env, @@ -146,18 +140,12 @@ fn cancel_p2p_swap_in_channel_succeeds(delete_message: bool) { let user2 = client::register_user(env, canister_ids); let community_id = client::user::happy_path::create_community(env, &user1, &random_string(), true, vec![random_string()]); - let channel_id = client::community::happy_path::summary(env, &user1, community_id) + let channel_id = client::community::happy_path::summary(env, user1.principal, community_id) .channels .first() .unwrap() .channel_id; - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); let original_chat_balance = 11_000_000_000; diff --git a/backend/integration_tests/src/communities/remove_member_from_channel_tests.rs b/backend/integration_tests/src/communities/remove_member_from_channel_tests.rs index 3f1b09a8d5..76ea8ad188 100644 --- a/backend/integration_tests/src/communities/remove_member_from_channel_tests.rs +++ b/backend/integration_tests/src/communities/remove_member_from_channel_tests.rs @@ -27,21 +27,15 @@ fn remove_member_from_channel_succeeds() { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![user2.user_id], ); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); - let user2_summary1 = client::community::happy_path::summary(env, &user2, community_id); + let user2_summary1 = client::community::happy_path::summary(env, user2.principal, community_id); assert!(user2_summary1.channels.iter().any(|c| c.channel_id == channel_id)); let remove_member_response = client::community::remove_member_from_channel( @@ -60,11 +54,11 @@ fn remove_member_from_channel_succeeds() { )); // Check that the channel is no longer returned for user2 - let user2_summary2 = client::community::happy_path::summary(env, &user2, community_id); + let user2_summary2 = client::community::happy_path::summary(env, user2.principal, community_id); assert!(!user2_summary2.channels.iter().any(|c| c.channel_id == channel_id)); // Check that the channel is still returned for user1 - let user1_summary = client::community::happy_path::summary(env, &user1, community_id); + let user1_summary = client::community::happy_path::summary(env, user1.principal, community_id); assert!(user1_summary.channels.iter().any(|c| c.channel_id == channel_id)); } @@ -77,13 +71,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_id = client::user::happy_path::create_community(env, &user1, &community_name, true, vec!["abcde".to_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); TestData { user1, diff --git a/backend/integration_tests/src/communities/remove_member_tests.rs b/backend/integration_tests/src/communities/remove_member_tests.rs index 447e68aae8..5c0f3de86c 100644 --- a/backend/integration_tests/src/communities/remove_member_tests.rs +++ b/backend/integration_tests/src/communities/remove_member_tests.rs @@ -45,7 +45,7 @@ fn block_user_succeeds(user_has_left_community: bool) { )); // Check user has been blocked - let response = client::community::happy_path::selected_initial(env, &user1, community_id); + let response = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert!(response.blocked_users.contains(&user2.user_id)); assert!(!response.members.iter().any(|member| member.user_id == user2.user_id)); @@ -135,7 +135,7 @@ fn remove_user_succeeds() { )); // Check user has been removed - let response = client::community::happy_path::selected_initial(env, &user1, community_id); + let response = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert!(!response.blocked_users.contains(&user2.user_id)); assert!(!response.members.iter().any(|member| member.user_id == user2.user_id)); @@ -180,7 +180,7 @@ fn community_referral_added_and_removed() { } = init_test_data(env, canister_ids, *controller, false); // Check the referral has been added - method 1 - let response1 = client::community::happy_path::selected_initial(env, &user1, community_id); + let response1 = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert!(response1.referrals.contains(&user2.user_id)); // Check the referral has been added - method 2 @@ -205,7 +205,7 @@ fn community_referral_added_and_removed() { )); // Check the referral has been removed - method 1 - let response3 = client::community::happy_path::selected_initial(env, &user1, community_id); + let response3 = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert!(response3.referrals.is_empty()); // Check the referral has been removed - method 2 @@ -228,19 +228,13 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr client::local_user_index::happy_path::invite_users_to_community( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, vec![user2.user_id], ); } - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/communities/search_channel_tests.rs b/backend/integration_tests/src/communities/search_channel_tests.rs index c413056041..580eebca48 100644 --- a/backend/integration_tests/src/communities/search_channel_tests.rs +++ b/backend/integration_tests/src/communities/search_channel_tests.rs @@ -49,17 +49,11 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let user2 = client::register_user(env, canister_ids); let community_id = client::user::happy_path::create_community(env, &user1, &random_string(), true, vec!["general".to_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); env.tick(); - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); let channel_id = summary.channels.iter().find(|c| c.name == "general").unwrap().channel_id; client::community::happy_path::send_text_message(env, &user1, community_id, channel_id, None, "Hello, world!", None); diff --git a/backend/integration_tests/src/communities/send_message_tests.rs b/backend/integration_tests/src/communities/send_message_tests.rs index d0cc1fb409..7a94c8427c 100644 --- a/backend/integration_tests/src/communities/send_message_tests.rs +++ b/backend/integration_tests/src/communities/send_message_tests.rs @@ -69,7 +69,7 @@ fn send_crypto_in_channel(with_c2c_error: bool) { } = init_test_data(env, canister_ids, *controller); if with_c2c_error { - stop_canister(env, canister_ids.local_group_index, community_id.into()); + stop_canister(env, canister_ids.local_group_index(env, community_id), community_id.into()); } let send_message_result = client::user::send_message_with_transfer_to_channel( @@ -123,7 +123,7 @@ fn send_crypto_in_channel(with_c2c_error: bool) { if with_c2c_error { env.advance_time(Duration::from_secs(10)); - start_canister(env, canister_ids.local_group_index, community_id.into()); + start_canister(env, canister_ids.local_group_index(env, community_id), community_id.into()); env.tick(); } @@ -641,8 +641,8 @@ fn send_message_with_rules_leads_to_expected_summary_and_selected_states() { } fn get_community_rules(env: &mut PocketIc, user: &User, community_id: CommunityId) -> ChatRules { - let summary = client::community::happy_path::summary(env, user, community_id); - let selected = client::community::happy_path::selected_initial(env, user, community_id); + let summary = client::community::happy_path::summary(env, user.principal, community_id); + let selected = client::community::happy_path::selected_initial(env, user.principal, community_id); ChatRules { enabled: selected.chat_rules.enabled, @@ -708,17 +708,11 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let user2 = client::register_user(env, canister_ids); let community_id = client::user::happy_path::create_community(env, &user1, &random_string(), true, vec!["general".to_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); env.tick(); - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); let channel_id = summary.channels.iter().find(|c| c.name == "general").unwrap().channel_id; TestData { diff --git a/backend/integration_tests/src/communities/update_channel_tests.rs b/backend/integration_tests/src/communities/update_channel_tests.rs index 5a3b38debe..e941cf0d21 100644 --- a/backend/integration_tests/src/communities/update_channel_tests.rs +++ b/backend/integration_tests/src/communities/update_channel_tests.rs @@ -38,32 +38,19 @@ fn members_added_if_channel_made_public_or_gate_removed(make_public: bool) { client::local_user_index::happy_path::invite_users_to_channel( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, vec![user2.user_id], ); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); for i in 0..5 { client::community::happy_path::send_text_message(env, &user1, community_id, channel_id, None, i.to_string(), None); } client::community::happy_path::leave_channel(env, user2.principal, community_id, channel_id); - - client::local_user_index::happy_path::join_community( - env, - user3.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user3.principal, community_id); client::community::happy_path::update_channel( env, user1.principal, @@ -84,7 +71,7 @@ fn members_added_if_channel_made_public_or_gate_removed(make_public: bool) { ); // Check that user2 has not been re-added to the channel - let user2_channel_summary = client::community::happy_path::summary(env, &user2, community_id); + let user2_channel_summary = client::community::happy_path::summary(env, user2.principal, community_id); assert!(!user2_channel_summary.channels.iter().any(|c| c.channel_id == channel_id)); diff --git a/backend/integration_tests/src/communities/update_communities_tests.rs b/backend/integration_tests/src/communities/update_communities_tests.rs index 9fb2862cef..1f577a5e31 100644 --- a/backend/integration_tests/src/communities/update_communities_tests.rs +++ b/backend/integration_tests/src/communities/update_communities_tests.rs @@ -45,7 +45,7 @@ fn change_casing_of_community_name_succeeds() { ); // Check the name has changed - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); assert_eq!(summary.name, new_community_name); tick_many(env, 3); @@ -95,7 +95,7 @@ fn update_permissions_succeeds() { client::community::happy_path::update_community(env, user1.principal, community_id, &args); - let result = client::community::happy_path::summary(env, &user2, community_id); + let result = client::community::happy_path::summary(env, user2.principal, community_id); assert_eq!(result.description, "New description"); assert!(matches!( @@ -120,7 +120,7 @@ fn update_permissions_summary_updates_succeeds() { community_id, } = init_test_data(env, canister_ids, *controller, &random_string()); - let summary = client::community::happy_path::summary(env, &user2, community_id); + let summary = client::community::happy_path::summary(env, user2.principal, community_id); env.advance_time(Duration::from_millis(1000)); @@ -146,7 +146,8 @@ fn update_permissions_summary_updates_succeeds() { client::community::happy_path::update_community(env, user1.principal, community_id, &args); - let result = match client::community::happy_path::summary_updates(env, &user2, community_id, summary.last_updated) { + let result = match client::community::happy_path::summary_updates(env, user2.principal, community_id, summary.last_updated) + { Some(r) => r, None => { panic!("Expected summary_updates") @@ -191,7 +192,7 @@ fn make_private_community_public_succeeds() { client::community::happy_path::update_community(env, user.principal, community_id, &args); - let result = client::community::happy_path::summary(env, &user, community_id); + let result = client::community::happy_path::summary(env, user.principal, community_id); assert!(result.is_public); @@ -210,13 +211,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_id = client::user::happy_path::create_community(env, &user1, community_name, true, vec!["general".to_string()]); - client::local_user_index::happy_path::join_community( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - None, - ); + client::community::happy_path::join_community(env, user2.principal, community_id); TestData { user1, diff --git a/backend/integration_tests/src/communities/user_group_tests.rs b/backend/integration_tests/src/communities/user_group_tests.rs index e6fd76de57..8b94dbdb10 100644 --- a/backend/integration_tests/src/communities/user_group_tests.rs +++ b/backend/integration_tests/src/communities/user_group_tests.rs @@ -45,7 +45,7 @@ fn create_user_group_succeeds() { assert!(user_group_id > 0); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); assert_eq!(summary.user_groups.len(), 1); let user_group = summary.user_groups.first().unwrap(); @@ -53,7 +53,7 @@ fn create_user_group_succeeds() { assert_eq!(user_group.name, user_group_name); assert_eq!(user_group.members, 3); - let details = client::community::happy_path::selected_initial(env, &user1, community_id); + let details = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!(details.user_groups.len(), 1); let user_groups = details.user_groups.first().unwrap(); @@ -114,7 +114,7 @@ fn update_user_group_succeeds() { community_canister::update_user_group::Response::Success )); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); assert_eq!(summary.user_groups.len(), 1); let user_group = summary.user_groups.first().unwrap(); @@ -122,7 +122,7 @@ fn update_user_group_succeeds() { assert_eq!(user_group.name, new_name); assert_eq!(user_group.members, 2); - let details = client::community::happy_path::selected_initial(env, &user1, community_id); + let details = client::community::happy_path::selected_initial(env, user1.principal, community_id); assert_eq!(details.user_groups.len(), 1); let user_groups = details.user_groups.first().unwrap(); @@ -181,10 +181,11 @@ fn delete_user_group_succeeds() { community_canister::delete_user_groups::Response::Success )); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); assert!(summary.user_groups.is_empty()); - let summary_updates = client::community::happy_path::summary_updates(env, &user1, community_id, now_millis(env) - 1); + let summary_updates = + client::community::happy_path::summary_updates(env, user1.principal, community_id, now_millis(env) - 1); assert_eq!(summary_updates.unwrap().user_groups_deleted, vec![user_group_id]); } @@ -248,19 +249,19 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr client::local_user_index::happy_path::join_community( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, None, ); client::local_user_index::happy_path::join_community( env, user3.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, None, ); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); TestData { user1, diff --git a/backend/integration_tests/src/communities/video_call_tests.rs b/backend/integration_tests/src/communities/video_call_tests.rs index e2f8fe7074..b131ab816a 100644 --- a/backend/integration_tests/src/communities/video_call_tests.rs +++ b/backend/integration_tests/src/communities/video_call_tests.rs @@ -40,7 +40,7 @@ fn access_token_valid() { let token = local_user_index::happy_path::access_token( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, community_id), community_id, channel_id, AccessTokenType::StartVideoCallV2(VideoCallAccessTokenArgs { @@ -61,7 +61,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let community_id = client::user::happy_path::create_community(env, &user1, &random_string(), true, vec!["general".to_string()]); - let summary = client::community::happy_path::summary(env, &user1, community_id); + let summary = client::community::happy_path::summary(env, user1.principal, community_id); TestData { user1, diff --git a/backend/integration_tests/src/delete_group_tests.rs b/backend/integration_tests/src/delete_group_tests.rs index 05da4fd1eb..4471427714 100644 --- a/backend/integration_tests/src/delete_group_tests.rs +++ b/backend/integration_tests/src/delete_group_tests.rs @@ -43,11 +43,9 @@ fn user_canister_notified_of_group_deleted() { group_id, } = init_test_data(env, canister_ids); - env.stop_canister(user2.canister(), Some(canister_ids.local_user_index)) - .unwrap(); + env.stop_canister(user2.canister(), Some(user2.local_user_index)).unwrap(); - env.stop_canister(user3.canister(), Some(canister_ids.local_user_index)) - .unwrap(); + env.stop_canister(user3.canister(), Some(user3.local_user_index)).unwrap(); let delete_group_response = client::user::delete_group( env, @@ -70,7 +68,7 @@ fn user_canister_notified_of_group_deleted() { env.tick(); - env.start_canister(user2.user_id.into(), Some(canister_ids.local_user_index)) + env.start_canister(user2.user_id.into(), Some(user2.local_user_index)) .unwrap(); env.tick(); @@ -82,7 +80,7 @@ fn user_canister_notified_of_group_deleted() { env.tick(); - env.start_canister(user3.user_id.into(), Some(canister_ids.local_user_index)) + env.start_canister(user3.user_id.into(), Some(user3.local_user_index)) .unwrap(); env.tick(); @@ -103,7 +101,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds) -> TestData { client::local_user_index::happy_path::add_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), group_id, vec![(user2.user_id, user2.principal), (user3.user_id, user3.principal)], ); diff --git a/backend/integration_tests/src/delete_message_tests.rs b/backend/integration_tests/src/delete_message_tests.rs index ea2771c77d..8a30af5a84 100644 --- a/backend/integration_tests/src/delete_message_tests.rs +++ b/backend/integration_tests/src/delete_message_tests.rs @@ -369,7 +369,7 @@ fn platform_operators_can_delete_messages(is_platform_moderator: bool) { let user1 = client::register_diamond_user(env, canister_ids, *controller); let user2 = client::register_user(env, canister_ids); let group = client::user::happy_path::create_group(env, &user1, &random_string(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group); + client::group::happy_path::join_group(env, user2.principal, group); let message_id = random_from_u128(); diff --git a/backend/integration_tests/src/delete_user_tests.rs b/backend/integration_tests/src/delete_user_tests.rs index d3a2186b51..e1ea1bf449 100644 --- a/backend/integration_tests/src/delete_user_tests.rs +++ b/backend/integration_tests/src/delete_user_tests.rs @@ -34,9 +34,7 @@ fn delete_user_succeeds() { user_index_canister::current_user::Response::UserNotFound )); - let canister_status = env - .canister_status(user.canister(), Some(canister_ids.local_user_index)) - .unwrap(); + let canister_status = env.canister_status(user.canister(), Some(user.local_user_index)).unwrap(); assert!(canister_status.module_hash.is_none()); } diff --git a/backend/integration_tests/src/fire_and_forget_handler_tests.rs b/backend/integration_tests/src/fire_and_forget_handler_tests.rs index 96d991d4da..926a2ac53d 100644 --- a/backend/integration_tests/src/fire_and_forget_handler_tests.rs +++ b/backend/integration_tests/src/fire_and_forget_handler_tests.rs @@ -27,8 +27,7 @@ fn retries_after_failures(failures: usize) { assert_eq!(events_response1.events.len(), 1); assert!(matches!(events_response1.events[0].event, ChatEvent::Message(_))); - env.stop_canister(user2.user_id.into(), Some(canister_ids.local_user_index)) - .unwrap(); + env.stop_canister(user2.user_id.into(), Some(user2.local_user_index)).unwrap(); client::user::happy_path::add_reaction(env, &user1, user2.user_id, "1", message_id); @@ -37,7 +36,7 @@ fn retries_after_failures(failures: usize) { env.tick(); } - env.start_canister(user2.user_id.into(), Some(canister_ids.local_user_index)) + env.start_canister(user2.user_id.into(), Some(user2.local_user_index)) .unwrap(); env.tick(); diff --git a/backend/integration_tests/src/gated_group_tests.rs b/backend/integration_tests/src/gated_group_tests.rs index 720ce7bda3..013c58d069 100644 --- a/backend/integration_tests/src/gated_group_tests.rs +++ b/backend/integration_tests/src/gated_group_tests.rs @@ -54,7 +54,7 @@ fn public_group_diamond_member_gate_check(is_diamond: bool, is_invited: bool) { client::local_user_index::happy_path::invite_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), group_id, vec![user2.user_id], ); @@ -63,7 +63,7 @@ fn public_group_diamond_member_gate_check(is_diamond: bool, is_invited: bool) { let join_group_response = client::local_user_index::join_group( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::join_group::Args { chat_id: group_id, invite_code: None, @@ -137,7 +137,7 @@ fn public_group_token_balance_gate_check(has_sufficient_balance: bool) { let join_group_response = client::local_user_index::join_group( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::join_group::Args { chat_id: group_id, invite_code: None, @@ -231,7 +231,7 @@ fn public_group_composite_gate_check(is_diamond: bool, has_sufficient_balance: b let join_group_response = client::local_user_index::join_group( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::join_group::Args { chat_id: group_id, invite_code: None, @@ -322,7 +322,7 @@ fn owner_receives_transfer_after_user_joins_via_payment_gate(composite_gate: boo Principal::from(group_id), amount - fee, ); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/identity_tests.rs b/backend/integration_tests/src/identity_tests.rs index a458e13dfe..2c1a6eb549 100644 --- a/backend/integration_tests/src/identity_tests.rs +++ b/backend/integration_tests/src/identity_tests.rs @@ -32,10 +32,11 @@ fn link_auth_identities(delay: bool) { ); let oc_principal1 = Principal::self_authenticating(create_identity_result.user_key.clone()); + let user_registration_canister = client::user_index::happy_path::user_registration_canister(env, canister_ids.user_index); client::local_user_index::happy_path::register_user( env, oc_principal1, - canister_ids.local_user_index, + user_registration_canister, create_identity_result.user_key, ); diff --git a/backend/integration_tests/src/join_group_tests.rs b/backend/integration_tests/src/join_group_tests.rs index b76c79f4bd..623e214369 100644 --- a/backend/integration_tests/src/join_group_tests.rs +++ b/backend/integration_tests/src/join_group_tests.rs @@ -24,7 +24,7 @@ fn join_public_group_succeeds() { group_id, } = init_test_data(env, canister_ids, *controller, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); env.tick(); @@ -48,12 +48,12 @@ fn join_private_group_with_invitation_succeeds() { client::local_user_index::happy_path::invite_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), group_id, vec![user2.user_id], ); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); env.tick(); @@ -90,7 +90,7 @@ fn join_private_group_using_invite_code_succeeds() { let join_group_response = client::local_user_index::join_group( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::join_group::Args { chat_id: group_id, invite_code: Some(invite_code), @@ -132,7 +132,7 @@ fn join_leave_group_triggers_correct_updates() { env.advance_time(Duration::from_secs(1)); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); env.tick(); diff --git a/backend/integration_tests/src/lib.rs b/backend/integration_tests/src/lib.rs index e3a50cd97e..5bc4c7b80f 100644 --- a/backend/integration_tests/src/lib.rs +++ b/backend/integration_tests/src/lib.rs @@ -3,6 +3,7 @@ use crate::utils::principal_to_username; use candid::Principal; use pocket_ic::PocketIc; +use registry_canister::subnets::Subnet; use std::fmt::{Debug, Formatter}; use types::{CanisterId, Cycles, UserId}; @@ -67,6 +68,7 @@ pub struct User { pub principal: Principal, pub user_id: UserId, pub public_key: Vec, + pub local_user_index: CanisterId, } impl User { @@ -92,9 +94,6 @@ pub struct CanisterIds { pub user_index: CanisterId, pub group_index: CanisterId, pub notifications_index: CanisterId, - pub local_user_index: CanisterId, - pub local_group_index: CanisterId, - pub notifications: CanisterId, pub identity: CanisterId, pub online_users: CanisterId, pub proposals_bot: CanisterId, @@ -110,6 +109,26 @@ pub struct CanisterIds { pub icp_ledger: CanisterId, pub chat_ledger: CanisterId, pub cycles_minting_canister: CanisterId, + pub subnets: Vec, +} + +impl CanisterIds { + pub fn local_user_index(&self, env: &PocketIc, canister_id: impl Into) -> CanisterId { + self.subnet(env, canister_id.into()).local_user_index + } + + pub fn local_group_index(&self, env: &PocketIc, canister_id: impl Into) -> CanisterId { + self.subnet(env, canister_id.into()).local_group_index + } + + pub fn notifications(&self, env: &PocketIc, canister_id: impl Into) -> CanisterId { + self.subnet(env, canister_id.into()).notifications_canister + } + + fn subnet(&self, env: &PocketIc, canister_id: CanisterId) -> Subnet { + let subnet_id = env.topology().get_subnet(canister_id).unwrap(); + self.subnets.iter().find(|s| s.subnet_id == subnet_id).cloned().unwrap() + } } impl Debug for CanisterIds { @@ -118,9 +137,6 @@ impl Debug for CanisterIds { w.field("user_index", &self.user_index.to_string()); w.field("group_index", &self.group_index.to_string()); w.field("notifications_index", &self.notifications_index.to_string()); - w.field("local_user_index", &self.local_user_index.to_string()); - w.field("local_group_index", &self.local_group_index.to_string()); - w.field("notifications", &self.notifications.to_string()); w.field("identity", &self.identity.to_string()); w.field("online_users", &self.online_users.to_string()); w.field("proposals_bot", &self.proposals_bot.to_string()); diff --git a/backend/integration_tests/src/mentions_tests.rs b/backend/integration_tests/src/mentions_tests.rs index 8386a2e0e3..9590434919 100644 --- a/backend/integration_tests/src/mentions_tests.rs +++ b/backend/integration_tests/src/mentions_tests.rs @@ -59,13 +59,13 @@ fn mention_users_succeeds(mention_everyone: bool) { group_canister::send_message_v2::Response::Success(_) )); - let user2_summary = client::group::happy_path::summary(env, &user2, group_id); + let user2_summary = client::group::happy_path::summary(env, user2.principal, group_id); assert_eq!(user2_summary.mentions.len(), 1); let mention = user2_summary.mentions.first().unwrap(); assert_eq!(mention.message_index, 0.into()); assert_eq!(mention.message_id, message_id); - let user3_summary = client::group::happy_path::summary(env, &user3, group_id); + let user3_summary = client::group::happy_path::summary(env, user3.principal, group_id); assert_eq!(user3_summary.mentions.len(), 1); let mention = user3_summary.mentions.first().unwrap(); assert_eq!(mention.message_index, 0.into()); @@ -135,7 +135,7 @@ fn mention_everyone_only_succeeds_if_authorized(authorized: bool) { group_canister::send_message_v2::Response::Success(_) )); - let user1_summary = client::group::happy_path::summary(env, &user1, group_id); + let user1_summary = client::group::happy_path::summary(env, user1.principal, group_id); if authorized { assert_eq!(user1_summary.mentions.len(), 1); @@ -193,7 +193,7 @@ fn mentioned_in_thread_adds_user_as_follower() { }, ); - let summary = client::group::happy_path::summary(env, &user2, group_id); + let summary = client::group::happy_path::summary(env, user2.principal, group_id); assert_eq!(summary.mentions.len(), 1); assert_eq!(summary.latest_threads.len(), 1); } @@ -207,8 +207,8 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let group_id = client::user::happy_path::create_group(env, &user1, &group_name, true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); - client::local_user_index::happy_path::join_group(env, user3.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); + client::group::happy_path::join_group(env, user3.principal, group_id); TestData { user1, diff --git a/backend/integration_tests/src/message_activity_tests.rs b/backend/integration_tests/src/message_activity_tests.rs index b6d215d7f6..b3973f66ee 100644 --- a/backend/integration_tests/src/message_activity_tests.rs +++ b/backend/integration_tests/src/message_activity_tests.rs @@ -513,8 +513,8 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr ChatType::Direct => Chat::Direct(us.user_id.into()), ChatType::Group => { let group_id = client::user::happy_path::create_group(env, &owner, &random_string(), true, true); - client::local_user_index::happy_path::join_group(env, us.principal, canister_ids.local_user_index, group_id); - client::local_user_index::happy_path::join_group(env, them.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, us.principal, group_id); + client::group::happy_path::join_group(env, them.principal, group_id); Chat::Group(group_id) } ChatType::Channel => { @@ -522,20 +522,8 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr client::user::happy_path::create_community(env, &owner, &random_string(), true, vec![random_string()]); let channel_id = client::community::happy_path::create_channel(env, owner.principal, community_id, true, random_string()); - client::local_user_index::happy_path::join_channel( - env, - us.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); - client::local_user_index::happy_path::join_channel( - env, - them.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, us.principal, community_id, channel_id); + client::community::happy_path::join_channel(env, them.principal, community_id, channel_id); Chat::Channel(community_id, channel_id) } }; diff --git a/backend/integration_tests/src/notification_tests.rs b/backend/integration_tests/src/notification_tests.rs index ec1f23a521..7a53754306 100644 --- a/backend/integration_tests/src/notification_tests.rs +++ b/backend/integration_tests/src/notification_tests.rs @@ -20,14 +20,15 @@ fn direct_message_notification_succeeds() { let TestData { user1, user2 } = init_test_data(env, canister_ids); - let latest_notification_index = latest_notification_index(env, canister_ids.notifications, *controller); + let notifications_canister = canister_ids.notifications(env, user2.canister()); + let latest_notification_index = latest_notification_index(env, notifications_canister, *controller); client::user::happy_path::send_text_message(env, &user1, user2.user_id, random_string(), None); let notifications_canister::notifications::Response::Success(notifications_response) = client::notifications::notifications( env, *controller, - canister_ids.notifications, + notifications_canister, ¬ifications_canister::notifications::Args { from_notification_index: latest_notification_index + 1, }, @@ -49,13 +50,14 @@ fn group_message_notification_succeeds() { let TestData { user1, user2 } = init_test_data(env, canister_ids); - let latest_notification_index = latest_notification_index(env, canister_ids.notifications, *controller); + let notifications_canister = canister_ids.notifications(env, user2.canister()); + let latest_notification_index = latest_notification_index(env, notifications_canister, *controller); let group_id = client::user::happy_path::create_group(env, &user1, &random_string(), false, false); client::local_user_index::happy_path::add_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), group_id, vec![(user2.user_id, user2.principal)], ); @@ -65,7 +67,7 @@ fn group_message_notification_succeeds() { let notifications_canister::notifications::Response::Success(notifications_response) = client::notifications::notifications( env, *controller, - canister_ids.notifications, + notifications_canister, ¬ifications_canister::notifications::Args { from_notification_index: latest_notification_index + 1, }, @@ -98,14 +100,15 @@ fn direct_message_notification_muted() { }, ); - let latest_notification_index = latest_notification_index(env, canister_ids.notifications, *controller); + let notifications_canister = canister_ids.notifications(env, user2.canister()); + let latest_notification_index = latest_notification_index(env, notifications_canister, *controller); client::user::happy_path::send_text_message(env, &user1, user2.user_id, random_string(), None); let notifications_canister::notifications::Response::Success(notifications_response) = client::notifications::notifications( env, *controller, - canister_ids.notifications, + notifications_canister, ¬ifications_canister::notifications::Args { from_notification_index: latest_notification_index + 1, }, @@ -136,7 +139,7 @@ fn group_message_notification_muted(case: u32) { client::local_user_index::happy_path::add_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), group_id, vec![(user2.user_id, user2.principal)], ); @@ -148,7 +151,8 @@ fn group_message_notification_muted(case: u32) { &group_canister::toggle_mute_notifications::Args { mute: true }, ); - let latest_notification_index = latest_notification_index(env, canister_ids.notifications, *controller); + let notifications_canister = canister_ids.notifications(env, user2.canister()); + let latest_notification_index = latest_notification_index(env, notifications_canister, *controller); let (text, mentioned) = match case { 1 => (random_string(), Vec::new()), @@ -187,7 +191,7 @@ fn group_message_notification_muted(case: u32) { let notifications_canister::notifications::Response::Success(notifications_response) = client::notifications::notifications( env, *controller, - canister_ids.notifications, + notifications_canister, ¬ifications_canister::notifications::Args { from_notification_index: latest_notification_index + 1, }, @@ -225,7 +229,8 @@ fn only_store_up_to_10_subscriptions_per_user() { env.tick(); - let latest_notification_index = latest_notification_index(env, canister_ids.notifications, *controller); + let notifications_canister = canister_ids.notifications(env, user2.canister()); + let latest_notification_index = latest_notification_index(env, notifications_canister, *controller); client::user::happy_path::send_text_message(env, &user1, user2.user_id, random_string(), None); @@ -233,7 +238,7 @@ fn only_store_up_to_10_subscriptions_per_user() { client::notifications::notifications( env, *controller, - canister_ids.notifications, + notifications_canister, ¬ifications_canister::notifications::Args { from_notification_index: latest_notification_index + 1, }, diff --git a/backend/integration_tests/src/p2p_swap_tests.rs b/backend/integration_tests/src/p2p_swap_tests.rs index 9bef462c78..968466e7ab 100644 --- a/backend/integration_tests/src/p2p_swap_tests.rs +++ b/backend/integration_tests/src/p2p_swap_tests.rs @@ -137,7 +137,7 @@ fn p2p_swap_in_group_succeeds() { let user2 = client::register_user(env, canister_ids); let group_id = client::user::happy_path::create_group(env, &user1, &random_string(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); client::ledger::happy_path::transfer( env, @@ -369,7 +369,7 @@ fn cancel_p2p_swap_in_group_chat_succeeds(delete_message: bool) { let user2 = client::register_user(env, canister_ids); let group_id = client::user::happy_path::create_group(env, &user1, &random_string(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); let original_chat_balance = 11_000_000_000; diff --git a/backend/integration_tests/src/platform_moderator_tests.rs b/backend/integration_tests/src/platform_moderator_tests.rs index c0fe814d8f..b105786a10 100644 --- a/backend/integration_tests/src/platform_moderator_tests.rs +++ b/backend/integration_tests/src/platform_moderator_tests.rs @@ -27,7 +27,7 @@ fn report_message_succeeds() { let report_message_response = client::local_user_index::report_message_v2( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::report_message_v2::Args { chat_id: MultiUserChat::Group(group_id), thread_root_message_index: None, diff --git a/backend/integration_tests/src/poll_tests.rs b/backend/integration_tests/src/poll_tests.rs index 4891650098..b7951a23c0 100644 --- a/backend/integration_tests/src/poll_tests.rs +++ b/backend/integration_tests/src/poll_tests.rs @@ -227,7 +227,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, poll_config: P client::local_user_index::happy_path::add_users_to_group( env, &user1, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group), group, vec![(user2.user_id, user2.principal)], ); diff --git a/backend/integration_tests/src/prize_message_tests.rs b/backend/integration_tests/src/prize_message_tests.rs index 138457b9c6..1749f212ea 100644 --- a/backend/integration_tests/src/prize_message_tests.rs +++ b/backend/integration_tests/src/prize_message_tests.rs @@ -25,8 +25,8 @@ fn prize_messages_can_be_claimed_successfully() { let user2 = client::register_user(env, canister_ids); let user3 = client::register_user(env, canister_ids); let group_id = client::user::happy_path::create_group(env, &user1, random_string().as_str(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); - client::local_user_index::happy_path::join_group(env, user3.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); + client::group::happy_path::join_group(env, user3.principal, group_id); // Send user1 some ICP client::ledger::happy_path::transfer(env, *controller, canister_ids.icp_ledger, user1.user_id, 1_000_000_000); @@ -134,7 +134,7 @@ fn unclaimed_prizes_get_refunded(case: u32) { ); } - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); // Send user1 some ICP client::ledger::happy_path::transfer(env, *controller, canister_ids.icp_ledger, user1.user_id, 1_000_000_000); diff --git a/backend/integration_tests/src/register_user_tests.rs b/backend/integration_tests/src/register_user_tests.rs index c27d8c4ce1..bd24f5f4cd 100644 --- a/backend/integration_tests/src/register_user_tests.rs +++ b/backend/integration_tests/src/register_user_tests.rs @@ -33,6 +33,7 @@ fn register_user_with_duplicate_username_appends_suffix() { let user_count = 5usize; let mut user_ids = Vec::new(); let mut first_user_principal = None; + let local_user_index = client::user_index::happy_path::user_registration_canister(env, canister_ids.user_index); for _ in 0..user_count { let (principal, public_key) = random_delegated_principal(canister_ids.identity); @@ -42,7 +43,7 @@ fn register_user_with_duplicate_username_appends_suffix() { let response = client::local_user_index::register_user( env, principal, - canister_ids.local_user_index, + local_user_index, &local_user_index_canister::register_user::Args { username: username.clone(), referral_code: None, diff --git a/backend/integration_tests/src/remove_from_group_tests.rs b/backend/integration_tests/src/remove_from_group_tests.rs index b65ddce426..20eddbb489 100644 --- a/backend/integration_tests/src/remove_from_group_tests.rs +++ b/backend/integration_tests/src/remove_from_group_tests.rs @@ -34,7 +34,7 @@ fn remove_group_member_succeeds() { group_canister::remove_participant::Response::Success )); - let members = client::group::happy_path::selected_initial(env, &user1, group_id).participants; + let members = client::group::happy_path::selected_initial(env, user1.principal, group_id).participants; assert!(!members.iter().any(|m| m.user_id == user2.user_id)); } @@ -65,14 +65,14 @@ fn block_user_who_is_no_longer_group_member_succeeds() { assert!(matches!(block_user_response, group_canister::block_user::Response::Success)); - let blocked_users = client::group::happy_path::selected_initial(env, &user1, group_id).blocked_users; + let blocked_users = client::group::happy_path::selected_initial(env, user1.principal, group_id).blocked_users; assert!(blocked_users.contains(&user2.user_id)); let join_group_response = client::local_user_index::join_group( env, user2.principal, - canister_ids.local_user_index, + canister_ids.local_user_index(env, group_id), &local_user_index_canister::join_group::Args { chat_id: group_id, invite_code: None, @@ -95,7 +95,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let group_id = client::user::happy_path::create_group(env, &user1, &group_name, public, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/send_crypto_tests.rs b/backend/integration_tests/src/send_crypto_tests.rs index 80ed04349e..d36bf6205a 100644 --- a/backend/integration_tests/src/send_crypto_tests.rs +++ b/backend/integration_tests/src/send_crypto_tests.rs @@ -28,7 +28,7 @@ fn send_direct_message_with_transfer_succeeds(with_c2c_error: bool, icrc2: bool) let user2 = client::register_user(env, canister_ids); if with_c2c_error { - stop_canister(env, canister_ids.local_user_index, user2.canister()); + stop_canister(env, user2.local_user_index, user2.canister()); } let token = Cryptocurrency::InternetComputer; @@ -102,7 +102,7 @@ fn send_direct_message_with_transfer_succeeds(with_c2c_error: bool, icrc2: bool) if with_c2c_error { env.advance_time(Duration::from_secs(10)); - start_canister(env, canister_ids.local_user_index, user2.canister()); + start_canister(env, user2.local_user_index, user2.canister()); tick_many(env, 3); } @@ -135,13 +135,14 @@ fn send_message_with_transfer_to_group_succeeds(with_c2c_error: bool, icrc2: boo let user1 = client::register_diamond_user(env, canister_ids, *controller); let user2 = client::register_user(env, canister_ids); let group_id = client::user::happy_path::create_group(env, &user1, &random_string(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); let token = Cryptocurrency::InternetComputer; let ledger = token.ledger_canister_id().unwrap(); let amount = 1_000_000; let fee = 10_000; let now_nanos = now_nanos(env); + let local_group_index = canister_ids.local_group_index(env, group_id); let transaction = if icrc2 { // Approve user1's canister to transfer some ICP @@ -175,7 +176,7 @@ fn send_message_with_transfer_to_group_succeeds(with_c2c_error: bool, icrc2: boo }; if with_c2c_error { - stop_canister(env, canister_ids.local_group_index, group_id.into()); + stop_canister(env, local_group_index, group_id.into()); } let send_message_result = client::user::send_message_with_transfer_to_group( @@ -220,7 +221,7 @@ fn send_message_with_transfer_to_group_succeeds(with_c2c_error: bool, icrc2: boo if with_c2c_error { env.advance_time(Duration::from_secs(10)); - start_canister(env, canister_ids.local_group_index, group_id.into()); + start_canister(env, local_group_index, group_id.into()); } let event = client::group::happy_path::events(env, &user2, group_id, 0.into(), true, 10, 10) diff --git a/backend/integration_tests/src/send_direct_message_tests.rs b/backend/integration_tests/src/send_direct_message_tests.rs index d2ac9514fa..05321739a9 100644 --- a/backend/integration_tests/src/send_direct_message_tests.rs +++ b/backend/integration_tests/src/send_direct_message_tests.rs @@ -89,12 +89,12 @@ fn send_message_retries_if_fails() { let user1 = client::register_user(env, canister_ids); let user2 = client::register_user(env, canister_ids); - stop_canister(env, canister_ids.local_user_index, user2.user_id.into()); + stop_canister(env, user2.local_user_index, user2.user_id.into()); let send_message_result = client::user::happy_path::send_text_message(env, &user1, user2.user_id, "TEXT", None); env.tick(); - start_canister(env, canister_ids.local_user_index, user2.user_id.into()); + start_canister(env, user2.local_user_index, user2.user_id.into()); env.advance_time(Duration::from_secs(10)); env.tick(); @@ -114,12 +114,12 @@ fn messages_arrive_in_order_even_if_some_fail_originally() { let user1 = client::register_user(env, canister_ids); let user2 = client::register_user(env, canister_ids); - stop_canister(env, canister_ids.local_user_index, user2.user_id.into()); + stop_canister(env, user2.local_user_index, user2.user_id.into()); client::user::happy_path::send_text_message(env, &user1, user2.user_id, "1", None); client::user::happy_path::send_text_message(env, &user1, user2.user_id, "2", None); - start_canister(env, canister_ids.local_user_index, user2.user_id.into()); + start_canister(env, user2.local_user_index, user2.user_id.into()); client::user::happy_path::send_text_message(env, &user1, user2.user_id, "3", None); diff --git a/backend/integration_tests/src/setup.rs b/backend/integration_tests/src/setup.rs index f6b5d8578b..d69c189654 100644 --- a/backend/integration_tests/src/setup.rs +++ b/backend/integration_tests/src/setup.rs @@ -1,4 +1,4 @@ -use crate::client::{create_canister, create_canister_with_id, install_canister, INIT_CYCLES_BALANCE}; +use crate::client::{create_canister, create_canister_with_id, install_canister}; use crate::env::VIDEO_CALL_OPERATOR; use crate::utils::tick_many; use crate::{client, wasms, CanisterIds, TestEnv, T}; @@ -482,21 +482,20 @@ fn install_canisters(env: &mut PocketIc, controller: Principal) -> CanisterIds { ); // Top up the Registry with 10 ICP - client::ledger::happy_path::transfer(env, controller, nns_ledger_canister_id, registry_canister_id, 1_000_000_000); + client::ledger::happy_path::transfer( + env, + controller, + nns_ledger_canister_id, + registry_canister_id, + 10 * 100_000_000, + ); let subnet = client::registry::happy_path::expand_onto_subnet(env, controller, registry_canister_id, application_subnet); - let local_user_index_canister_id = subnet.local_user_index; - let local_group_index_canister_id = subnet.local_group_index; - let notifications_canister_id = subnet.notifications_canister; - - env.add_cycles(local_user_index_canister_id, INIT_CYCLES_BALANCE); - env.add_cycles(local_group_index_canister_id, INIT_CYCLES_BALANCE); - env.add_cycles(notifications_canister_id, INIT_CYCLES_BALANCE); let airdrop_bot_init_args = airdrop_bot_canister::init::Args { admins: vec![controller], user_index_canister_id, - local_user_index_canister_id, + local_user_index_canister_id: subnet.local_user_index, chat_ledger_canister_id, wasm_version, test_mode, @@ -516,9 +515,6 @@ fn install_canisters(env: &mut PocketIc, controller: Principal) -> CanisterIds { user_index: user_index_canister_id, group_index: group_index_canister_id, notifications_index: notifications_index_canister_id, - local_user_index: local_user_index_canister_id, - local_group_index: local_group_index_canister_id, - notifications: notifications_canister_id, identity: identity_canister_id, online_users: online_users_canister_id, proposals_bot: proposals_bot_canister_id, @@ -534,6 +530,7 @@ fn install_canisters(env: &mut PocketIc, controller: Principal) -> CanisterIds { icp_ledger: nns_ledger_canister_id, chat_ledger: chat_ledger_canister_id, cycles_minting_canister: cycles_minting_canister_id, + subnets: vec![subnet], }; println!("Test env setup complete. {canister_ids:?}"); diff --git a/backend/integration_tests/src/tip_message_tests.rs b/backend/integration_tests/src/tip_message_tests.rs index b1a895dcd9..4a36330f46 100644 --- a/backend/integration_tests/src/tip_message_tests.rs +++ b/backend/integration_tests/src/tip_message_tests.rs @@ -80,7 +80,7 @@ fn tip_group_message_succeeds() { let message_id = random_from_u128(); let tip_amount = 1_0000_0000; - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); let event_index = client::group::happy_path::send_text_message(env, &user2, group_id, None, random_string(), Some(message_id)) @@ -130,13 +130,7 @@ fn tip_channel_message_succeeds() { let message_id = random_from_u128(); let tip_amount = 1_0000_0000; - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); let event_index = client::community::happy_path::send_text_message( env, @@ -191,15 +185,15 @@ fn tip_group_message_retries_if_c2c_call_fails() { let group_id = client::user::happy_path::create_group(env, &user1, &random_string(), true, true); let message_id = random_from_u128(); let tip_amount = 1_0000_0000; + let local_group_index = canister_ids.local_group_index(env, group_id); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); let event_index = client::group::happy_path::send_text_message(env, &user2, group_id, None, random_string(), Some(message_id)) .event_index; - env.stop_canister(group_id.into(), Some(canister_ids.local_group_index)) - .unwrap(); + env.stop_canister(group_id.into(), Some(local_group_index)).unwrap(); let tip_message_response = client::user::tip_message( env, @@ -225,8 +219,7 @@ fn tip_group_message_retries_if_c2c_call_fails() { )); env.tick(); - env.start_canister(group_id.into(), Some(canister_ids.local_group_index)) - .unwrap(); + env.start_canister(group_id.into(), Some(local_group_index)).unwrap(); env.advance_time(Duration::from_secs(10)); env.tick(); @@ -259,14 +252,9 @@ fn tip_channel_message_retries_if_c2c_call_fails() { let channel_id = client::community::happy_path::create_channel(env, user1.principal, community_id, true, random_string()); let message_id = random_from_u128(); let tip_amount = 1_0000_0000; + let local_group_index = canister_ids.local_group_index(env, community_id); - client::local_user_index::happy_path::join_channel( - env, - user2.principal, - canister_ids.local_user_index, - community_id, - channel_id, - ); + client::community::happy_path::join_channel(env, user2.principal, community_id, channel_id); let event_index = client::community::happy_path::send_text_message( env, @@ -279,8 +267,7 @@ fn tip_channel_message_retries_if_c2c_call_fails() { ) .event_index; - env.stop_canister(community_id.into(), Some(canister_ids.local_group_index)) - .unwrap(); + env.stop_canister(community_id.into(), Some(local_group_index)).unwrap(); let tip_message_response = client::user::tip_message( env, @@ -306,8 +293,7 @@ fn tip_channel_message_retries_if_c2c_call_fails() { )); env.tick(); - env.start_canister(community_id.into(), Some(canister_ids.local_group_index)) - .unwrap(); + env.start_canister(community_id.into(), Some(local_group_index)).unwrap(); env.advance_time(Duration::from_secs(10)); env.tick(); diff --git a/backend/integration_tests/src/update_group_tests.rs b/backend/integration_tests/src/update_group_tests.rs index 5dbe8d6389..99bab8bb50 100644 --- a/backend/integration_tests/src/update_group_tests.rs +++ b/backend/integration_tests/src/update_group_tests.rs @@ -40,7 +40,7 @@ fn update_group_name_succeeds() { ); // Check the name has changed - let summary = client::group::happy_path::summary(env, &user2, group_id); + let summary = client::group::happy_path::summary(env, user2.principal, group_id); assert_eq!(summary.name, new_group_name); tick_many(env, 3); @@ -84,7 +84,7 @@ fn change_casing_of_group_name_succeeds() { ); // Check the name has changed - let summary = client::group::happy_path::summary(env, &user2, group_id); + let summary = client::group::happy_path::summary(env, user2.principal, group_id); assert_eq!(summary.name, new_group_name); tick_many(env, 3); @@ -131,7 +131,7 @@ fn update_group_privacy_succeeds() { ); // Check the privacy and name have changed - let summary = client::group::happy_path::summary(env, &user2, group_id); + let summary = client::group::happy_path::summary(env, user2.principal, group_id); assert_eq!(summary.name, new_group_name); assert!(!summary.is_public); @@ -179,9 +179,9 @@ fn make_private_group_public_succeeds() { }, ); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); - let group_summary = client::group::happy_path::summary(env, &user2, group_id); + let group_summary = client::group::happy_path::summary(env, user2.principal, group_id); assert!(group_summary.is_public); assert_eq!(group_summary.min_visible_event_index, 6.into()); @@ -193,7 +193,7 @@ fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Pr let user2 = client::register_user(env, canister_ids); let group_id = client::user::happy_path::create_group(env, &user1, group_name, true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group_id); + client::group::happy_path::join_group(env, user2.principal, group_id); tick_many(env, 3); diff --git a/backend/integration_tests/src/video_call_tests.rs b/backend/integration_tests/src/video_call_tests.rs index ad904e6a65..aa599877e4 100644 --- a/backend/integration_tests/src/video_call_tests.rs +++ b/backend/integration_tests/src/video_call_tests.rs @@ -115,14 +115,14 @@ fn start_join_end_video_call_in_group_chat_succeeds(manually_end_video_call: boo let user1 = client::register_diamond_user(env, canister_ids, *controller); let user2 = client::register_user(env, canister_ids); let group = client::user::happy_path::create_group(env, &user1, random_string().as_str(), true, true); - client::local_user_index::happy_path::join_group(env, user2.principal, canister_ids.local_user_index, group); + client::group::happy_path::join_group(env, user2.principal, group); let message_id = random_from_u128(); let max_duration = HOUR_IN_MS; client::group::happy_path::start_video_call(env, &user1, group, message_id, Some(max_duration)); - let summary = client::group::happy_path::summary(env, &user1, group); + let summary = client::group::happy_path::summary(env, user1.principal, group); assert!(summary.video_call_in_progress.is_some()); let event = client::group::happy_path::events_by_index(env, &user1, group, vec![2.into()]) @@ -148,7 +148,7 @@ fn start_join_end_video_call_in_group_chat_succeeds(manually_end_video_call: boo env.tick(); } - let summary = client::group::happy_path::summary(env, &user1, group); + let summary = client::group::happy_path::summary(env, user1.principal, group); assert!(summary.video_call_in_progress.is_none()); }