diff options
Diffstat (limited to 'test_utils')
| -rw-r--r-- | test_utils/Cargo.toml | 8 | ||||
| -rw-r--r-- | test_utils/src/lib.rs | 25 |
2 files changed, 17 insertions, 16 deletions
diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index f4e0c7e..5f88d8d 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml | |||
| @@ -10,10 +10,10 @@ dialoguer = "0.10.4" | |||
| 10 | directories = "5.0.1" | 10 | directories = "5.0.1" |
| 11 | futures = "0.3.28" | 11 | futures = "0.3.28" |
| 12 | git2 = "0.19.0" | 12 | git2 = "0.19.0" |
| 13 | nostr = { git = "https://github.com/rust-nostr/nostr", rev = "ede2a91" } | 13 | nostr = "0.36.0" |
| 14 | nostr-database = { git = "https://github.com/rust-nostr/nostr", rev = "ede2a91" } | 14 | nostr-database = "0.36.0" |
| 15 | nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "ede2a91" } | 15 | nostr-sdk = "0.36.0" |
| 16 | nostr-lmdb = { git = "https://github.com/rust-nostr/nostr", rev = "ede2a91" } | 16 | nostr-lmdb = "0.36.0" |
| 17 | once_cell = "1.18.0" | 17 | once_cell = "1.18.0" |
| 18 | rand = "0.8" | 18 | rand = "0.8" |
| 19 | rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } | 19 | rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } |
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index 96558ef..ac17f80 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs | |||
| @@ -2,6 +2,7 @@ use std::{ | |||
| 2 | ffi::OsStr, | 2 | ffi::OsStr, |
| 3 | path::{Path, PathBuf}, | 3 | path::{Path, PathBuf}, |
| 4 | str::FromStr, | 4 | str::FromStr, |
| 5 | sync::Arc, | ||
| 5 | time::Duration, | 6 | time::Duration, |
| 6 | }; | 7 | }; |
| 7 | 8 | ||
| @@ -35,16 +36,16 @@ pub static TEST_KEY_1_ENCRYPTED_WEAK: &str = "ncryptsec1qg835almhlrmyxqtqeva44d5 | |||
| 35 | pub static TEST_KEY_1_KEYS: Lazy<nostr::Keys> = | 36 | pub static TEST_KEY_1_KEYS: Lazy<nostr::Keys> = |
| 36 | Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()); | 37 | Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()); |
| 37 | 38 | ||
| 38 | pub static TEST_KEY_1_SIGNER: Lazy<NostrSigner> = | 39 | pub static TEST_KEY_1_SIGNER: Lazy<Arc<dyn NostrSigner>> = |
| 39 | Lazy::new(|| NostrSigner::Keys(nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap())); | 40 | Lazy::new(|| Arc::new(nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap())); |
| 40 | 41 | ||
| 41 | pub fn generate_test_key_1_signer() -> NostrSigner { | 42 | pub fn generate_test_key_1_signer() -> Arc<dyn NostrSigner> { |
| 42 | NostrSigner::Keys(nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()) | 43 | Arc::new(nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()) |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | pub fn generate_test_key_1_metadata_event(name: &str) -> nostr::Event { | 46 | pub fn generate_test_key_1_metadata_event(name: &str) -> nostr::Event { |
| 46 | nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) | 47 | nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) |
| 47 | .to_event(&TEST_KEY_1_KEYS) | 48 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 48 | .unwrap() | 49 | .unwrap() |
| 49 | } | 50 | } |
| 50 | 51 | ||
| @@ -58,7 +59,7 @@ pub fn generate_test_key_1_metadata_event_old(name: &str) -> nostr::Event { | |||
| 58 | 59 | ||
| 59 | pub fn generate_test_key_1_kind_event(kind: Kind) -> nostr::Event { | 60 | pub fn generate_test_key_1_kind_event(kind: Kind) -> nostr::Event { |
| 60 | nostr::event::EventBuilder::new(kind, "", []) | 61 | nostr::event::EventBuilder::new(kind, "", []) |
| 61 | .to_event(&TEST_KEY_1_KEYS) | 62 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 62 | .unwrap() | 63 | .unwrap() |
| 63 | } | 64 | } |
| 64 | 65 | ||
| @@ -81,7 +82,7 @@ pub fn generate_test_key_1_relay_list_event() -> nostr::Event { | |||
| 81 | }), | 82 | }), |
| 82 | ], | 83 | ], |
| 83 | ) | 84 | ) |
| 84 | .to_event(&TEST_KEY_1_KEYS) | 85 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 85 | .unwrap() | 86 | .unwrap() |
| 86 | } | 87 | } |
| 87 | 88 | ||
| @@ -100,7 +101,7 @@ pub fn generate_test_key_1_relay_list_event_same_as_fallback() -> nostr::Event { | |||
| 100 | }), | 101 | }), |
| 101 | ], | 102 | ], |
| 102 | ) | 103 | ) |
| 103 | .to_event(&TEST_KEY_1_KEYS) | 104 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 104 | .unwrap() | 105 | .unwrap() |
| 105 | } | 106 | } |
| 106 | 107 | ||
| @@ -117,7 +118,7 @@ pub static TEST_KEY_2_KEYS: Lazy<nostr::Keys> = | |||
| 117 | 118 | ||
| 118 | pub fn generate_test_key_2_metadata_event(name: &str) -> nostr::Event { | 119 | pub fn generate_test_key_2_metadata_event(name: &str) -> nostr::Event { |
| 119 | nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) | 120 | nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) |
| 120 | .to_event(&TEST_KEY_2_KEYS) | 121 | .sign_with_keys(&TEST_KEY_2_KEYS) |
| 121 | .unwrap() | 122 | .unwrap() |
| 122 | } | 123 | } |
| 123 | 124 | ||
| @@ -134,7 +135,7 @@ pub fn make_event_old_or_change_user( | |||
| 134 | ) -> nostr::Event { | 135 | ) -> nostr::Event { |
| 135 | let mut unsigned = | 136 | let mut unsigned = |
| 136 | nostr::event::EventBuilder::new(event.kind, event.content.clone(), event.tags.clone()) | 137 | nostr::event::EventBuilder::new(event.kind, event.content.clone(), event.tags.clone()) |
| 137 | .to_unsigned_event(keys.public_key()); | 138 | .build(keys.public_key()); |
| 138 | 139 | ||
| 139 | unsigned.created_at = | 140 | unsigned.created_at = |
| 140 | nostr::types::Timestamp::from(nostr::types::Timestamp::now().as_u64() - how_old_in_secs); | 141 | nostr::types::Timestamp::from(nostr::types::Timestamp::now().as_u64() - how_old_in_secs); |
| @@ -146,7 +147,7 @@ pub fn make_event_old_or_change_user( | |||
| 146 | &unsigned.content, | 147 | &unsigned.content, |
| 147 | )); | 148 | )); |
| 148 | 149 | ||
| 149 | unsigned.sign(keys).unwrap() | 150 | unsigned.sign_with_keys(keys).unwrap() |
| 150 | } | 151 | } |
| 151 | 152 | ||
| 152 | pub fn generate_repo_ref_event() -> nostr::Event { | 153 | pub fn generate_repo_ref_event() -> nostr::Event { |
| @@ -196,7 +197,7 @@ pub fn generate_repo_ref_event_with_git_server(git_servers: Vec<String>) -> nost | |||
| 196 | ), | 197 | ), |
| 197 | ], | 198 | ], |
| 198 | ) | 199 | ) |
| 199 | .to_event(&TEST_KEY_1_KEYS) | 200 | .sign_with_keys(&TEST_KEY_1_KEYS) |
| 200 | .unwrap() | 201 | .unwrap() |
| 201 | } | 202 | } |
| 202 | 203 | ||