fix(client): avoid lossy timing casts
This commit is contained in:
1 parent
a41a1e319d
commit
c3f2a524a3
5 files changed
+64
-21
No files matched your search
@@ -343,8 +343,8 @@ mod tests {
|
||||
fn test_params(duration: Option<Duration>, interval: Duration) -> Params {
|
||||
Params {
|
||||
protocol_version: PROTOCOL_VERSION,
|
||||
duration_ns: duration.map_or(0, |d| d.as_nanos() as i64),
|
||||
interval_ns: interval.as_nanos() as i64,
|
||||
duration_ns: duration.map_or(0, test_duration_ns_i64),
|
||||
interval_ns: test_duration_ns_i64(interval),
|
||||
length: 0,
|
||||
received_stats: ReceivedStats::Both,
|
||||
stamp_at: StampAt::Both,
|
||||
@@ -354,6 +354,10 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_duration_ns_i64(duration: Duration) -> i64 {
|
||||
i64::try_from(duration.as_nanos()).expect("test duration fits i64 nanoseconds")
|
||||
}
|
||||
|
||||
fn config(addr: SocketAddr, duration: Option<Duration>) -> ClientConfig {
|
||||
ClientConfig {
|
||||
server_addr: addr.to_string(),
|
||||
|
||||
Reference in new issue
Block a user