Extract the sample relay to test_data for reuse
Signed-off-by: kernelkind <kernelkind@gmail.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
9642b9243d
commit
c4d9b5cd3c
@@ -20,6 +20,7 @@ mod profile;
|
|||||||
pub mod relay_pool_manager;
|
pub mod relay_pool_manager;
|
||||||
pub mod relay_view;
|
pub mod relay_view;
|
||||||
mod result;
|
mod result;
|
||||||
|
mod test_data;
|
||||||
mod time;
|
mod time;
|
||||||
mod timecache;
|
mod timecache;
|
||||||
mod timeline;
|
mod timeline;
|
||||||
|
|||||||
@@ -172,27 +172,19 @@ fn get_connection_icon(status: &RelayStatus) -> egui::Image<'static> {
|
|||||||
|
|
||||||
// PREVIEWS
|
// PREVIEWS
|
||||||
|
|
||||||
|
mod preview {
|
||||||
|
use super::*;
|
||||||
|
use crate::test_data::sample_pool;
|
||||||
|
|
||||||
pub struct RelayViewPreview {
|
pub struct RelayViewPreview {
|
||||||
pool: RelayPool,
|
pool: RelayPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
|
||||||
impl RelayViewPreview {
|
impl RelayViewPreview {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
let mut pool = RelayPool::new();
|
RelayViewPreview {
|
||||||
let wakeup = move || {};
|
pool: sample_pool(),
|
||||||
|
|
||||||
pool.add_url("wss://relay.damus.io".to_string(), wakeup);
|
|
||||||
pool.add_url("wss://eden.nostr.land".to_string(), wakeup);
|
|
||||||
pool.add_url("wss://nostr.wine".to_string(), wakeup);
|
|
||||||
pool.add_url("wss://nos.lol".to_string(), wakeup);
|
|
||||||
pool.add_url("wss://test_relay_url_long_00000000000000000000000000000000000000000000000000000000000000000000000000000000000".to_string(), wakeup);
|
|
||||||
|
|
||||||
for _ in 0..20 {
|
|
||||||
pool.add_url("tmp".to_string(), wakeup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RelayViewPreview { pool }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,3 +202,4 @@ impl<'a> Preview for RelayView<'a> {
|
|||||||
RelayViewPreview::new()
|
RelayViewPreview::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
19
src/test_data.rs
Normal file
19
src/test_data.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use enostr::RelayPool;
|
||||||
|
|
||||||
|
#[allow(unused_must_use)]
|
||||||
|
pub fn sample_pool() -> RelayPool {
|
||||||
|
let mut pool = RelayPool::new();
|
||||||
|
let wakeup = move || {};
|
||||||
|
|
||||||
|
pool.add_url("wss://relay.damus.io".to_string(), wakeup);
|
||||||
|
pool.add_url("wss://eden.nostr.land".to_string(), wakeup);
|
||||||
|
pool.add_url("wss://nostr.wine".to_string(), wakeup);
|
||||||
|
pool.add_url("wss://nos.lol".to_string(), wakeup);
|
||||||
|
pool.add_url("wss://test_relay_url_long_00000000000000000000000000000000000000000000000000000000000000000000000000000000000".to_string(), wakeup);
|
||||||
|
|
||||||
|
for _ in 0..20 {
|
||||||
|
pool.add_url("tmp".to_string(), wakeup);
|
||||||
|
}
|
||||||
|
|
||||||
|
pool
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user