|
10 | 10 | #![warn(missing_docs)]
|
11 | 11 | #![warn(rustdoc::bare_urls)]
|
12 | 12 |
|
| 13 | +use std::collections::BTreeSet; |
13 | 14 | use std::num::NonZeroUsize;
|
14 | 15 |
|
15 | 16 | use lru::LruCache;
|
@@ -58,7 +59,7 @@ pub struct NostrMlsMemoryStorage {
|
58 | 59 | /// LRU Cache for Group objects, keyed by Nostr group ID (String)
|
59 | 60 | groups_by_nostr_id_cache: RwLock<LruCache<String, Group>>,
|
60 | 61 | /// LRU Cache for GroupRelay objects, keyed by MLS group ID (`Vec<u8>`)
|
61 |
| - group_relays_cache: RwLock<LruCache<Vec<u8>, Vec<GroupRelay>>>, |
| 62 | + group_relays_cache: RwLock<LruCache<Vec<u8>, BTreeSet<GroupRelay>>>, |
62 | 63 | /// LRU Cache for Welcome objects, keyed by Event ID
|
63 | 64 | welcomes_cache: RwLock<LruCache<EventId, Welcome>>,
|
64 | 65 | /// LRU Cache for ProcessedWelcome objects, keyed by Event ID
|
@@ -164,6 +165,8 @@ impl NostrMlsStorageProvider for NostrMlsMemoryStorage {
|
164 | 165 |
|
165 | 166 | #[cfg(test)]
|
166 | 167 | mod tests {
|
| 168 | + use std::collections::BTreeSet; |
| 169 | + |
167 | 170 | use nostr::{EventId, Kind, PublicKey, RelayUrl, Tags, Timestamp, UnsignedEvent};
|
168 | 171 | use nostr_mls_storage::groups::types::{Group, GroupState, GroupType};
|
169 | 172 | use nostr_mls_storage::groups::GroupStorage;
|
@@ -230,7 +233,7 @@ mod tests {
|
230 | 233 | nostr_group_id: "test_group_123".to_string(),
|
231 | 234 | name: "Test Group".to_string(),
|
232 | 235 | description: "A test group".to_string(),
|
233 |
| - admin_pubkeys: vec![], |
| 236 | + admin_pubkeys: BTreeSet::new(), |
234 | 237 | last_message_id: None,
|
235 | 238 | last_message_at: None,
|
236 | 239 | group_type: GroupType::Group,
|
@@ -273,7 +276,7 @@ mod tests {
|
273 | 276 | nostr_group_id: "test_group_456".to_string(),
|
274 | 277 | name: "Another Test Group".to_string(),
|
275 | 278 | description: "Another test group".to_string(),
|
276 |
| - admin_pubkeys: vec![], |
| 279 | + admin_pubkeys: BTreeSet::new(), |
277 | 280 | last_message_id: None,
|
278 | 281 | last_message_at: None,
|
279 | 282 | group_type: GroupType::Group,
|
@@ -358,8 +361,8 @@ mod tests {
|
358 | 361 | nostr_group_id: "test_welcome_group".to_string(),
|
359 | 362 | group_name: "Test Welcome Group".to_string(),
|
360 | 363 | group_description: "A test welcome group".to_string(),
|
361 |
| - group_admin_pubkeys: vec![pubkey.to_hex()], |
362 |
| - group_relays: vec!["wss://relay.example.com".to_string()], |
| 364 | + group_admin_pubkeys: BTreeSet::from([pubkey]), |
| 365 | + group_relays: BTreeSet::from([RelayUrl::parse("wss://relay.example.com").unwrap()]), |
363 | 366 | welcomer: pubkey,
|
364 | 367 | member_count: 2,
|
365 | 368 | state: WelcomeState::Pending,
|
@@ -422,7 +425,7 @@ mod tests {
|
422 | 425 | nostr_group_id: "message_test_group".to_string(),
|
423 | 426 | name: "Message Test Group".to_string(),
|
424 | 427 | description: "A group for testing messages".to_string(),
|
425 |
| - admin_pubkeys: vec![], |
| 428 | + admin_pubkeys: BTreeSet::new(), |
426 | 429 | last_message_id: None,
|
427 | 430 | last_message_at: None,
|
428 | 431 | group_type: GroupType::Group,
|
@@ -531,7 +534,7 @@ mod tests {
|
531 | 534 | nostr_group_id: "custom_cache_group".to_string(),
|
532 | 535 | name: "Custom Cache Group".to_string(),
|
533 | 536 | description: "A group for testing custom cache size".to_string(),
|
534 |
| - admin_pubkeys: vec![], |
| 537 | + admin_pubkeys: BTreeSet::new(), |
535 | 538 | last_message_id: None,
|
536 | 539 | last_message_at: None,
|
537 | 540 | group_type: GroupType::Group,
|
@@ -560,7 +563,7 @@ mod tests {
|
560 | 563 | nostr_group_id: "default_impl_group".to_string(),
|
561 | 564 | name: "Default Implementation Group".to_string(),
|
562 | 565 | description: "A group for testing default implementation".to_string(),
|
563 |
| - admin_pubkeys: vec![], |
| 566 | + admin_pubkeys: BTreeSet::new(), |
564 | 567 | last_message_id: None,
|
565 | 568 | last_message_at: None,
|
566 | 569 | group_type: GroupType::Group,
|
|
0 commit comments