upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.toml2
-rw-r--r--src/client.rs35
-rw-r--r--test_utils/config.toml2
-rw-r--r--test_utils/src/lib.rs2
4 files changed, 35 insertions, 6 deletions
diff --git a/config.toml b/config.toml
new file mode 100644
index 0000000..519f44f
--- /dev/null
+++ b/config.toml
@@ -0,0 +1,2 @@
1[env]
2NGITTEST = true \ No newline at end of file
diff --git a/src/client.rs b/src/client.rs
index 860562c..7418519 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -43,16 +43,39 @@ pub trait Connect {
43#[async_trait] 43#[async_trait]
44impl Connect for Client { 44impl Connect for Client {
45 fn default() -> Self { 45 fn default() -> Self {
46 Client { 46 let fallback_relays: Vec<String> = if std::env::var("NGITTEST").is_ok() {
47 client: nostr_sdk::Client::new(&nostr::Keys::generate()), 47 vec![
48 fallback_relays: vec![
49 "ws://localhost:8051".to_string(), 48 "ws://localhost:8051".to_string(),
50 "ws://localhost:8052".to_string(), 49 "ws://localhost:8052".to_string(),
51 ], 50 ]
52 more_fallback_relays: vec![ 51 } else {
52 vec![
53 "wss://relayable.org".to_string(),
54 "wss://relay.f7z.io".to_string(),
55 "wss://relay.damus.io".to_string(),
56 "wss://relay.snort.social".to_string(),
57 // "ws://localhost:8080".to_string()
58 ]
59 };
60
61 let more_fallback_relays: Vec<String> = if std::env::var("NGITTEST").is_ok() {
62 vec![
53 "ws://localhost:8055".to_string(), 63 "ws://localhost:8055".to_string(),
54 "ws://localhost:8056".to_string(), 64 "ws://localhost:8056".to_string(),
55 ], 65 ]
66 } else {
67 vec![
68 "wss://nostr.wine/".to_string(),
69 "wss://eden.nostr.land/".to_string(),
70 "wss://relay.nostr.band/".to_string(),
71 // "ws://localhost:8080".to_string()
72 ]
73 };
74
75 Client {
76 client: nostr_sdk::Client::new(&nostr::Keys::generate()),
77 fallback_relays,
78 more_fallback_relays,
56 } 79 }
57 } 80 }
58 fn new(opts: Params) -> Self { 81 fn new(opts: Params) -> Self {
diff --git a/test_utils/config.toml b/test_utils/config.toml
new file mode 100644
index 0000000..519f44f
--- /dev/null
+++ b/test_utils/config.toml
@@ -0,0 +1,2 @@
1[env]
2NGITTEST = true \ No newline at end of file
diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs
index d119bd7..f509039 100644
--- a/test_utils/src/lib.rs
+++ b/test_utils/src/lib.rs
@@ -735,6 +735,7 @@ where
735 S: AsRef<std::ffi::OsStr>, 735 S: AsRef<std::ffi::OsStr>,
736{ 736{
737 let mut cmd = std::process::Command::new(assert_cmd::cargo::cargo_bin("ngit")); 737 let mut cmd = std::process::Command::new(assert_cmd::cargo::cargo_bin("ngit"));
738 cmd.env("NGITTEST", "TRUE");
738 cmd.args(args); 739 cmd.args(args);
739 // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes 740 // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes
740 rexpect::session::spawn_with_options( 741 rexpect::session::spawn_with_options(
@@ -756,6 +757,7 @@ where
756 S: AsRef<std::ffi::OsStr>, 757 S: AsRef<std::ffi::OsStr>,
757{ 758{
758 let mut cmd = std::process::Command::new(assert_cmd::cargo::cargo_bin("ngit")); 759 let mut cmd = std::process::Command::new(assert_cmd::cargo::cargo_bin("ngit"));
760 cmd.env("NGITTEST", "TRUE");
759 cmd.current_dir(dir); 761 cmd.current_dir(dir);
760 cmd.args(args); 762 cmd.args(args);
761 // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes 763 // using branch for PR https://github.com/rust-cli/rexpect/pull/103 to strip ansi escape codes