upleb.uk

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

summaryrefslogtreecommitdiff
path: root/test_utils/src/relay.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-06-11 16:21:44 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-06-13 09:09:00 +0100
commitf1b3fcc40ab666d8def97096d1942c274da9b279 (patch)
tree05d6af0c5c1ad9baedb90ef652152fba6d46abf5 /test_utils/src/relay.rs
parent7c6a5ab4c5e7a81c7442061029b9230748a6639d (diff)
chore: bump rust-nostr to v0.32.0
both nostr and nostr-sdk packages and also in test_utils fix the many breaking changes fix: ignore trailing slash when depuplicate relays for send events. this was picked up as TagStandard::RelayMetadata has started adding a traling slash. refactor cli output test function `expect_send_with_progress` so that relays can succeed / fail in a random order
Diffstat (limited to 'test_utils/src/relay.rs')
-rw-r--r--test_utils/src/relay.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/test_utils/src/relay.rs b/test_utils/src/relay.rs
index e47ab5d..82a8f8d 100644
--- a/test_utils/src/relay.rs
+++ b/test_utils/src/relay.rs
@@ -255,21 +255,27 @@ pub fn expect_send_with_progress(
255 " - {} -------------------- 0/{event_count}", 255 " - {} -------------------- 0/{event_count}",
256 &relays[0].0 256 &relays[0].0
257 ))?; 257 ))?;
258 for relay in &relays { 258 let last_relay_outcome = outcome_message(relays.last().unwrap());
259 // if successful 259 let mut s = String::new();
260 if relay.1 { 260 loop {
261 p.expect_eventually(format!(" y {}", relay.0))?; 261 s.push_str(&p.expect_eventually(&last_relay_outcome)?);
262 } else { 262 s.push_str(&last_relay_outcome);
263 p.expect_eventually(format!(" x {} {}", relay.0, relay.2))?; 263 if relays.iter().all(|r| s.contains(&outcome_message(r))) {
264 // all responses have been received with correct outcome
265 break;
264 } 266 }
265 // could check that before only contains titles:
266 // - # y x n/n and whitespace
267 // let before = p.expect_eventually(format!(" â {title}"))?;
268 // assert_eq!("", before.trim());
269 } 267 }
270 Ok(()) 268 Ok(())
271} 269}
272 270
271fn outcome_message(relay: &(&str, bool, &str)) -> String {
272 if relay.1 {
273 format!(" y {}", relay.0)
274 } else {
275 format!(" x {} {}", relay.0, relay.2)
276 }
277}
278
273pub fn expect_send_with_progress_exact_interaction( 279pub fn expect_send_with_progress_exact_interaction(
274 p: &mut CliTester, 280 p: &mut CliTester,
275 titles: Vec<&str>, 281 titles: Vec<&str>,