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 --- Cargo.lock | 312 ++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 4 +- test_utils/Cargo.toml | 4 +- 3 files changed, 269 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97614fa..9965f63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,6 +50,18 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -59,6 +71,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "anstream" version = "0.6.13" @@ -301,9 +319,9 @@ dependencies = [ [[package]] name = "async-utility" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3716c0d3970fe92d79a8f4cda2caf91113574505dff5b18e455e549d4b078e98" +checksum = "a349201d80b4aa18d17a34a182bdd7f8ddf845e9e57d2ea130a12e10ef1e3a47" dependencies = [ "futures-util", "gloo-timers", @@ -313,20 +331,20 @@ dependencies = [ [[package]] name = "async-wsocket" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d55992e9155e571208dc012c2a5c056572d1ab167bc299a63810ebf910226c" +checksum = "d253e375ea899cb131b92a474587e217634e7ea927c24d8098eecbcad0c5c97a" dependencies = [ "async-utility", "futures-util", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tokio-socks", - "tokio-tungstenite", - "url-fork", + "tokio-tungstenite 0.21.0", + "url", "wasm-ws", - "webpki-roots", + "webpki-roots 0.26.1", ] [[package]] @@ -340,6 +358,15 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "atomic-destructor" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4653a42bf04120a1d4e92452e006b4e3af4ab4afff8fb4af0f1bbb98418adf3e" +dependencies = [ + "tracing", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -1169,7 +1196,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap", "slab", "tokio", @@ -1182,6 +1209,10 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -1242,6 +1273,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1249,7 +1291,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", "pin-project-lite", ] @@ -1276,7 +1318,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "httparse", "httpdate", @@ -1296,11 +1338,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", - "http", + "http 0.2.12", "hyper", - "rustls", + "rustls 0.21.10", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -1507,6 +1549,18 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "lnurl-pay" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b628658116d331c9567f6cb22415d726125ff6e328d1fb1b422b1b58afeaec21" +dependencies = [ + "bech32", + "reqwest", + "serde", + "serde_json", +] + [[package]] name = "lock_api" version = "0.4.11" @@ -1523,6 +1577,15 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown", +] + [[package]] name = "memchr" version = "2.7.1" @@ -1702,9 +1765,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nostr" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e47228d958fd65ef3e04650a3b1dd80f16f10f0243c80ed969556dead0f48c8" +checksum = "255485c2f41cf8f39d4e4a1901199549f54e32def81a71a8afe05f75809f441d" dependencies = [ "aes 0.8.4", "base64", @@ -1712,16 +1775,19 @@ dependencies = [ "bitcoin", "cbc", "chacha20", + "chacha20poly1305", "getrandom", "instant", "js-sys", "negentropy", "once_cell", "reqwest", + "scrypt", "serde", "serde_json", "tracing", - "url-fork", + "unicode-normalization", + "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -1729,11 +1795,12 @@ dependencies = [ [[package]] name = "nostr-database" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa0550256c8d4f0aaf74891ac986bd5ba46b2957c2c7e20f51838fa5819285f8" +checksum = "8e15ab55f96ea5e560af0c75f1d942b1064266d443d11b2afbe51ca9ad78a018" dependencies = [ "async-trait", + "lru", "nostr", "thiserror", "tokio", @@ -1741,21 +1808,65 @@ dependencies = [ ] [[package]] -name = "nostr-sdk" -version = "0.27.0" +name = "nostr-relay-pool" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf190e41230721f0ce64f5ea72ed36cbc431d3b305eb166e24a94f5d7e4a425" +checksum = "83b39b3dc3f1fe912a0f530ad8bd2e71c55608679c8c427952f71c13f0a4c545" dependencies = [ "async-utility", "async-wsocket", + "atomic-destructor", "nostr", "nostr-database", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "nostr-sdk" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81ed0ab9cbc3b20d3dba99337f2e0739f052ebe32133d690e212022a06a22044" +dependencies = [ + "async-utility", + "lnurl-pay", + "nostr", + "nostr-database", + "nostr-relay-pool", + "nostr-signer", + "nostr-zapper", + "nwc", "once_cell", "thiserror", "tokio", "tracing", ] +[[package]] +name = "nostr-signer" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bdc7c26887d7e65632e66872989a19892dfe9f2c6dbd9a1d3f959c5c524d5" +dependencies = [ + "async-utility", + "nostr", + "nostr-relay-pool", + "thiserror", + "tokio", +] + +[[package]] +name = "nostr-zapper" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061d5eb00b430747a984ea9e41cd82c849832151b4263d8230c9c220dc2c62f8" +dependencies = [ + "async-trait", + "nostr", + "thiserror", +] + [[package]] name = "num" version = "0.4.1" @@ -1847,6 +1958,20 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" +[[package]] +name = "nwc" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1894ffe54a1e5adf8dbb22b5a290c0748ec4a88aa07fa69c4359010edea49ed" +dependencies = [ + "async-utility", + "nostr", + "nostr-relay-pool", + "nostr-zapper", + "thiserror", + "tracing", +] + [[package]] name = "object" version = "0.32.2" @@ -2300,7 +2425,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.12", "http-body", "hyper", "hyper-rustls", @@ -2311,7 +2436,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.10", "rustls-pemfile", "serde", "serde_json", @@ -2319,14 +2444,14 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-socks", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 0.25.4", "winreg", ] @@ -2420,10 +2545,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -2433,6 +2572,12 @@ dependencies = [ "base64", ] +[[package]] +name = "rustls-pki-types" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -2443,6 +2588,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.17" @@ -2699,7 +2855,7 @@ dependencies = [ "flume", "futures-util", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.20.1", ] [[package]] @@ -2856,7 +3012,7 @@ dependencies = [ "rexpect 0.5.0 (git+https://github.com/rust-cli/rexpect.git?rev=9eb61dd)", "simple-websockets", "strip-ansi-escapes", - "tungstenite", + "tungstenite 0.20.1", ] [[package]] @@ -2930,7 +3086,18 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.2", + "rustls-pki-types", "tokio", ] @@ -2954,11 +3121,24 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls", "tokio", - "tokio-rustls", - "tungstenite", - "webpki-roots", + "tungstenite 0.20.1", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "rustls 0.22.2", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.25.0", + "tungstenite 0.21.0", + "webpki-roots 0.26.1", ] [[package]] @@ -3044,11 +3224,31 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.12", "httparse", "log", "rand", - "rustls", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "rustls 0.22.2", + "rustls-pki-types", "sha1", "thiserror", "url", @@ -3126,17 +3326,6 @@ name = "url" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "url-fork" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa3323c39b8e786154d3000b70ae9af0e9bd746c9791456da0d4a1f68ad89d6" dependencies = [ "form_urlencoded", "idna", @@ -3317,6 +3506,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3566,6 +3764,26 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.53", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index 7793a8c..e07e1a4 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.27.0" -nostr-sdk = "0.27.0" +nostr = "0.29.0" +nostr-sdk = "0.29.0" 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 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 07a6b27eacc9cb80b0858ae8d7042287567ea790 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:28 +0000 Subject: ClientSigner renamed ~> NostrSigner to reflect new name in rust-nostr --- src/client.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index 539d45a..7eaa322 100644 --- a/src/client.rs +++ b/src/client.rs @@ -19,7 +19,7 @@ use indicatif::{MultiProgress, ProgressBar, ProgressState, ProgressStyle}; #[cfg(test)] use mockall::*; use nostr::Event; -use nostr_sdk::ClientSigner; +use nostr_sdk::NostrSigner; #[allow(clippy::struct_field_names)] pub struct Client { @@ -101,7 +101,7 @@ impl Connect for Client { async fn set_keys(&mut self, keys: &nostr::Keys) { self.client - .set_signer(Some(ClientSigner::Keys(keys.clone()))) + .set_signer(Some(NostrSigner::Keys(keys.clone()))) .await; } @@ -125,7 +125,7 @@ impl Connect for Client { async fn send_event_to(&self, url: &str, event: Event) -> Result { self.client.add_relay(url).await?; self.client.connect_relay(url).await?; - Ok(self.client.send_event_to(url, event).await?) + Ok(self.client.send_event_to(vec![url], event).await?) } async fn get_events( -- cgit v1.2.3 From f7d520e9ccb6084144a3e963516e40a322add0c8 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:31 +0000 Subject: use Sha1Hashin new location it had moved from 'prelude' to 'hashes' --- src/git.rs | 2 +- src/sub_commands/push.rs | 2 +- src/sub_commands/send.rs | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/git.rs b/src/git.rs index 86b59fb..77c1dcb 100644 --- a/src/git.rs +++ b/src/git.rs @@ -4,7 +4,7 @@ use std::{env::current_dir, path::Path}; use anyhow::{bail, Context, Result}; use git2::{DiffOptions, Oid, Revwalk}; -use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; +use nostr_sdk::hashes::{sha1::Hash as Sha1Hash, Hash}; use crate::sub_commands::list::{get_commit_id_from_patch, tag_value}; diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 651b250..bb50ee2 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use nostr::prelude::sha1::Hash as Sha1Hash; +use nostr_sdk::hashes::sha1::Hash as Sha1Hash; #[cfg(not(test))] use crate::client::Client; diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 35c2c81..cc182f1 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,10 +4,8 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{ - nips::nip19::Nip19, prelude::sha1::Hash as Sha1Hash, EventBuilder, FromBech32, Marker, Tag, - TagKind, UncheckedUrl, -}; +use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; #[cfg(not(test))] -- 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(-) 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 9a450f2ce740da08843a541d230c43194b934f5f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:36 +0000 Subject: replace XOnlyPublicKey with wrapper PublicKey to reflect new name in rust-nostr --- src/config.rs | 6 +++--- src/key_handling/users.rs | 12 ++++++------ src/repo_ref.rs | 14 +++++++------- src/sub_commands/init.rs | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2370e34..7fca446 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,7 @@ use anyhow::{anyhow, Context, Result}; use directories::ProjectDirs; #[cfg(test)] use mockall::*; -use nostr::{secp256k1::XOnlyPublicKey, ToBech32}; +use nostr::{PublicKey, ToBech32}; use serde::{self, Deserialize, Serialize}; #[derive(Default)] @@ -69,7 +69,7 @@ pub struct MyConfig { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct UserRef { - pub public_key: XOnlyPublicKey, + pub public_key: PublicKey, pub encrypted_key: String, pub metadata: UserMetadata, pub relays: UserRelays, @@ -77,7 +77,7 @@ pub struct UserRef { } impl UserRef { - pub fn new(public_key: XOnlyPublicKey, encrypted_key: String) -> Self { + pub fn new(public_key: PublicKey, encrypted_key: String) -> Self { Self { public_key, encrypted_key, diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index c061cd3..751c577 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -32,13 +32,13 @@ pub trait UserManagement { &self, #[cfg(test)] client: &MockConnect, #[cfg(not(test))] client: &Client, - public_key: &XOnlyPublicKey, + public_key: &PublicKey, after: u64, ) -> Result; - fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result; + fn get_user_from_cache(&self, public_key: &PublicKey) -> Result; fn add_user_to_config( &self, - public_key: XOnlyPublicKey, + public_key: PublicKey, encrypted_secret_key: Option, overwrite: bool, ) -> Result<()>; @@ -99,7 +99,7 @@ impl UserManagement for UserManager { fn add_user_to_config( &self, - public_key: XOnlyPublicKey, + public_key: PublicKey, encrypted_secret_key: Option, overwrite: bool, ) -> Result<()> { @@ -129,7 +129,7 @@ impl UserManagement for UserManager { .context("failed to save application configuration with new user details in") } - fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result { + fn get_user_from_cache(&self, public_key: &PublicKey) -> Result { let cfg = self .config_manager .load() @@ -148,7 +148,7 @@ impl UserManagement for UserManager { &self, #[cfg(test)] client: &MockConnect, #[cfg(not(test))] client: &Client, - public_key: &XOnlyPublicKey, + public_key: &PublicKey, use_cache_unless_checked_more_than_x_secs_ago: u64, ) -> Result { let cfg = self diff --git a/src/repo_ref.rs b/src/repo_ref.rs index c7b42fa..0a14005 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs @@ -1,7 +1,7 @@ use std::{fs::File, io::BufReader, str::FromStr}; use anyhow::{bail, Context, Result}; -use nostr::{nips::nip19::Nip19, secp256k1::XOnlyPublicKey, FromBech32, Tag, ToBech32}; +use nostr::{nips::nip19::Nip19, FromBech32, PublicKey, Tag, ToBech32}; use serde::{Deserialize, Serialize}; #[cfg(not(test))] @@ -23,7 +23,7 @@ pub struct RepoRef { pub git_server: String, pub web: Vec, pub relays: Vec, - pub maintainers: Vec, + pub maintainers: Vec, // code languages and hashtags } @@ -78,7 +78,7 @@ impl TryFrom for RepoRef { } for pk in maintainers { r.maintainers.push( - nostr_sdk::prelude::XOnlyPublicKey::from_str(&pk) + nostr_sdk::prelude::PublicKey::from_str(&pk) .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) .context("invalid repository event")?, ); @@ -246,11 +246,11 @@ pub fn get_repo_config_from_yaml(git_repo: &Repo) -> Result { Ok(repo_config_yaml) } -pub fn extract_pks(pk_strings: Vec) -> Result> { - let mut pks: Vec = vec![]; +pub fn extract_pks(pk_strings: Vec) -> Result> { + let mut pks: Vec = vec![]; for s in pk_strings { pks.push( - nostr_sdk::prelude::XOnlyPublicKey::from_bech32(s.clone()) + nostr_sdk::prelude::PublicKey::from_bech32(s.clone()) .context(format!("cannot convert {s} into a valid nostr public key"))?, ); } @@ -259,7 +259,7 @@ pub fn extract_pks(pk_strings: Vec) -> Result> { pub fn save_repo_config_to_yaml( git_repo: &Repo, - maintainers: Vec, + maintainers: Vec, relays: Vec, ) -> Result<()> { let path = git_repo.get_path()?.join("maintainers.yaml"); diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 4f098c0..56129a6 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use nostr::{secp256k1::XOnlyPublicKey, FromBech32, ToBech32}; +use nostr::{FromBech32, PublicKey, ToBech32}; use super::send::send_events; #[cfg(not(test))] @@ -163,7 +163,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { args.web.clone() }; - let maintainers: Vec = { + let maintainers: Vec = { let mut dont_ask = !args.other_maintainers.is_empty(); let mut maintainers_string = if !args.other_maintainers.is_empty() { [args.other_maintainers.clone()].concat().join(" ") @@ -185,7 +185,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { }; // add current user if not present if maintainers.iter().any(|m| { - if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { + if let Ok(m_pubkey) = PublicKey::from_bech32(m) { user_ref.public_key.eq(&m_pubkey) } else { false @@ -210,9 +210,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { .map(std::string::ToString::to_string) .collect(); } - let mut maintainers: Vec = vec![]; + let mut maintainers: Vec = vec![]; for m in maintainers_string.split(' ') { - if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { + if let Ok(m_pubkey) = PublicKey::from_bech32(m) { maintainers.push(m_pubkey); } else { println!("not a valid set of npubs seperated by a space"); -- cgit v1.2.3 From 49bc478fffc63a3cad0be194c6c45a868e432691 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:40 +0000 Subject: update tag generation to reflect changes in rust-nostr --- src/key_handling/users.rs | 6 +++++- src/repo_ref.rs | 5 +++-- src/sub_commands/list.rs | 12 +++++++++--- src/sub_commands/send.rs | 31 ++++++++++++++++++++----------- tests/list.rs | 12 +++++++++--- tests/pull.rs | 10 ++++++++-- 6 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index 751c577..1dd75a8 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -249,7 +249,11 @@ impl UserManagement for UserManager { relays: new_relays_event .tags .iter() - .filter(|t| t.kind().eq(&nostr::TagKind::R)) + .filter(|t| { + t.kind().eq(&nostr::TagKind::SingleLetter( + SingleLetterTag::lowercase(Alphabet::R), + )) + }) .map(|t| UserRelayRef { url: t.as_vec()[1].clone(), read: t.as_vec().len() == 2 || t.as_vec()[2].eq("read"), diff --git a/src/repo_ref.rs b/src/repo_ref.rs index 0a14005..2dab79c 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs @@ -200,8 +200,9 @@ pub async fn fetch( nostr::Filter::default().kind(nostr::Kind::Custom(REPO_REF_KIND)); match nip19 { Nip19::Coordinate(c) => { - repo_event_filter = - repo_event_filter.identifier(c.identifier).author(c.pubkey); + repo_event_filter = repo_event_filter + .identifier(c.identifier) + .author(c.public_key); for r in c.relays { relays.push(r); } diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index 2d81164..1a30b9b 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -730,9 +730,12 @@ pub async fn find_proposal_events( vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) .custom_tag( - nostr::Alphabet::A, + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::A), repo_ref .maintainers .iter() @@ -742,7 +745,10 @@ pub async fn find_proposal_events( // events nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) .reference(root_commit), ], ) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index cc182f1..91654d2 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,7 +4,10 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr::{ + nips::{nip01::Coordinate, nip19::Nip19}, + EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl, +}; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; @@ -539,11 +542,14 @@ pub fn generate_cover_letter_and_patch_events( vec![ // TODO: why not tag all maintainer identifiers? Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::from).clone(), }, Tag::Reference(format!("{root_commit}")), @@ -795,11 +801,14 @@ pub fn generate_patch_event( [ vec![ Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: relay_hint.clone(), }, Tag::Reference(format!("{root_commit}")), diff --git a/tests/list.rs b/tests/list.rs index 4f55645..ee5e1dc 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -190,7 +190,7 @@ mod cannot_find_repo_event { input.succeeds_with( &Coordinate { kind: nostr::Kind::Custom(REPOSITORY_KIND), - pubkey: TEST_KEY_1_KEYS.public_key(), + public_key: TEST_KEY_1_KEYS.public_key(), identifier: repo_event.identifier().unwrap().to_string(), relays: vec!["ws://localhost:8056".to_string()], } @@ -1621,7 +1621,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -1748,7 +1751,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; diff --git a/tests/pull.rs b/tests/pull.rs index 50dddbf..853f518 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -746,7 +746,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -843,7 +846,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; -- 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(-) 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 761484b6db6100a8b7f81e09f8903232f9f3ffaf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 16:02:35 +0000 Subject: refactor: more concise error message to suppress the clippy too_many_lines in function warning --- src/sub_commands/send.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 91654d2..d9caf9b 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -545,8 +545,7 @@ pub fn generate_cover_letter_and_patch_events( coordinate: Coordinate { kind: nostr::Kind::Custom(REPO_REF_KIND), public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, + .context("repo reference should always have at least one maintainer")?, identifier: repo_ref.identifier.to_string(), relays: repo_ref.relays.clone(), }, -- cgit v1.2.3 From 04a8bce2c58dfb697410ae9bb83ab6abbf95406a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 25 Mar 2024 09:47:04 +0000 Subject: fix: relay connection timeout panic upgrade from rust-nostr v0.27 ~> v0.28 introduces this panic presumably get_events attempted to write to the MultiProgress just after it has been removed --- src/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index 7eaa322..e271a9f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -144,7 +144,7 @@ impl Connect for Client { let m = MultiProgress::new(); let pb_style = ProgressStyle::with_template(" {spinner} {prefix} {msg} {timeout_in}")? .with_key("timeout_in", |state: &ProgressState, w: &mut dyn Write| { - if state.elapsed().as_secs() > 3 { + if state.elapsed().as_secs() > 3 && state.elapsed().as_secs() < GET_EVENTS_TIMEOUT { write!( w, "timeout in {:.1}s", -- 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(-) 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(-) 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 From 1fb20de563babeafbe55d3608f1211787aba6497 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 27 Mar 2024 17:22:49 +0000 Subject: bump nostr-relay-pool to v0.29.2 yukibtc released a patch to address intermittent problem fetching events, which caused our integration tests to fail --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29bf716..a3f3cc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,7 +1324,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -1809,9 +1809,9 @@ dependencies = [ [[package]] name = "nostr-relay-pool" -version = "0.29.1" +version = "0.29.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c3431820082c850315218193c7e33a328b4b2cd0129d4fd5446a4dab87ddc4" +checksum = "a1b306bc99d49064950a16a06d35c7c19af94d8b4052fad0dfe02e41e529d5d3" dependencies = [ "async-utility", "async-wsocket", -- cgit v1.2.3 From bc1e9e7ff8d2c3747a7dbc3b649930ac5bc6425d Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 28 Mar 2024 08:26:19 +0000 Subject: test: fix intermittent test failures caused by test proposals with the same timestamp listed in an inconsistant list order; by ensuring test proposals have a different timestamps --- tests/list.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/list.rs b/tests/list.rs index 8252448..61c2201 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -23,6 +23,7 @@ fn cli_tester_create_proposals() -> Result { Some((PROPOSAL_TITLE_1, "proposal a description")), None, )?; + std::thread::sleep(std::time::Duration::from_millis(1000)); cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_2, @@ -30,6 +31,7 @@ fn cli_tester_create_proposals() -> Result { Some((PROPOSAL_TITLE_2, "proposal b description")), None, )?; + std::thread::sleep(std::time::Duration::from_millis(1000)); cli_tester_create_proposal( &git_repo, FEATURE_BRANCH_NAME_3, @@ -72,7 +74,7 @@ fn cli_tester_create_proposal( in_reply_to: Option, ) -> Result<()> { create_and_populate_branch(test_repo, branch_name, prefix, false)?; - + std::thread::sleep(std::time::Duration::from_millis(1000)); if let Some(in_reply_to) = in_reply_to { let mut p = CliTester::new_from_dir( &test_repo.dir, @@ -489,7 +491,7 @@ mod when_main_branch_is_uptodate { "checked out proposal as '{FEATURE_BRANCH_NAME_3}' branch\r\n" ))?; p.expect_end()?; - + println!("blablagothere"); for p in [51, 52, 53, 55, 56] { relay::shutdown_relay(8000 + p)?; } @@ -726,6 +728,7 @@ mod when_main_branch_is_uptodate { let cli_tester_handle = std::thread::spawn(move || -> Result<()> { let originating_repo = cli_tester_create_proposals()?; + std::thread::sleep(std::time::Duration::from_millis(1000)); cli_tester_create_proposal( &originating_repo, FEATURE_BRANCH_NAME_4, -- cgit v1.2.3 From 4171733090d25732029a149cf0976c6b1103d0ea Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 28 Mar 2024 08:30:57 +0000 Subject: refactor: allow pedantic clippy warning large_futures rust-nostr author suggested this might be a false positive https://github.com/rust-nostr/nostr/pull/375#issuecomment-2022245832 --- src/client.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client.rs b/src/client.rs index e271a9f..2dbd238 100644 --- a/src/client.rs +++ b/src/client.rs @@ -124,6 +124,7 @@ impl Connect for Client { async fn send_event_to(&self, url: &str, event: Event) -> Result { self.client.add_relay(url).await?; + #[allow(clippy::large_futures)] self.client.connect_relay(url).await?; Ok(self.client.send_event_to(vec![url], event).await?) } @@ -200,6 +201,7 @@ impl Connect for Client { } else { None }; + #[allow(clippy::large_futures)] match get_events_of(relay, filters, &pb).await { Err(error) => { if let Some(pb) = pb { @@ -246,6 +248,7 @@ async fn get_events_of( pb: &Option, ) -> Result> { if !relay.is_connected().await { + #[allow(clippy::large_futures)] relay.connect(None).await; } -- cgit v1.2.3 From 11dc9fa2d8b82594d3803f12d2c5a49e57026cfb Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 28 Mar 2024 12:13:40 +0000 Subject: build: use nix for tests ci using the same dependancies in ci as in development --- .github/workflows/build_test.yaml | 30 ----------------------------- .github/workflows/check_rustfmt_clippy.yaml | 26 ------------------------- .github/workflows/clippy_rustfmt_test.yaml | 16 +++++++++++++++ 3 files changed, 16 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/build_test.yaml delete mode 100644 .github/workflows/check_rustfmt_clippy.yaml create mode 100644 .github/workflows/clippy_rustfmt_test.yaml diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml deleted file mode 100644 index 5d2555d..0000000 --- a/.github/workflows/build_test.yaml +++ /dev/null @@ -1,30 +0,0 @@ -on: push - -name: build test - -jobs: - ci: - runs-on: ubuntu-latest - timeout-minutes: 8 - strategy: - matrix: - rust: - - stable - - nightly - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - - uses: actions-rs/cargo@v1 - with: - command: build - - - uses: actions-rs/cargo@v1 - with: - command: test diff --git a/.github/workflows/check_rustfmt_clippy.yaml b/.github/workflows/check_rustfmt_clippy.yaml deleted file mode 100644 index eec744e..0000000 --- a/.github/workflows/check_rustfmt_clippy.yaml +++ /dev/null @@ -1,26 +0,0 @@ -on: push - -name: check rustfmt - -jobs: - ci: - runs-on: ubuntu-latest - strategy: - matrix: - rust: - - nightly - - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - components: rustfmt - - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check diff --git a/.github/workflows/clippy_rustfmt_test.yaml b/.github/workflows/clippy_rustfmt_test.yaml new file mode 100644 index 0000000..5253814 --- /dev/null +++ b/.github/workflows/clippy_rustfmt_test.yaml @@ -0,0 +1,16 @@ +on: push + +name: build test + +jobs: + ci: + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + nix_path: nixpkgs=channel:nixos-unstable + - run: nix develop --command cargo clippy + - run: nix develop --command cargo fmt --all -- --check + - run: nix develop --command cargo test -- cgit v1.2.3