mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2025-03-17 13:22:54 +01:00
refactor: rustfmt
This commit is contained in:
parent
b4234eae25
commit
d72af96d5f
@ -472,12 +472,8 @@ mod tests {
|
||||
let mut event = Event::simple_event();
|
||||
event.tags = vec![vec!["e".to_owned(), "foo".to_owned()]];
|
||||
event.build_index();
|
||||
assert!(
|
||||
event.generic_tag_val_intersect(
|
||||
'e',
|
||||
&HashSet::from(["foo".to_owned(), "bar".to_owned()])
|
||||
)
|
||||
);
|
||||
assert!(event
|
||||
.generic_tag_val_intersect('e', &HashSet::from(["foo".to_owned(), "bar".to_owned()])));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -25,7 +25,9 @@ impl EventResultStatus {
|
||||
pub fn to_bool(&self) -> bool {
|
||||
match self {
|
||||
Self::Duplicate | Self::Saved => true,
|
||||
Self::Invalid | Self::Blocked | Self::RateLimited | Self::Error | Self::Restricted => false,
|
||||
Self::Invalid | Self::Blocked | Self::RateLimited | Self::Error | Self::Restricted => {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ async fn handle_web_request(
|
||||
.header("Content-Type", "text/html; charset=UTF-8")
|
||||
.body(Body::from(file_content))
|
||||
.expect("request builder"));
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Failed to read relay_page file: {}. Will use default", err);
|
||||
}
|
||||
@ -920,7 +920,7 @@ pub fn start_server(settings: &Settings, shutdown_rx: MpscReceiver<()>) -> Resul
|
||||
info!("starting payment process ...");
|
||||
p.run().await;
|
||||
});
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to start payment process {e}");
|
||||
std::process::exit(1);
|
||||
|
@ -45,8 +45,8 @@ pub struct ReqFilter {
|
||||
|
||||
impl Serialize for ReqFilter {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut map = serializer.serialize_map(None)?;
|
||||
if let Some(ids) = &self.ids {
|
||||
@ -80,8 +80,8 @@ impl Serialize for ReqFilter {
|
||||
|
||||
impl<'de> Deserialize<'de> for ReqFilter {
|
||||
fn deserialize<D>(deserializer: D) -> Result<ReqFilter, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let received: Value = Deserialize::deserialize(deserializer)?;
|
||||
let filter = received.as_object().ok_or_else(|| {
|
||||
@ -184,8 +184,8 @@ impl<'de> Deserialize<'de> for Subscription {
|
||||
/// Custom deserializer for subscriptions, which have a more
|
||||
/// complex structure than the other message types.
|
||||
fn deserialize<D>(deserializer: D) -> Result<Subscription, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let mut v: Value = Deserialize::deserialize(deserializer)?;
|
||||
// this should be a 3-or-more element array.
|
||||
@ -673,11 +673,26 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn is_scraper() -> Result<()> {
|
||||
assert!(serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984],"since": 123,"limit":1}]"#)?.is_scraper());
|
||||
assert!(serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984]},{"kinds": [1984],"authors":["aaaa"]}]"#)?.is_scraper());
|
||||
assert!(!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984],"authors":["aaaa"]}]"#)?.is_scraper());
|
||||
assert!(!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"ids": ["aaaa"]}]"#)?.is_scraper());
|
||||
assert!(!serde_json::from_str::<Subscription>(r##"["REQ","some-id",{"#p": ["aaaa"],"kinds":[1,4]}]"##)?.is_scraper());
|
||||
assert!(serde_json::from_str::<Subscription>(
|
||||
r#"["REQ","some-id",{"kinds": [1984],"since": 123,"limit":1}]"#
|
||||
)?
|
||||
.is_scraper());
|
||||
assert!(serde_json::from_str::<Subscription>(
|
||||
r#"["REQ","some-id",{"kinds": [1984]},{"kinds": [1984],"authors":["aaaa"]}]"#
|
||||
)?
|
||||
.is_scraper());
|
||||
assert!(!serde_json::from_str::<Subscription>(
|
||||
r#"["REQ","some-id",{"kinds": [1984],"authors":["aaaa"]}]"#
|
||||
)?
|
||||
.is_scraper());
|
||||
assert!(
|
||||
!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"ids": ["aaaa"]}]"#)?
|
||||
.is_scraper()
|
||||
);
|
||||
assert!(!serde_json::from_str::<Subscription>(
|
||||
r##"["REQ","some-id",{"#p": ["aaaa"],"kinds":[1,4]}]"##
|
||||
)?
|
||||
.is_scraper());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user