From f1b3fcc40ab666d8def97096d1942c274da9b279 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 11 Jun 2024 16:21:44 +0100 Subject: chore: bump rust-nostr to v0.32.0 both nostr and nostr-sdk packages and also in test_utils fix the many breaking changes fix: ignore trailing slash when depuplicate relays for send events. this was picked up as TagStandard::RelayMetadata has started adding a traling slash. refactor cli output test function `expect_send_with_progress` so that relays can succeed / fail in a random order --- test_utils/src/lib.rs | 69 +++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'test_utils/src/lib.rs') diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index daed8fa..1d881cf 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -3,8 +3,8 @@ use std::{ffi::OsStr, path::PathBuf, str::FromStr}; use anyhow::{bail, ensure, Context, Result}; use dialoguer::theme::{ColorfulTheme, Theme}; use directories::ProjectDirs; -use nostr::{self, Kind, Tag}; -use nostr_sdk::serde_json; +use nostr::{self, nips::nip65::RelayMetadata, Kind, Tag}; +use nostr_sdk::{serde_json, TagStandard}; use once_cell::sync::Lazy; use rexpect::session::{Options, PtySession}; use strip_ansi_escapes::strip_str; @@ -12,8 +12,8 @@ use strip_ansi_escapes::strip_str; pub mod git; pub mod relay; -pub static PATCH_KIND: u64 = 1617; -pub static REPOSITORY_KIND: u64 = 30617; +pub static PATCH_KIND: u16 = 1617; +pub static REPOSITORY_KIND: u16 = 30617; pub static TEST_KEY_1_NSEC: &str = "nsec1ppsg5sm2aexq06juxmu9evtutr6jkwkhp98exxxvwamhru9lyx9s3rwseq"; @@ -54,15 +54,18 @@ pub fn generate_test_key_1_relay_list_event() -> nostr::Event { nostr::Kind::RelayList, "", [ - nostr::Tag::RelayMetadata( - "ws://localhost:8053".into(), - Some(nostr::RelayMetadata::Write), - ), - nostr::Tag::RelayMetadata( - "ws://localhost:8054".into(), - Some(nostr::RelayMetadata::Read), - ), - nostr::Tag::RelayMetadata("ws://localhost:8055".into(), None), + nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { + relay_url: nostr::Url::from_str("ws://localhost:8053").unwrap(), + metadata: Some(RelayMetadata::Write), + }), + nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { + relay_url: nostr::Url::from_str("ws://localhost:8054").unwrap(), + metadata: Some(RelayMetadata::Read), + }), + nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { + relay_url: nostr::Url::from_str("ws://localhost:8055").unwrap(), + metadata: None, + }), ], ) .to_event(&TEST_KEY_1_KEYS) @@ -74,14 +77,14 @@ pub fn generate_test_key_1_relay_list_event_same_as_fallback() -> nostr::Event { nostr::Kind::RelayList, "", [ - nostr::Tag::RelayMetadata( - "ws://localhost:8051".into(), - Some(nostr::RelayMetadata::Write), - ), - nostr::Tag::RelayMetadata( - "ws://localhost:8052".into(), - Some(nostr::RelayMetadata::Write), - ), + nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { + relay_url: nostr::Url::from_str("ws://localhost:8051").unwrap(), + metadata: Some(RelayMetadata::Write), + }), + nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { + relay_url: nostr::Url::from_str("ws://localhost:8052").unwrap(), + metadata: Some(RelayMetadata::Write), + }), ], ) .to_event(&TEST_KEY_1_KEYS) @@ -141,33 +144,33 @@ pub fn generate_repo_ref_event() -> nostr::Event { nostr::Kind::Custom(REPOSITORY_KIND), "", [ - Tag::Identifier( + Tag::identifier( // root_commit.to_string() format!("{}-consider-it-random", root_commit), ), - Tag::Reference(root_commit.into()), - Tag::Name("example name".into()), - Tag::Description("example description".into()), - Tag::Generic( - nostr::TagKind::Custom("clone".to_string()), + Tag::from_standardized(TagStandard::Reference(root_commit.to_string())), + Tag::from_standardized(TagStandard::Name("example name".into())), + Tag::from_standardized(TagStandard::Description("example description".into())), + Tag::custom( + nostr::TagKind::Custom(std::borrow::Cow::Borrowed("clone")), vec!["git:://123.gitexample.com/test".to_string()], ), - Tag::Generic( - nostr::TagKind::Custom("web".to_string()), + Tag::custom( + nostr::TagKind::Custom(std::borrow::Cow::Borrowed("web")), vec![ "https://exampleproject.xyz".to_string(), "https://gitworkshop.dev/123".to_string(), ], ), - Tag::Generic( - nostr::TagKind::Custom("relays".to_string()), + Tag::custom( + nostr::TagKind::Custom(std::borrow::Cow::Borrowed("relays")), vec![ "ws://localhost:8055".to_string(), "ws://localhost:8056".to_string(), ], ), - Tag::Generic( - nostr::TagKind::Custom("maintainers".to_string()), + Tag::custom( + nostr::TagKind::Custom(std::borrow::Cow::Borrowed("maintainers")), vec![ TEST_KEY_1_KEYS.public_key().to_string(), TEST_KEY_2_KEYS.public_key().to_string(), -- cgit v1.2.3