Skip to content

Commit 518b02a

Browse files
committed
fix: additional testing
1 parent 5e6f28b commit 518b02a

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

.idea/runConfigurations/Run_acme_dns_rust.xml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dns/mod.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use anyhow::Result;
2-
use std::future::Future;
32
use tokio::net::{ToSocketAddrs, UdpSocket};
43
use tracing::field::{debug, Empty};
5-
use tracing::{info_span, Instrument, Span};
4+
use tracing::{info_span, Span};
65
use trust_dns_server::authority::{AuthorityObject, Catalog};
76
use trust_dns_server::proto::rr::Name;
87
use trust_dns_server::ServerFuture;
@@ -32,17 +31,14 @@ impl<A: ToSocketAddrs> DNS<A> {
3231
DNS { server, addr, span }
3332
}
3433

35-
pub fn spawn(mut self) -> impl Future<Output = Result<()>> {
36-
let span = self.span.clone();
37-
async move {
38-
let udp = UdpSocket::bind(self.addr).await?;
39-
self.span.record("local.addr", &debug(udp.local_addr()));
40-
self.server.register_socket(udp);
34+
#[tracing::instrument(skip(self))]
35+
pub async fn spawn(mut self) -> Result<()> {
36+
let udp = UdpSocket::bind(self.addr).await?;
37+
self.span.record("local.addr", &debug(udp.local_addr()));
38+
self.server.register_socket(udp);
4139

42-
tokio::spawn(self.server.block_until_done()).await??;
40+
tokio::spawn(self.server.block_until_done()).await??;
4341

44-
Ok(())
45-
}
46-
.instrument(span)
42+
Ok(())
4743
}
4844
}

src/util.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) fn uuid() -> String {
3434

3535
#[cfg(test)]
3636
mod tests {
37-
use super::{error, now, to_i64, to_u64};
37+
use super::{error, now, to_i64, to_u64, uuid};
3838
use anyhow::anyhow;
3939
use std::io::{Error as IoError, ErrorKind};
4040
use std::thread;
@@ -56,6 +56,14 @@ mod tests {
5656
assert_eq!(expected, actual)
5757
}
5858

59+
#[test]
60+
fn uuid_test() {
61+
assert_ne!(uuid(), uuid());
62+
63+
let len = uuid().len();
64+
assert_eq!(32, len)
65+
}
66+
5967
#[test]
6068
fn now_works() {
6169
let actual = now();

0 commit comments

Comments
 (0)