upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/test_utils/src/lib.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-04-01 14:31:34 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-04-01 14:35:50 +0100
commit948fe972eb2bddf187b79f2673a091b6331cfd90 (patch)
treeec1c538d28108b104b5a00afd673631538f9aa00 /test_utils/src/lib.rs
parent70966d571fce16f707725c6b0af0fd585bfce607 (diff)
chore: bump rust-nostr v0.37 ~> v0.40
and fix all of the breaking changes
Diffstat (limited to 'test_utils/src/lib.rs')
-rw-r--r--test_utils/src/lib.rs54
1 files changed, 32 insertions, 22 deletions
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs
index 5c8d7a5..66d0df5 100644
--- a/test_utils/src/lib.rs
+++ b/test_utils/src/lib.rs
@@ -1,4 +1,5 @@
1use std::{ 1use std::{
2 collections::HashSet,
2 ffi::OsStr, 3 ffi::OsStr,
3 path::{Path, PathBuf}, 4 path::{Path, PathBuf},
4 str::FromStr, 5 str::FromStr,
@@ -8,13 +9,13 @@ use std::{
8 9
9use anyhow::{Context, Result, bail, ensure}; 10use anyhow::{Context, Result, bail, ensure};
10use dialoguer::theme::{ColorfulTheme, Theme}; 11use dialoguer::theme::{ColorfulTheme, Theme};
11use futures::executor::block_on; 12use futures::{executor::block_on, future::join_all};
12use git::GitTestRepo; 13use git::GitTestRepo;
13use git2::{Signature, Time}; 14use git2::{Signature, Time};
14use nostr::{self, Kind, Tag, nips::nip65::RelayMetadata}; 15use nostr::{self, Kind, Tag, nips::nip65::RelayMetadata};
15use nostr_database::NostrEventsDatabase; 16use nostr_database::NostrEventsDatabase;
16use nostr_lmdb::NostrLMDB; 17use nostr_lmdb::NostrLMDB;
17use nostr_sdk::{Client, NostrSigner, TagStandard, serde_json}; 18use nostr_sdk::{Client, Event, NostrSigner, TagStandard, serde_json};
18use once_cell::sync::Lazy; 19use once_cell::sync::Lazy;
19use rexpect::session::{Options, PtySession}; 20use rexpect::session::{Options, PtySession};
20use strip_ansi_escapes::strip_str; 21use strip_ansi_escapes::strip_str;
@@ -139,7 +140,7 @@ pub fn make_event_old_or_change_user(
139 &keys.public_key(), 140 &keys.public_key(),
140 &unsigned.created_at, 141 &unsigned.created_at,
141 &unsigned.kind, 142 &unsigned.kind,
142 &unsigned.tags.clone().to_vec(), 143 &unsigned.tags.clone(),
143 &unsigned.content, 144 &unsigned.content,
144 )); 145 ));
145 146
@@ -1107,14 +1108,24 @@ pub async fn get_events_from_cache(
1107 git_repo_path: &Path, 1108 git_repo_path: &Path,
1108 filters: Vec<nostr::Filter>, 1109 filters: Vec<nostr::Filter>,
1109) -> Result<Vec<nostr::Event>> { 1110) -> Result<Vec<nostr::Event>> {
1110 Ok(get_local_cache_database(git_repo_path) 1111 let db = get_local_cache_database(git_repo_path).await?;
1111 .await? 1112
1112 .query(filters.clone()) 1113 let query_results = join_all(filters.into_iter().map(|filter| async {
1113 .await 1114 db.query(filter).await.context(
1114 .context(
1115 "failed to execute query on opened git repo nostr cache database .git/nostr-cache.lmdb", 1115 "failed to execute query on opened git repo nostr cache database .git/nostr-cache.lmdb",
1116 )? 1116 )
1117 .to_vec()) 1117 }))
1118 .await;
1119
1120 // no Event is being mutated, just new items added to the set
1121 #[allow(clippy::mutable_key_type)]
1122 let mut events: HashSet<Event> = HashSet::new();
1123
1124 for result in query_results {
1125 events.extend(result?);
1126 }
1127
1128 Ok(events.into_iter().collect())
1118} 1129}
1119 1130
1120pub fn get_proposal_branch_name( 1131pub fn get_proposal_branch_name(
@@ -1436,19 +1447,18 @@ fn get_first_proposal_event_id() -> Result<nostr::EventId> {
1436 Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; 1447 Handle::current().block_on(client.add_relay("ws://localhost:8055"))?;
1437 Handle::current().block_on(client.connect_relay("ws://localhost:8055"))?; 1448 Handle::current().block_on(client.connect_relay("ws://localhost:8055"))?;
1438 let proposals = Handle::current() 1449 let proposals = Handle::current()
1439 .block_on(client.fetch_events( 1450 .block_on(
1440 vec![ 1451 client.fetch_events(
1441 nostr::Filter::default() 1452 nostr::Filter::default()
1442 .kind(nostr::Kind::GitPatch) 1453 .kind(nostr::Kind::GitPatch)
1443 .custom_tag( 1454 .custom_tags(nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), vec![
1444 nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), 1455 "root",
1445 vec!["root"], 1456 ]),
1446 ), 1457 Duration::from_millis(500),
1447 ], 1458 ),
1448 Some(Duration::from_millis(500)), 1459 )?
1449 ))?
1450 .to_vec(); 1460 .to_vec();
1451 Handle::current().block_on(client.disconnect())?; 1461 Handle::current().block_on(client.disconnect());
1452 1462
1453 let proposal_1_id = proposals 1463 let proposal_1_id = proposals
1454 .iter() 1464 .iter()