Skip to content

Commit

Permalink
Hack to work around serde(untagged) not working with u128 values (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 5, 2024
1 parent c680a4a commit 9a2061f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions backend/canisters/community/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ struct Data {
description: Timestamped<String>,
#[serde(deserialize_with = "deserialize_maybe_timestamped")]
rules: Timestamped<AccessRulesInternal>,
#[serde(deserialize_with = "deserialize_maybe_timestamped")]
#[serde(deserialize_with = "deserialize_optional_document")]
avatar: Timestamped<Option<Document>>,
#[serde(deserialize_with = "deserialize_maybe_timestamped")]
#[serde(deserialize_with = "deserialize_optional_document")]
banner: Timestamped<Option<Document>>,
#[serde(deserialize_with = "deserialize_maybe_timestamped")]
permissions: Timestamped<CommunityPermissions>,
Expand Down Expand Up @@ -965,3 +965,8 @@ pub struct AddUsersToChannelResult {
pub users_already_in_channel: Vec<UserId>,
pub users_limit_reached: Vec<UserId>,
}

fn deserialize_optional_document<'de, D: Deserializer<'de>>(d: D) -> Result<Timestamped<Option<Document>>, D::Error> {
let document = Option::deserialize(d)?;
Ok(Timestamped::new(document, now_millis()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
87
88
);

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(), 3);
assert_eq!(get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), 4);
}

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

0 comments on commit 9a2061f

Please sign in to comment.