Skip to content

Commit

Permalink
Fix logging of events migrated to stable memory + fix test (#6992)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 5, 2024
1 parent 7338c9a commit b67c71d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ fn post_upgrade(args: Args) {

assert!(data.members_migrated_to_stable_memory);

data.events.migrate_to_stable_memory();

canister_logger::init_with_logs(data.test_mode, errors, logs, traces);

data.events.migrate_to_stable_memory();

let env = init_env(data.rng_seed);
init_state(env, data, args.wasm_version);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ fn stable_memory_garbage_collected_after_deleting_channel() {
} = init_test_data(env, canister_ids, *controller);

let stable_map = get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID);
// 10 keys = 2 community members, 2 events and 2 users per channel
assert_eq!(stable_map.len(), 10);
// 11 keys = 1 community event, 2 community members, 2 chat events and 2 users per channel
assert_eq!(stable_map.len(), 11);

for _ in 0..100 {
client::community::happy_path::send_text_message(env, &user1, community_id, channel_id1, None, random_string(), None);
}

assert_eq!(
get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(),
110
111
);

for _ in 0..80 {
Expand All @@ -84,7 +84,7 @@ fn stable_memory_garbage_collected_after_deleting_channel() {

assert_eq!(
get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(),
190
191
);

client::community::happy_path::delete_channel(env, user1.principal, community_id, channel_id1);
Expand All @@ -94,15 +94,15 @@ fn stable_memory_garbage_collected_after_deleting_channel() {

assert_eq!(
get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(),
86
87
);

client::community::happy_path::delete_channel(env, user1.principal, community_id, channel_id2);

env.advance_time(Duration::from_secs(60));
env.tick();

assert_eq!(get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), 2);
assert_eq!(get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), 3);
}

fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Principal) -> TestData {
Expand Down

0 comments on commit b67c71d

Please sign in to comment.