From 1a476efd7c365e771c25ce3aac694015c024afe6 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:19 +0000 Subject: chore: bump rust-nostr to v0.29.0 both nostr and nostr-sdk packages and also in test_utils --- test_utils/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test_utils') diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index 8928f67..af25b43 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -9,8 +9,8 @@ assert_cmd = "2.0.12" dialoguer = "0.10.4" directories = "5.0.1" git2 = "0.18.1" -nostr = "0.27.0" -nostr-sdk = { version = "0.27.0", features = ["blocking"] } +nostr = "0.29.0" +nostr-sdk = { version = "0.29.0", features = ["blocking"] } once_cell = "1.18.0" rand = "0.8" rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } -- cgit v1.2.3 From 0d7a8383d7d54e64bb0e1d5f4e06110c1e6a818b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:34 +0000 Subject: rename from_sk_str -> from_str to reflect new name in rust-nostr --- src/key_handling/encryption.rs | 12 ++++++++---- src/key_handling/users.rs | 6 +++--- src/login.rs | 8 +++++--- test_utils/src/lib.rs | 8 ++++---- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'test_utils') diff --git a/src/key_handling/encryption.rs b/src/key_handling/encryption.rs index 0ef7f69..54002fa 100644 --- a/src/key_handling/encryption.rs +++ b/src/key_handling/encryption.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use anyhow::{anyhow, bail, ensure, Context, Result}; use chacha20poly1305::{ aead::{rand_core::RngCore, Aead, AeadCore, KeyInit, OsRng, Payload}, @@ -6,6 +8,7 @@ use chacha20poly1305::{ #[cfg(test)] use mockall::*; use nostr::{prelude::*, Keys}; +use nostr_sdk::bech32::{self, FromBase32, ToBase32}; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use zeroize::Zeroize; @@ -120,10 +123,11 @@ impl EncryptDecrypt for Encryptor { bail!("invalid encrypted key"); } - let key = Keys::from_sk_str( - std::str::from_utf8(&inner_secret).context("inner secret is not [u8]")?, - ) - .context("incorrect password. Key decrypted with password did not produce a valid nsec.")?; + let key = + Keys::from_str(std::str::from_utf8(&inner_secret).context("inner secret is not [u8]")?) + .context( + "incorrect password. Key decrypted with password did not produce a valid nsec.", + )?; inner_secret.zeroize(); diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index 2e88fba..c061cd3 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -1,4 +1,4 @@ -use std::time::SystemTime; +use std::{str::FromStr, time::SystemTime}; use anyhow::{Context, Result}; use async_trait::async_trait; @@ -59,7 +59,7 @@ impl UserManagement for UserManager { .input(PromptInputParms::default().with_prompt(prompt)) .context("failed to get nsec input from interactor")?, }; - match Keys::from_sk_str(&pk) { + match Keys::from_str(&pk) { Ok(key) => { break key; } @@ -471,7 +471,7 @@ mod tests { .expect_encrypt_key() .once() .withf(|k, p| { - k.eq(&Keys::from_sk_str(TEST_KEY_1_NSEC).unwrap()) && p.eq(TEST_PASSWORD) + k.eq(&Keys::from_str(TEST_KEY_1_NSEC).unwrap()) && p.eq(TEST_PASSWORD) }) .returning(|_, _| Ok(TEST_KEY_1_ENCRYPTED.into())); diff --git a/src/login.rs b/src/login.rs index b0fe230..4cdf3c1 100644 --- a/src/login.rs +++ b/src/login.rs @@ -1,5 +1,7 @@ +use std::str::FromStr; + use anyhow::{bail, Context, Result}; -use nostr::{prelude::FromSkStr, secp256k1::XOnlyPublicKey}; +use nostr::PublicKey; use zeroize::Zeroize; #[cfg(not(test))] @@ -25,7 +27,7 @@ pub async fn launch( // if nsec parameter let key = if let Some(nsec_unwrapped) = nsec { // get key or fail without prompts - let key = nostr::Keys::from_sk_str(nsec_unwrapped).context("invalid nsec parameter")?; + let key = nostr::Keys::from_str(nsec_unwrapped).context("invalid nsec parameter")?; // if password, add user to enable password login in future if password.is_some() { @@ -91,7 +93,7 @@ pub async fn launch( } async fn get_user_details( - public_key: &XOnlyPublicKey, + public_key: &PublicKey, #[cfg(test)] client: &crate::client::MockConnect, #[cfg(not(test))] client: &Client, ) -> Result { diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index a0c67df..ad187be 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1,9 +1,9 @@ -use std::{ffi::OsStr, path::PathBuf}; +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, prelude::FromSkStr, Kind, Tag}; +use nostr::{self, Kind, Tag}; use once_cell::sync::Lazy; use rexpect::session::{Options, PtySession}; use strip_ansi_escapes::strip_str; @@ -26,7 +26,7 @@ pub static TEST_KEY_1_DISPLAY_NAME: &str = "bob"; pub static TEST_KEY_1_ENCRYPTED: &str = "ncryptsec1qyq607h3cykxc3f2a44u89cdk336fptccn3fm5pf3nmf93d3c86qpunc7r6klwcn6lyszjy72wxwqq9aljg4pm6atvjrds9e248yhv76xfnt464265kgnjsvg8rlg06wg4sp9uljzfpu8zuaztcvfn2j8ggdrg8mldh850cy75efsyqqansert9wqmn4e6khpgvfz7h5le9"; pub static TEST_KEY_1_ENCRYPTED_WEAK: &str = "ncryptsec1qy8ke0tjqnn8wt3w6lnc86c27ry3qrptxctjfcgruryxy0at238kwyjwsswd7z88thysruzw3awlrsxjvw5uptcd7vt70ft9rtkx00m8cgy3khm4hxa5d2gfnc6athnfruy2eyl6pkas8k34jg85z7xjqqadzfzh9rp0fzxqtw0tvxksac3n8yc98uksvuf93e0lcvqy8j6"; pub static TEST_KEY_1_KEYS: Lazy = - Lazy::new(|| nostr::Keys::from_sk_str(TEST_KEY_1_NSEC).unwrap()); + Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()); pub fn generate_test_key_1_metadata_event(name: &str) -> nostr::Event { nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) @@ -95,7 +95,7 @@ pub static TEST_KEY_2_NPUB: &str = pub static TEST_KEY_2_DISPLAY_NAME: &str = "carole"; pub static TEST_KEY_2_ENCRYPTED: &str = "...2"; pub static TEST_KEY_2_KEYS: Lazy = - Lazy::new(|| nostr::Keys::from_sk_str(TEST_KEY_2_NSEC).unwrap()); + Lazy::new(|| nostr::Keys::from_str(TEST_KEY_2_NSEC).unwrap()); pub fn generate_test_key_2_metadata_event(name: &str) -> nostr::Event { nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) -- cgit v1.2.3 From 71606283bf21f0fb4931850cd69d97344dca521e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:42 +0000 Subject: replace blocking client in tests with async as it has been removed from nostr_sdk --- Cargo.lock | 1 - test_utils/Cargo.toml | 2 +- tests/list.rs | 235 ++++++++++++++++++++++++++------------------------ tests/pull.rs | 168 ++++++++++++++++++------------------ 4 files changed, 209 insertions(+), 197 deletions(-) (limited to 'test_utils') diff --git a/Cargo.lock b/Cargo.lock index 9965f63..22927d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1837,7 +1837,6 @@ dependencies = [ "nostr-signer", "nostr-zapper", "nwc", - "once_cell", "thiserror", "tokio", "tracing", diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index af25b43..e07e411 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -10,7 +10,7 @@ dialoguer = "0.10.4" directories = "5.0.1" git2 = "0.18.1" nostr = "0.29.0" -nostr-sdk = { version = "0.29.0", features = ["blocking"] } +nostr-sdk = "0.29.0" once_cell = "1.18.0" rand = "0.8" rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } diff --git a/tests/list.rs b/tests/list.rs index ee5e1dc..8252448 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -1,6 +1,6 @@ use anyhow::Result; use futures::join; -use nostr_sdk::client::blocking::Client; +use nostr_sdk::client::Client; use serial_test::serial; use test_utils::{git::GitTestRepo, relay::Relay, *}; @@ -1589,6 +1589,8 @@ mod when_main_branch_is_uptodate { mod when_latest_revision_rebases_branch { use std::time::Duration; + use tokio::{runtime::Handle, task::JoinHandle}; + use super::*; async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { @@ -1609,26 +1611,28 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = std::thread::spawn( - move || -> Result<(GitTestRepo, GitTestRepo)> { + let cli_tester_handle: JoinHandle> = + tokio::task::spawn_blocking(move || { // create 3 proposals let _ = cli_tester_create_proposals()?; // get proposal id of first - let client = Client::new(&nostr::Keys::generate()); - client.add_relay("ws://localhost:8055")?; - client.connect_relay("ws://localhost:8055")?; - let proposals = client.get_events_of( + // get proposal id of first + let client = Client::default(); + Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; + Handle::current() + .block_on(client.connect_relay("ws://localhost:8055"))?; + let proposals = Handle::current().block_on(client.get_events_of( vec![ - nostr::Filter::default() - .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag( - nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), - vec!["root"], - ), - ], + nostr::Filter::default() + .kind(nostr::Kind::Custom(PATCH_KIND)) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), + ], Some(Duration::from_millis(500)), - )?; - client.disconnect()?; + ))?; + Handle::current().block_on(client.disconnect())?; let proposal_1_id = proposals .iter() @@ -1702,8 +1706,7 @@ mod when_main_branch_is_uptodate { relay::shutdown_relay(8000 + p)?; } Ok((second_originating_repo, test_repo)) - }, - ); + }); // launch relay let _ = join!( @@ -1713,7 +1716,7 @@ mod when_main_branch_is_uptodate { r55.listen_until_close(), r56.listen_until_close(), ); - let res = cli_tester_handle.join().unwrap()?; + let res = cli_tester_handle.await??; Ok(res) } @@ -1740,99 +1743,105 @@ mod when_main_branch_is_uptodate { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - // create 3 proposals - let _ = cli_tester_create_proposals()?; - // get proposal id of first - let client = Client::new(&nostr::Keys::generate()); - client.add_relay("ws://localhost:8055")?; - client.connect_relay("ws://localhost:8055")?; - let proposals = client.get_events_of( - vec![ - nostr::Filter::default() - .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag( - nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), - vec!["root"], - ), - ], - Some(Duration::from_millis(500)), - )?; - client.disconnect()?; - - let proposal_1_id = proposals - .iter() - .find(|e| { - e.tags - .iter() - .any(|t| t.as_vec()[1].eq(&FEATURE_BRANCH_NAME_1)) - }) - .unwrap() - .id; - // recreate proposal 1 on top of a another commit (like a rebase on top - // of one extra commit) - let second_originating_repo = GitTestRepo::default(); - second_originating_repo.populate()?; - std::fs::write( - second_originating_repo.dir.join("amazing.md"), - "some content", - )?; - second_originating_repo - .stage_and_commit("commit for rebasing on top of")?; - cli_tester_create_proposal( - &second_originating_repo, - FEATURE_BRANCH_NAME_1, - "a", - Some((PROPOSAL_TITLE_1, "proposal a description")), - Some(proposal_1_id.to_string()), - )?; - - // pretend we have downloaded the origianl version of the first proposal - let test_repo = GitTestRepo::default(); - test_repo.populate()?; - create_and_populate_branch( - &test_repo, - FEATURE_BRANCH_NAME_1, - "a", - false, - )?; - // pretend we have pulled the updated main branch - test_repo.checkout("main")?; - std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; - test_repo.stage_and_commit("commit for rebasing on top of")?; - - let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); - p.expect("finding proposals...\r\n")?; - let mut c = p.expect_choice( - "all proposals", - vec![ - format!("\"{PROPOSAL_TITLE_3}\""), - format!("\"{PROPOSAL_TITLE_2}\""), - format!("\"{PROPOSAL_TITLE_1}\""), - ], - )?; - c.succeeds_with(2, true, None)?; - p.expect("finding commits...\r\n")?; - p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; - let mut c = p.expect_choice( - "", - vec![ - format!("checkout and overwrite existing proposal branch"), - format!("checkout existing outdated proposal branch"), - format!("apply to current branch with `git am`"), - format!("download to ./patches"), - format!("back"), - ], - )?; - c.succeeds_with(0, false, Some(0))?; - p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; - p.expect_end()?; - - for p in [51, 52, 53, 55, 56] { - relay::shutdown_relay(8000 + p)?; - } - Ok(()) - }); + let cli_tester_handle: JoinHandle> = tokio::task::spawn_blocking( + move || { + // create 3 proposals + let _ = cli_tester_create_proposals()?; + // get proposal id of first + let client = Client::default(); + Handle::current() + .block_on(client.add_relay("ws://localhost:8055"))?; + Handle::current() + .block_on(client.connect_relay("ws://localhost:8055"))?; + let proposals = + Handle::current().block_on(client.get_events_of( + vec![ + nostr::Filter::default() + .kind(nostr::Kind::Custom(PATCH_KIND)) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), + ], + Some(Duration::from_millis(500)), + ))?; + Handle::current().block_on(client.disconnect())?; + + let proposal_1_id = proposals + .iter() + .find(|e| { + e.tags + .iter() + .any(|t| t.as_vec()[1].eq(&FEATURE_BRANCH_NAME_1)) + }) + .unwrap() + .id; + // recreate proposal 1 on top of a another commit (like a rebase on + // top of one extra commit) + let second_originating_repo = GitTestRepo::default(); + second_originating_repo.populate()?; + std::fs::write( + second_originating_repo.dir.join("amazing.md"), + "some content", + )?; + second_originating_repo + .stage_and_commit("commit for rebasing on top of")?; + cli_tester_create_proposal( + &second_originating_repo, + FEATURE_BRANCH_NAME_1, + "a", + Some((PROPOSAL_TITLE_1, "proposal a description")), + Some(proposal_1_id.to_string()), + )?; + + // pretend we have downloaded the origianl version of the first + // proposal + let test_repo = GitTestRepo::default(); + test_repo.populate()?; + create_and_populate_branch( + &test_repo, + FEATURE_BRANCH_NAME_1, + "a", + false, + )?; + // pretend we have pulled the updated main branch + test_repo.checkout("main")?; + std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; + test_repo.stage_and_commit("commit for rebasing on top of")?; + + let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); + p.expect("finding proposals...\r\n")?; + let mut c = p.expect_choice( + "all proposals", + vec![ + format!("\"{PROPOSAL_TITLE_3}\""), + format!("\"{PROPOSAL_TITLE_2}\""), + format!("\"{PROPOSAL_TITLE_1}\""), + ], + )?; + c.succeeds_with(2, true, None)?; + p.expect("finding commits...\r\n")?; + p.expect("updated proposal available (2 ahead 0 behind 'main'). existing version is 2 ahead 1 behind 'main'\r\n")?; + let mut c = p.expect_choice( + "", + vec![ + format!("checkout and overwrite existing proposal branch"), + format!("checkout existing outdated proposal branch"), + format!("apply to current branch with `git am`"), + format!("download to ./patches"), + format!("back"), + ], + )?; + c.succeeds_with(0, false, Some(0))?; + p.expect("checked out new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; + p.expect_end()?; + + for p in [51, 52, 53, 55, 56] { + relay::shutdown_relay(8000 + p)?; + } + Ok(()) + }, + ); // launch relay let _ = join!( @@ -1842,7 +1851,7 @@ mod when_main_branch_is_uptodate { r55.listen_until_close(), r56.listen_until_close(), ); - cli_tester_handle.join().unwrap()?; + cli_tester_handle.await??; println!("{:?}", r55.events); Ok(()) } diff --git a/tests/pull.rs b/tests/pull.rs index 853f518..bf132e7 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -712,7 +712,8 @@ mod when_branch_is_checked_out { mod when_latest_event_rebases_branch { use std::time::Duration; - use nostr_sdk::blocking::Client; + use nostr_sdk::Client; + use tokio::{runtime::Handle, task::JoinHandle}; use super::*; @@ -734,26 +735,26 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = - std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { + let cli_tester_handle: JoinHandle> = + tokio::task::spawn_blocking(move || { // create 3 proposals let _ = cli_tester_create_proposals()?; // get proposal id of first - let client = Client::new(&nostr::Keys::generate()); - client.add_relay("ws://localhost:8055")?; - client.connect_relay("ws://localhost:8055")?; - let proposals = client.get_events_of( + let client = Client::default(); + Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; + Handle::current().block_on(client.connect_relay("ws://localhost:8055"))?; + let proposals = Handle::current().block_on(client.get_events_of( vec![ - nostr::Filter::default() - .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag( - nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), - vec!["root"], - ), - ], + nostr::Filter::default() + .kind(nostr::Kind::Custom(PATCH_KIND)) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), + ], Some(Duration::from_millis(500)), - )?; - client.disconnect()?; + ))?; + Handle::current().block_on(client.disconnect())?; let proposal_1_id = proposals .iter() @@ -808,7 +809,7 @@ mod when_branch_is_checked_out { r55.listen_until_close(), r56.listen_until_close(), ); - let res = cli_tester_handle.join().unwrap()?; + let res = cli_tester_handle.await??; Ok(res) } @@ -835,72 +836,75 @@ mod when_branch_is_checked_out { r55.events.push(generate_test_key_1_metadata_event("fred")); r55.events.push(generate_test_key_1_relay_list_event()); - let cli_tester_handle = std::thread::spawn(move || -> Result<()> { - // create 3 proposals - let _ = cli_tester_create_proposals()?; - // get proposal id of first - let client = Client::new(&nostr::Keys::generate()); - client.add_relay("ws://localhost:8055")?; - client.connect_relay("ws://localhost:8055")?; - let proposals = client.get_events_of( - vec![ - nostr::Filter::default() - .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag( - nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), - vec!["root"], - ), - ], - Some(Duration::from_millis(500)), - )?; - client.disconnect()?; - - let proposal_1_id = proposals - .iter() - .find(|e| { - e.tags - .iter() - .any(|t| t.as_vec()[1].eq(&FEATURE_BRANCH_NAME_1)) - }) - .unwrap() - .id; - // recreate proposal 1 on top of a another commit (like a rebase on top - // of one extra commit) - let second_originating_repo = GitTestRepo::default(); - second_originating_repo.populate()?; - std::fs::write( - second_originating_repo.dir.join("amazing.md"), - "some content", - )?; - second_originating_repo.stage_and_commit("commit for rebasing on top of")?; - cli_tester_create_proposal( - &second_originating_repo, - FEATURE_BRANCH_NAME_1, - "a", - Some((PROPOSAL_TITLE_1, "proposal a description")), - Some(proposal_1_id.to_string()), - )?; - - // pretend we have downloaded the origianl version of the first proposal - let test_repo = GitTestRepo::default(); - test_repo.populate()?; - create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; - // pretend we have pulled the updated main branch - test_repo.checkout("main")?; - std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; - test_repo.stage_and_commit("commit for rebasing on top of")?; - test_repo.checkout(FEATURE_BRANCH_NAME_1)?; + let cli_tester_handle: JoinHandle> = tokio::task::spawn_blocking( + move || { + // create 3 proposals + let _ = cli_tester_create_proposals()?; + // get proposal id of first + let client = Client::default(); + Handle::current().block_on(client.add_relay("ws://localhost:8055"))?; + Handle::current().block_on(client.connect_relay("ws://localhost:8055"))?; + let proposals = Handle::current().block_on(client.get_events_of( + vec![ + nostr::Filter::default() + .kind(nostr::Kind::Custom(PATCH_KIND)) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), + ], + Some(Duration::from_millis(500)), + ))?; + Handle::current().block_on(client.disconnect())?; + + let proposal_1_id = proposals + .iter() + .find(|e| { + e.tags + .iter() + .any(|t| t.as_vec()[1].eq(&FEATURE_BRANCH_NAME_1)) + }) + .unwrap() + .id; + // recreate proposal 1 on top of a another commit (like a rebase on top + // of one extra commit) + let second_originating_repo = GitTestRepo::default(); + second_originating_repo.populate()?; + std::fs::write( + second_originating_repo.dir.join("amazing.md"), + "some content", + )?; + second_originating_repo + .stage_and_commit("commit for rebasing on top of")?; + cli_tester_create_proposal( + &second_originating_repo, + FEATURE_BRANCH_NAME_1, + "a", + Some((PROPOSAL_TITLE_1, "proposal a description")), + Some(proposal_1_id.to_string()), + )?; + + // pretend we have downloaded the origianl version of the first proposal + let test_repo = GitTestRepo::default(); + test_repo.populate()?; + create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; + // pretend we have pulled the updated main branch + test_repo.checkout("main")?; + std::fs::write(test_repo.dir.join("amazing.md"), "some content")?; + test_repo.stage_and_commit("commit for rebasing on top of")?; + test_repo.checkout(FEATURE_BRANCH_NAME_1)?; - let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); - p.expect("finding proposal root event...\r\n")?; - p.expect("found proposal root event. finding commits...\r\n")?; - p.expect_end_with("pulled new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; + let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); + p.expect("finding proposal root event...\r\n")?; + p.expect("found proposal root event. finding commits...\r\n")?; + p.expect_end_with("pulled new version of proposal (2 ahead 0 behind 'main'), replacing old version (2 ahead 1 behind 'main')\r\n")?; - for p in [51, 52, 53, 55, 56] { - relay::shutdown_relay(8000 + p)?; - } - Ok(()) - }); + for p in [51, 52, 53, 55, 56] { + relay::shutdown_relay(8000 + p)?; + } + Ok(()) + }, + ); // launch relay let _ = join!( @@ -910,7 +914,7 @@ mod when_branch_is_checked_out { r55.listen_until_close(), r56.listen_until_close(), ); - cli_tester_handle.join().unwrap()?; + cli_tester_handle.await??; println!("{:?}", r55.events); Ok(()) } -- cgit v1.2.3 From dfc31c40c9f941e55a5130d334d6383462a6fc85 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 26 Mar 2024 14:34:42 +0000 Subject: use patched nostr-rust v0.29 to address send_event_to spurious timeout error --- Cargo.lock | 21 +++++++-------------- Cargo.toml | 4 ++-- test_utils/Cargo.toml | 4 ++-- 3 files changed, 11 insertions(+), 18 deletions(-) (limited to 'test_utils') diff --git a/Cargo.lock b/Cargo.lock index 22927d7..ba12e87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1766,8 +1766,7 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nostr" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "255485c2f41cf8f39d4e4a1901199549f54e32def81a71a8afe05f75809f441d" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "aes 0.8.4", "base64", @@ -1796,8 +1795,7 @@ dependencies = [ [[package]] name = "nostr-database" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e15ab55f96ea5e560af0c75f1d942b1064266d443d11b2afbe51ca9ad78a018" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-trait", "lru", @@ -1810,8 +1808,7 @@ dependencies = [ [[package]] name = "nostr-relay-pool" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b39b3dc3f1fe912a0f530ad8bd2e71c55608679c8c427952f71c13f0a4c545" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-utility", "async-wsocket", @@ -1826,8 +1823,7 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ed0ab9cbc3b20d3dba99337f2e0739f052ebe32133d690e212022a06a22044" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-utility", "lnurl-pay", @@ -1845,8 +1841,7 @@ dependencies = [ [[package]] name = "nostr-signer" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bdc7c26887d7e65632e66872989a19892dfe9f2c6dbd9a1d3f959c5c524d5" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-utility", "nostr", @@ -1858,8 +1853,7 @@ dependencies = [ [[package]] name = "nostr-zapper" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061d5eb00b430747a984ea9e41cd82c849832151b4263d8230c9c220dc2c62f8" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-trait", "nostr", @@ -1960,8 +1954,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nwc" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1894ffe54a1e5adf8dbb22b5a290c0748ec4a88aa07fa69c4359010edea49ed" +source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" dependencies = [ "async-utility", "nostr", diff --git a/Cargo.toml b/Cargo.toml index e07e1a4..3484e25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ futures = "0.3.28" git2 = "0.18.1" indicatif = "0.17.7" keyring = "2.0.5" -nostr = "0.29.0" -nostr-sdk = "0.29.0" +nostr = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } +nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } passwords = "3.1.13" scrypt = "0.11.0" serde = { version = "1.0.181", features = ["derive"] } diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index e07e411..10900fd 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -9,8 +9,8 @@ assert_cmd = "2.0.12" dialoguer = "0.10.4" directories = "5.0.1" git2 = "0.18.1" -nostr = "0.29.0" -nostr-sdk = "0.29.0" +nostr = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } +nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } once_cell = "1.18.0" rand = "0.8" rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } -- cgit v1.2.3 From 53bbbbf5d5b9bbdbb0a8598705e7ee8fe3087c11 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 26 Mar 2024 16:41:30 +0000 Subject: bump nostr-relay-pool to v0.29.1 as patch accepted into package --- Cargo.lock | 25 ++++++++++++++++--------- Cargo.toml | 4 ++-- test_utils/Cargo.toml | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'test_utils') diff --git a/Cargo.lock b/Cargo.lock index ba12e87..29bf716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,7 +1324,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -1766,7 +1766,8 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nostr" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255485c2f41cf8f39d4e4a1901199549f54e32def81a71a8afe05f75809f441d" dependencies = [ "aes 0.8.4", "base64", @@ -1795,7 +1796,8 @@ dependencies = [ [[package]] name = "nostr-database" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e15ab55f96ea5e560af0c75f1d942b1064266d443d11b2afbe51ca9ad78a018" dependencies = [ "async-trait", "lru", @@ -1807,8 +1809,9 @@ dependencies = [ [[package]] name = "nostr-relay-pool" -version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c3431820082c850315218193c7e33a328b4b2cd0129d4fd5446a4dab87ddc4" dependencies = [ "async-utility", "async-wsocket", @@ -1823,7 +1826,8 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81ed0ab9cbc3b20d3dba99337f2e0739f052ebe32133d690e212022a06a22044" dependencies = [ "async-utility", "lnurl-pay", @@ -1841,7 +1845,8 @@ dependencies = [ [[package]] name = "nostr-signer" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bdc7c26887d7e65632e66872989a19892dfe9f2c6dbd9a1d3f959c5c524d5" dependencies = [ "async-utility", "nostr", @@ -1853,7 +1858,8 @@ dependencies = [ [[package]] name = "nostr-zapper" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061d5eb00b430747a984ea9e41cd82c849832151b4263d8230c9c220dc2c62f8" dependencies = [ "async-trait", "nostr", @@ -1954,7 +1960,8 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nwc" version = "0.29.0" -source = "git+https://github.com/DanConwayDev/nostr?branch=v0-29-with-send-events-fix#20901408c61ba3977e4927bc069f3870a9174b1b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1894ffe54a1e5adf8dbb22b5a290c0748ec4a88aa07fa69c4359010edea49ed" dependencies = [ "async-utility", "nostr", diff --git a/Cargo.toml b/Cargo.toml index 3484e25..67706a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ futures = "0.3.28" git2 = "0.18.1" indicatif = "0.17.7" keyring = "2.0.5" -nostr = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } -nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } +nostr = "0.29" +nostr-sdk = "0.29" passwords = "3.1.13" scrypt = "0.11.0" serde = { version = "1.0.181", features = ["derive"] } diff --git a/test_utils/Cargo.toml b/test_utils/Cargo.toml index 10900fd..c4e1b1a 100644 --- a/test_utils/Cargo.toml +++ b/test_utils/Cargo.toml @@ -9,8 +9,8 @@ assert_cmd = "2.0.12" dialoguer = "0.10.4" directories = "5.0.1" git2 = "0.18.1" -nostr = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } -nostr-sdk = { git = "https://github.com/DanConwayDev/nostr", branch="v0-29-with-send-events-fix" } +nostr = "0.29" +nostr-sdk = "0.29" once_cell = "1.18.0" rand = "0.8" rexpect = { git = "https://github.com/rust-cli/rexpect.git", rev = "9eb61dd" } -- cgit v1.2.3