diff options
Diffstat (limited to 'test_utils/src/lib.rs')
| -rw-r--r-- | test_utils/src/lib.rs | 69 |
1 files changed, 36 insertions, 33 deletions
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}; | |||
| 3 | use anyhow::{bail, ensure, Context, Result}; | 3 | use anyhow::{bail, ensure, Context, Result}; |
| 4 | use dialoguer::theme::{ColorfulTheme, Theme}; | 4 | use dialoguer::theme::{ColorfulTheme, Theme}; |
| 5 | use directories::ProjectDirs; | 5 | use directories::ProjectDirs; |
| 6 | use nostr::{self, Kind, Tag}; | 6 | use nostr::{self, nips::nip65::RelayMetadata, Kind, Tag}; |
| 7 | use nostr_sdk::serde_json; | 7 | use nostr_sdk::{serde_json, TagStandard}; |
| 8 | use once_cell::sync::Lazy; | 8 | use once_cell::sync::Lazy; |
| 9 | use rexpect::session::{Options, PtySession}; | 9 | use rexpect::session::{Options, PtySession}; |
| 10 | use strip_ansi_escapes::strip_str; | 10 | use strip_ansi_escapes::strip_str; |
| @@ -12,8 +12,8 @@ use strip_ansi_escapes::strip_str; | |||
| 12 | pub mod git; | 12 | pub mod git; |
| 13 | pub mod relay; | 13 | pub mod relay; |
| 14 | 14 | ||
| 15 | pub static PATCH_KIND: u64 = 1617; | 15 | pub static PATCH_KIND: u16 = 1617; |
| 16 | pub static REPOSITORY_KIND: u64 = 30617; | 16 | pub static REPOSITORY_KIND: u16 = 30617; |
| 17 | 17 | ||
| 18 | pub static TEST_KEY_1_NSEC: &str = | 18 | pub static TEST_KEY_1_NSEC: &str = |
| 19 | "nsec1ppsg5sm2aexq06juxmu9evtutr6jkwkhp98exxxvwamhru9lyx9s3rwseq"; | 19 | "nsec1ppsg5sm2aexq06juxmu9evtutr6jkwkhp98exxxvwamhru9lyx9s3rwseq"; |
| @@ -54,15 +54,18 @@ pub fn generate_test_key_1_relay_list_event() -> nostr::Event { | |||
| 54 | nostr::Kind::RelayList, | 54 | nostr::Kind::RelayList, |
| 55 | "", | 55 | "", |
| 56 | [ | 56 | [ |
| 57 | nostr::Tag::RelayMetadata( | 57 | nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { |
| 58 | "ws://localhost:8053".into(), | 58 | relay_url: nostr::Url::from_str("ws://localhost:8053").unwrap(), |
| 59 | Some(nostr::RelayMetadata::Write), | 59 | metadata: Some(RelayMetadata::Write), |
| 60 | ), | 60 | }), |
| 61 | nostr::Tag::RelayMetadata( | 61 | nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { |
| 62 | "ws://localhost:8054".into(), | 62 | relay_url: nostr::Url::from_str("ws://localhost:8054").unwrap(), |
| 63 | Some(nostr::RelayMetadata::Read), | 63 | metadata: Some(RelayMetadata::Read), |
| 64 | ), | 64 | }), |
| 65 | nostr::Tag::RelayMetadata("ws://localhost:8055".into(), None), | 65 | nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { |
| 66 | relay_url: nostr::Url::from_str("ws://localhost:8055").unwrap(), | ||
| 67 | metadata: None, | ||
| 68 | }), | ||
| 66 | ], | 69 | ], |
| 67 | ) | 70 | ) |
| 68 | .to_event(&TEST_KEY_1_KEYS) | 71 | .to_event(&TEST_KEY_1_KEYS) |
| @@ -74,14 +77,14 @@ pub fn generate_test_key_1_relay_list_event_same_as_fallback() -> nostr::Event { | |||
| 74 | nostr::Kind::RelayList, | 77 | nostr::Kind::RelayList, |
| 75 | "", | 78 | "", |
| 76 | [ | 79 | [ |
| 77 | nostr::Tag::RelayMetadata( | 80 | nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { |
| 78 | "ws://localhost:8051".into(), | 81 | relay_url: nostr::Url::from_str("ws://localhost:8051").unwrap(), |
| 79 | Some(nostr::RelayMetadata::Write), | 82 | metadata: Some(RelayMetadata::Write), |
| 80 | ), | 83 | }), |
| 81 | nostr::Tag::RelayMetadata( | 84 | nostr::Tag::from_standardized(nostr::TagStandard::RelayMetadata { |
| 82 | "ws://localhost:8052".into(), | 85 | relay_url: nostr::Url::from_str("ws://localhost:8052").unwrap(), |
| 83 | Some(nostr::RelayMetadata::Write), | 86 | metadata: Some(RelayMetadata::Write), |
| 84 | ), | 87 | }), |
| 85 | ], | 88 | ], |
| 86 | ) | 89 | ) |
| 87 | .to_event(&TEST_KEY_1_KEYS) | 90 | .to_event(&TEST_KEY_1_KEYS) |
| @@ -141,33 +144,33 @@ pub fn generate_repo_ref_event() -> nostr::Event { | |||
| 141 | nostr::Kind::Custom(REPOSITORY_KIND), | 144 | nostr::Kind::Custom(REPOSITORY_KIND), |
| 142 | "", | 145 | "", |
| 143 | [ | 146 | [ |
| 144 | Tag::Identifier( | 147 | Tag::identifier( |
| 145 | // root_commit.to_string() | 148 | // root_commit.to_string() |
| 146 | format!("{}-consider-it-random", root_commit), | 149 | format!("{}-consider-it-random", root_commit), |
| 147 | ), | 150 | ), |
| 148 | Tag::Reference(root_commit.into()), | 151 | Tag::from_standardized(TagStandard::Reference(root_commit.to_string())), |
| 149 | Tag::Name("example name".into()), | 152 | Tag::from_standardized(TagStandard::Name("example name".into())), |
| 150 | Tag::Description("example description".into()), | 153 | Tag::from_standardized(TagStandard::Description("example description".into())), |
| 151 | Tag::Generic( | 154 | Tag::custom( |
| 152 | nostr::TagKind::Custom("clone".to_string()), | 155 | nostr::TagKind::Custom(std::borrow::Cow::Borrowed("clone")), |
| 153 | vec!["git:://123.gitexample.com/test".to_string()], | 156 | vec!["git:://123.gitexample.com/test".to_string()], |
| 154 | ), | 157 | ), |
| 155 | Tag::Generic( | 158 | Tag::custom( |
| 156 | nostr::TagKind::Custom("web".to_string()), | 159 | nostr::TagKind::Custom(std::borrow::Cow::Borrowed("web")), |
| 157 | vec![ | 160 | vec![ |
| 158 | "https://exampleproject.xyz".to_string(), | 161 | "https://exampleproject.xyz".to_string(), |
| 159 | "https://gitworkshop.dev/123".to_string(), | 162 | "https://gitworkshop.dev/123".to_string(), |
| 160 | ], | 163 | ], |
| 161 | ), | 164 | ), |
| 162 | Tag::Generic( | 165 | Tag::custom( |
| 163 | nostr::TagKind::Custom("relays".to_string()), | 166 | nostr::TagKind::Custom(std::borrow::Cow::Borrowed("relays")), |
| 164 | vec![ | 167 | vec![ |
| 165 | "ws://localhost:8055".to_string(), | 168 | "ws://localhost:8055".to_string(), |
| 166 | "ws://localhost:8056".to_string(), | 169 | "ws://localhost:8056".to_string(), |
| 167 | ], | 170 | ], |
| 168 | ), | 171 | ), |
| 169 | Tag::Generic( | 172 | Tag::custom( |
| 170 | nostr::TagKind::Custom("maintainers".to_string()), | 173 | nostr::TagKind::Custom(std::borrow::Cow::Borrowed("maintainers")), |
| 171 | vec![ | 174 | vec![ |
| 172 | TEST_KEY_1_KEYS.public_key().to_string(), | 175 | TEST_KEY_1_KEYS.public_key().to_string(), |
| 173 | TEST_KEY_2_KEYS.public_key().to_string(), | 176 | TEST_KEY_2_KEYS.public_key().to_string(), |