From c37368484563d9054d785fca40a064086c17030e Mon Sep 17 00:00:00 2001 From: Komal <157946119+komal-sai-yral@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:03:10 +0530 Subject: [PATCH] Clean ml feed (#473) * reset ml feed * reset ml feed * test * inc tick * add more tick * test print * test print * test print * final push * review changes --- src/canister/individual_user_template/can.did | 33 +- .../src/api/ml_ops/ml_feed_cache.rs | 11 + .../src/api/ml_ops/update_success_history.rs | 5 + .../src/api/ml_ops/update_watch_history.rs | 5 + src/canister/platform_orchestrator/can.did | 1 + .../src/api/canister_management/mod.rs | 1 + .../reset_canisters_ml_feed_cache.rs | 27 ++ src/canister/user_index/can.did | 1 + .../src/api/canister_management/mod.rs | 1 + .../reset_user_canister_ml_feed_cache.rs | 30 ++ .../tests/platform_orchestrator/main.rs | 1 + .../reset_ml_feed_cache_test.rs | 360 ++++++++++++++++++ .../update_canisters_last_access_time_test.rs | 1 + 13 files changed, 461 insertions(+), 16 deletions(-) create mode 100644 src/canister/platform_orchestrator/src/api/canister_management/reset_canisters_ml_feed_cache.rs create mode 100644 src/canister/user_index/src/api/canister_management/reset_user_canister_ml_feed_cache.rs create mode 100644 src/lib/integration_tests/tests/platform_orchestrator/reset_ml_feed_cache_test.rs diff --git a/src/canister/individual_user_template/can.did b/src/canister/individual_user_template/can.did index 1166e0ad..52d1626e 100644 --- a/src/canister/individual_user_template/can.did +++ b/src/canister/individual_user_template/can.did @@ -377,11 +377,11 @@ type Result_19 = variant { Ok : vec record { nat64; nat8 }; Err : text }; type Result_2 = variant { Ok : bool; Err : CdaoTokenError }; type Result_20 = variant { Ok; Err : MigrationErrors }; type Result_21 = variant { Ok; Err : AirdropError }; -type Result_22 = variant { Ok : IndividualUserCreatorDaoEntry; Err : text }; -type Result_23 = variant { Committed : Committed; Aborted : record {} }; -type Result_24 = variant { Ok : Ok; Err : GovernanceError }; -type Result_25 = variant { Ok; Err : CdaoTokenError }; -type Result_26 = variant { Ok : text; Err : text }; +type Result_22 = variant { Ok : text; Err : text }; +type Result_23 = variant { Ok : IndividualUserCreatorDaoEntry; Err : text }; +type Result_24 = variant { Committed : Committed; Aborted : record {} }; +type Result_25 = variant { Ok : Ok; Err : GovernanceError }; +type Result_26 = variant { Ok; Err : CdaoTokenError }; type Result_27 = variant { Ok : UserProfileDetailsForFrontend; Err : UpdateProfileDetailsError; @@ -408,10 +408,10 @@ type RoomDetails = record { }; type SessionType = variant { AnonymousSession; RegisteredSession }; type SettleNeuronsFundParticipationRequest = record { - result : opt Result_23; + result : opt Result_24; nns_proposal_id : opt nat64; }; -type SettleNeuronsFundParticipationResponse = record { result : opt Result_24 }; +type SettleNeuronsFundParticipationResponse = record { result : opt Result_25 }; type SlotDetails = record { room_details : vec record { nat64; RoomDetails } }; type SnsInitPayload = record { url : opt text; @@ -631,20 +631,21 @@ service : (IndividualUserTemplateInitArgs) -> { receive_bet_winnings_when_distributed : (nat64, BetOutcomeForBetMaker) -> (); receive_data_from_hotornot : (principal, nat64, vec Post) -> (Result_20); request_airdrop : (principal, opt blob, nat, principal) -> (Result_21); + reset_ml_feed_cache : () -> (Result_22); return_cycles_to_user_index_canister : (opt nat) -> (); save_snapshot_json : () -> (nat32); - send_creator_dao_stats_to_subnet_orchestrator : () -> (Result_22); + send_creator_dao_stats_to_subnet_orchestrator : () -> (Result_23); set_controller_as_subnet_orchestrator : (principal) -> (); settle_neurons_fund_participation : ( SettleNeuronsFundParticipationRequest, ) -> (SettleNeuronsFundParticipationResponse); transfer_token_to_user_canister : (principal, principal, opt blob, nat) -> ( - Result_25, + Result_26, ); transfer_tokens_and_posts : (principal, principal) -> (Result_20); - update_last_access_time : () -> (Result_26); + update_last_access_time : () -> (Result_22); update_last_canister_functionality_access_time : () -> (); - update_ml_feed_cache : (vec MLFeedCacheItem) -> (Result_26); + update_ml_feed_cache : (vec MLFeedCacheItem) -> (Result_22); update_post_add_view_details : (nat64, PostViewDetailsFromFrontend) -> (); update_post_as_ready_to_view : (nat64) -> (); update_post_increment_share_count : (nat64) -> (nat64); @@ -661,11 +662,11 @@ service : (IndividualUserTemplateInitArgs) -> { update_profiles_that_follow_me_toggle_list_with_specified_profile : ( FollowerArg, ) -> (Result_8); - update_referrer_details : (UserCanisterDetails) -> (Result_26); - update_session_type : (SessionType) -> (Result_26); - update_success_history : (SuccessHistoryItemV1) -> (Result_26); - update_user_propensity : (float64) -> (Result_26); - update_watch_history : (WatchHistoryItem) -> (Result_26); + update_referrer_details : (UserCanisterDetails) -> (Result_22); + update_session_type : (SessionType) -> (Result_22); + update_success_history : (SuccessHistoryItemV1) -> (Result_22); + update_user_propensity : (float64) -> (Result_22); + update_watch_history : (WatchHistoryItem) -> (Result_22); update_well_known_principal : (KnownPrincipalType, principal) -> (); upgrade_creator_dao_governance_canisters : (blob) -> (Result_28); write_key_value_pair : (nat64, text, text) -> (Result_5); diff --git a/src/canister/individual_user_template/src/api/ml_ops/ml_feed_cache.rs b/src/canister/individual_user_template/src/api/ml_ops/ml_feed_cache.rs index f2d649e5..83cf3307 100644 --- a/src/canister/individual_user_template/src/api/ml_ops/ml_feed_cache.rs +++ b/src/canister/individual_user_template/src/api/ml_ops/ml_feed_cache.rs @@ -61,6 +61,17 @@ fn get_ml_feed_cache_paginated_impl( canister_data.ml_feed_cache[start_index..end_index].to_vec() } +#[update(guard = "is_caller_controller_or_global_admin")] +fn reset_ml_feed_cache() -> Result { + let _ = CANISTER_DATA.with(|canister_data| { + let mut canister_data = canister_data.borrow_mut(); + + canister_data.ml_feed_cache.clear(); + }); + + Ok("Success".into()) +} + #[cfg(test)] mod test { use candid::Principal; diff --git a/src/canister/individual_user_template/src/api/ml_ops/update_success_history.rs b/src/canister/individual_user_template/src/api/ml_ops/update_success_history.rs index 06f4c4c7..72585b96 100644 --- a/src/canister/individual_user_template/src/api/ml_ops/update_success_history.rs +++ b/src/canister/individual_user_template/src/api/ml_ops/update_success_history.rs @@ -19,6 +19,11 @@ fn update_success_history(success_history_item: SuccessHistoryItemV1) -> Result< canister_data .success_history .insert(success_history_item, ()); + + // keep removing oldest items until the len is less than or equal to 3000 + while canister_data.success_history.len() > 3000 { + canister_data.success_history.pop_first(); + } }); Ok("Success".into()) diff --git a/src/canister/individual_user_template/src/api/ml_ops/update_watch_history.rs b/src/canister/individual_user_template/src/api/ml_ops/update_watch_history.rs index b41abee9..86823afc 100644 --- a/src/canister/individual_user_template/src/api/ml_ops/update_watch_history.rs +++ b/src/canister/individual_user_template/src/api/ml_ops/update_watch_history.rs @@ -17,6 +17,11 @@ fn update_watch_history(watch_history_item: WatchHistoryItem) -> Result 3000 { + canister_data.watch_history.pop_first(); + } }); Ok("Success".into()) diff --git a/src/canister/platform_orchestrator/can.did b/src/canister/platform_orchestrator/can.did index ab3d5b60..339436da 100644 --- a/src/canister/platform_orchestrator/can.did +++ b/src/canister/platform_orchestrator/can.did @@ -124,6 +124,7 @@ service : (PlatformOrchestratorInitArgs) -> { remove_principal_from_global_admins : (principal) -> (); remove_subnet_orchestrators_from_available_list : (principal) -> (Result); report_subnet_upgrade_status : (UpgradeStatus) -> (Result_1); + reset_canisters_ml_feed_cache : () -> (Result); set_reserved_cycle_limit_for_subnet_orchestrator : (principal, nat) -> ( Result_1, ); diff --git a/src/canister/platform_orchestrator/src/api/canister_management/mod.rs b/src/canister/platform_orchestrator/src/api/canister_management/mod.rs index 36c575bc..53c9515a 100644 --- a/src/canister/platform_orchestrator/src/api/canister_management/mod.rs +++ b/src/canister/platform_orchestrator/src/api/canister_management/mod.rs @@ -20,6 +20,7 @@ pub mod register_new_subnet_orhestrator; mod reinstall_yral_post_cache_canister; pub mod remove_subnet_orchestrator_from_available_list; pub mod report_subnet_upgrade_status; +pub mod reset_canisters_ml_feed_cache; pub mod set_reserved_cycle_limit_for_subnet_orchestrator; pub mod start_subnet_orchestrator_canister; mod stop_upgrades_for_individual_user_canisters; diff --git a/src/canister/platform_orchestrator/src/api/canister_management/reset_canisters_ml_feed_cache.rs b/src/canister/platform_orchestrator/src/api/canister_management/reset_canisters_ml_feed_cache.rs new file mode 100644 index 00000000..f1e7e27c --- /dev/null +++ b/src/canister/platform_orchestrator/src/api/canister_management/reset_canisters_ml_feed_cache.rs @@ -0,0 +1,27 @@ +use ic_cdk::{api::call::CallResult, call}; +use ic_cdk_macros::update; + +use crate::{guard::is_caller::is_caller_global_admin_or_controller, CANISTER_DATA}; + +#[update(guard = "is_caller_global_admin_or_controller")] +async fn reset_canisters_ml_feed_cache() -> Result { + let subnet_orchestrator_list = CANISTER_DATA + .with_borrow(|canister_data| canister_data.all_subnet_orchestrator_canisters_list.clone()); + + for subnet_orchestrator in subnet_orchestrator_list { + let result: CallResult<()> = call( + subnet_orchestrator, + "reset_user_canisters_ml_feed_cache", + (), + ) + .await; + result.map_err(|e| { + format!( + "failed to call reset_user_canisters_ml_feed_cache for {} {}", + subnet_orchestrator, e.1 + ) + })?; + } + + Ok("Success".into()) +} diff --git a/src/canister/user_index/can.did b/src/canister/user_index/can.did index 8827eea5..a6ae18e6 100644 --- a/src/canister/user_index/can.did +++ b/src/canister/user_index/can.did @@ -178,6 +178,7 @@ service : (UserIndexInitArgs) -> { recharge_individual_user_canister : () -> (Result_4); reclaim_cycles_from_individual_canisters : () -> (); request_cycles : (nat) -> (Result_4); + reset_user_canisters_ml_feed_cache : () -> (text); reset_user_individual_canisters : (vec principal) -> (Result_2); return_cycles_to_platform_orchestrator_canister : () -> (Result_2); set_permission_to_upgrade_individual_canisters : (bool) -> (text); diff --git a/src/canister/user_index/src/api/canister_management/mod.rs b/src/canister/user_index/src/api/canister_management/mod.rs index 7861367a..00a4d546 100644 --- a/src/canister/user_index/src/api/canister_management/mod.rs +++ b/src/canister/user_index/src/api/canister_management/mod.rs @@ -43,6 +43,7 @@ pub mod provision_empty_canisters; pub mod recharge_individual_user_canister; pub mod recycle_canisters; pub mod request_cycles; +pub mod reset_user_canister_ml_feed_cache; pub mod start_upgrades_for_individual_canisters; pub mod update_canisters_access_time; pub mod update_user_canister_restart_timers; diff --git a/src/canister/user_index/src/api/canister_management/reset_user_canister_ml_feed_cache.rs b/src/canister/user_index/src/api/canister_management/reset_user_canister_ml_feed_cache.rs new file mode 100644 index 00000000..25553b8f --- /dev/null +++ b/src/canister/user_index/src/api/canister_management/reset_user_canister_ml_feed_cache.rs @@ -0,0 +1,30 @@ +use futures::StreamExt; +use ic_cdk::api::call::CallResult; +use ic_cdk_macros::update; + +use crate::CANISTER_DATA; +use shared_utils::common::utils::permissions::is_caller_controller; + +#[update(guard = "is_caller_controller")] +async fn reset_user_canisters_ml_feed_cache() -> String { + ic_cdk::spawn(reset_user_canisters_ml_feed_cache_impl()); + "Success".to_string() +} + +async fn reset_user_canisters_ml_feed_cache_impl() { + let canisters = CANISTER_DATA.with_borrow_mut(|canister_data| { + canister_data + .user_principal_id_to_canister_id_map + .values() + .cloned() + .collect::>() + }); + + let futures = canisters.iter().map(|canister_id| async { + let _: CallResult<()> = ic_cdk::call(*canister_id, "reset_ml_feed_cache", ()).await; + }); + + let stream = futures::stream::iter(futures).boxed().buffer_unordered(25); + + let _ = stream.collect::>().await; +} diff --git a/src/lib/integration_tests/tests/platform_orchestrator/main.rs b/src/lib/integration_tests/tests/platform_orchestrator/main.rs index 23721f4f..86dbe3a3 100644 --- a/src/lib/integration_tests/tests/platform_orchestrator/main.rs +++ b/src/lib/integration_tests/tests/platform_orchestrator/main.rs @@ -3,4 +3,5 @@ pub mod provision_empty_canisters_in_a_subnet_test; pub mod provision_subnet_orchestrator_test; pub mod recharge_subnet_orchestrator_test; pub mod register_and_deregister_new_subnet_orchestrator_test; +pub mod reset_ml_feed_cache_test; pub mod update_canisters_last_access_time_test; diff --git a/src/lib/integration_tests/tests/platform_orchestrator/reset_ml_feed_cache_test.rs b/src/lib/integration_tests/tests/platform_orchestrator/reset_ml_feed_cache_test.rs new file mode 100644 index 00000000..0dddf794 --- /dev/null +++ b/src/lib/integration_tests/tests/platform_orchestrator/reset_ml_feed_cache_test.rs @@ -0,0 +1,360 @@ +use std::{ + collections::{HashMap, HashSet}, + time::{Duration, SystemTime}, +}; + +use candid::{encode_args, encode_one, CandidType, Principal}; +use ic_cdk::api::management_canister::main::{CanisterId, CanisterSettings}; +use ic_ledger_types::{AccountIdentifier, BlockIndex, Tokens, DEFAULT_SUBACCOUNT}; +use pocket_ic::{PocketIc, PocketIcBuilder, WasmResult}; +use shared_utils::{ + canister_specific::{ + individual_user_template::types::{ + arg::PlaceBetArg, + error::BetOnCurrentlyViewingPostError, + hot_or_not::{BetDirection, BettingStatus}, + ml_data::MLFeedCacheItem, + post::PostDetailsFromFrontend, + profile::UserProfileDetailsForFrontend, + }, + platform_orchestrator::types::args::PlatformOrchestratorInitArgs, + post_cache::types::arg::PostCacheInitArgs, + user_index::types::{args::UserIndexInitArgs, RecycleStatus}, + }, + common::types::{known_principal::KnownPrincipalType, wasm::WasmType}, + constant::{NNS_CYCLE_MINTING_CANISTER, NNS_LEDGER_CANISTER_ID}, +}; +use test_utils::setup::{ + env::pocket_ic_env::get_new_pocket_ic_env, + test_constants::{ + get_mock_user_alice_principal_id, get_mock_user_bob_principal_id, + get_mock_user_charlie_principal_id, get_mock_user_dan_principal_id, + v1::CANISTER_INITIAL_CYCLES_FOR_SPAWNING_CANISTERS, + }, +}; + +const INDIVIDUAL_TEMPLATE_WASM_PATH: &str = + "../../../target/wasm32-unknown-unknown/release/individual_user_template.wasm.gz"; +const POST_CACHE_WASM_PATH: &str = + "../../../target/wasm32-unknown-unknown/release/post_cache.wasm.gz"; + +const USER_INDEX_WASM_PATH: &str = + "../../../target/wasm32-unknown-unknown/release/user_index.wasm.gz"; +const PF_ORCH_WASM_PATH: &str = + "../../../target/wasm32-unknown-unknown/release/platform_orchestrator.wasm.gz"; + +fn individual_template_canister_wasm() -> Vec { + std::fs::read(INDIVIDUAL_TEMPLATE_WASM_PATH).unwrap() +} + +fn user_index_canister_wasm() -> Vec { + std::fs::read(USER_INDEX_WASM_PATH).unwrap() +} + +fn post_cache_canister_wasm() -> Vec { + std::fs::read(POST_CACHE_WASM_PATH).unwrap() +} +fn pf_orch_canister_wasm() -> Vec { + std::fs::read(PF_ORCH_WASM_PATH).unwrap() +} + +// TODO: remove this when removing the update_last_access_time API from PF Orch + +#[test] +fn reset_ml_feed_cache_test() { + let (pocket_ic, known_principal) = get_new_pocket_ic_env(); + let platform_canister_id = known_principal + .get(&KnownPrincipalType::CanisterIdPlatformOrchestrator) + .cloned() + .unwrap(); + + let super_admin = known_principal + .get(&KnownPrincipalType::UserIdGlobalSuperAdmin) + .cloned() + .unwrap(); + + let application_subnets = pocket_ic.topology().get_app_subnets(); + + let charlie_global_admin = get_mock_user_charlie_principal_id(); + let alice_principal_id = get_mock_user_alice_principal_id(); + let bob_principal_id = get_mock_user_bob_principal_id(); + let dan_principal_id = get_mock_user_dan_principal_id(); + + pocket_ic + .update_call( + platform_canister_id, + super_admin, + "add_principal_as_global_admin", + candid::encode_one(charlie_global_admin).unwrap(), + ) + .unwrap(); + + let user_index_canister_id: Principal = pocket_ic + .update_call( + platform_canister_id, + super_admin, + "provision_subnet_orchestrator_canister", + candid::encode_one(application_subnets[1]).unwrap(), + ) + .map(|res| { + let canister_id_result: Result = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("Canister call failed"), + }; + canister_id_result.unwrap() + }) + .unwrap(); + + for i in 0..50 { + pocket_ic.tick(); + } + + // User Index available details - call get_subnet_available_capacity + + let res = pocket_ic + .query_call( + user_index_canister_id, + super_admin, + "get_subnet_available_capacity", + encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let subnet_capacity: u64 = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_subnet_available_capacity failed\n"), + }; + subnet_capacity + }) + .unwrap(); + println!("Avail capacity: {:?}", res); + + // call get_subnet_backup_capacity + + let res = pocket_ic + .query_call( + user_index_canister_id, + super_admin, + "get_subnet_backup_capacity", + encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let subnet_capacity: u64 = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_subnet_backup_capacity failed\n"), + }; + subnet_capacity + }) + .unwrap(); + println!("Backup capacity: {:?}", res); + + // create user canisters + + let alice_individual_template_canister_id = pocket_ic + .update_call( + user_index_canister_id, + alice_principal_id, + "get_requester_principals_canister_id_create_if_not_exists", + encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let result: Result = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!( + "\nšŸ›‘ get_requester_principals_canister_id_create_if_not_exists failed\n" + ), + }; + result + }) + .unwrap() + .unwrap(); + println!("res1: {:?}", alice_individual_template_canister_id); + + let bob_individual_template_canister_id = pocket_ic + .update_call( + user_index_canister_id, + bob_principal_id, + "get_requester_principals_canister_id_create_if_not_exists", + encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let result: Result = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!( + "\nšŸ›‘ get_requester_principals_canister_id_create_if_not_exists failed\n" + ), + }; + result + }) + .unwrap() + .unwrap(); + println!("res2: {:?}", bob_individual_template_canister_id); + + let dan_individual_template_canister_id = pocket_ic + .update_call( + user_index_canister_id, + dan_principal_id, + "get_requester_principals_canister_id_create_if_not_exists", + encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let result: Result = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!( + "\nšŸ›‘ get_requester_principals_canister_id_create_if_not_exists failed\n" + ), + }; + result + }) + .unwrap() + .unwrap(); + println!("res3: {:?}", dan_individual_template_canister_id); + + // add items into ml cache + + let items = vec![ + MLFeedCacheItem { + post_id: 1 as u64, + canister_id: Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap(), + video_id: "1".to_string(), + creator_principal_id: None, + }, + MLFeedCacheItem { + post_id: 2 as u64, + canister_id: Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap(), + video_id: "2".to_string(), + creator_principal_id: None, + }, + MLFeedCacheItem { + post_id: 3 as u64, + canister_id: Principal::from_text("ryjl3-tyaaa-aaaaa-aaaba-cai").unwrap(), + video_id: "3".to_string(), + creator_principal_id: None, + }, + ]; + + let res = pocket_ic + .update_call( + alice_individual_template_canister_id, + user_index_canister_id, + "update_ml_feed_cache", + candid::encode_one(items.clone()).unwrap(), + ) + .map(|res| { + let canister_id_result: Result = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("Canister call failed"), + }; + canister_id_result.unwrap() + }) + .unwrap(); + + let res1 = pocket_ic + .query_call( + alice_individual_template_canister_id, + alice_principal_id, + "get_ml_feed_cache_paginated", + encode_args((0 as u64, 10 as u64)).unwrap(), + ) + .map(|reply_payload| { + let result: Vec = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_last_canister_functionality_access_time failed\n"), + }; + result + }) + .unwrap(); + + assert_eq!(res1.len(), 3); + + let res = pocket_ic + .update_call( + bob_individual_template_canister_id, + user_index_canister_id, + "update_ml_feed_cache", + candid::encode_one(items).unwrap(), + ) + .map(|res| { + let canister_id_result: Result = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("Canister call failed"), + }; + canister_id_result.unwrap() + }) + .unwrap(); + + let res2 = pocket_ic + .query_call( + bob_individual_template_canister_id, + bob_principal_id, + "get_ml_feed_cache_paginated", + encode_args((0 as u64, 10 as u64)).unwrap(), + ) + .map(|reply_payload| { + let result: Vec = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_last_canister_functionality_access_time failed\n"), + }; + result + }) + .unwrap(); + + assert_eq!(res2.len(), 3); + + // reset cache + + let res = pocket_ic + .update_call( + platform_canister_id, + super_admin, + "reset_canisters_ml_feed_cache", + candid::encode_one(application_subnets[1]).unwrap(), + ) + .map(|res| { + let canister_id_result: Result = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("Canister call failed"), + }; + canister_id_result.unwrap() + }) + .unwrap(); + + for i in 0..50 { + pocket_ic.tick(); + } + + let res1 = pocket_ic + .query_call( + alice_individual_template_canister_id, + alice_principal_id, + "get_ml_feed_cache_paginated", + encode_args((0 as u64, 10 as u64)).unwrap(), + ) + .map(|reply_payload| { + let result: Vec = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_last_canister_functionality_access_time failed\n"), + }; + result + }) + .unwrap(); + + assert_eq!(res1.len(), 0); + + let res2 = pocket_ic + .query_call( + bob_individual_template_canister_id, + bob_principal_id, + "get_ml_feed_cache_paginated", + encode_args((0 as u64, 10 as u64)).unwrap(), + ) + .map(|reply_payload| { + let result: Vec = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\nšŸ›‘ get_last_canister_functionality_access_time failed\n"), + }; + result + }) + .unwrap(); + + assert_eq!(res2.len(), 0); +} diff --git a/src/lib/integration_tests/tests/platform_orchestrator/update_canisters_last_access_time_test.rs b/src/lib/integration_tests/tests/platform_orchestrator/update_canisters_last_access_time_test.rs index fc5ce69c..b8c79014 100644 --- a/src/lib/integration_tests/tests/platform_orchestrator/update_canisters_last_access_time_test.rs +++ b/src/lib/integration_tests/tests/platform_orchestrator/update_canisters_last_access_time_test.rs @@ -13,6 +13,7 @@ use shared_utils::{ arg::PlaceBetArg, error::BetOnCurrentlyViewingPostError, hot_or_not::{BetDirection, BettingStatus}, + ml_data::MLFeedCacheItem, post::PostDetailsFromFrontend, profile::UserProfileDetailsForFrontend, },