Skip to content

Commit

Permalink
Fix sub-millisecond time always being 0. (#161)
Browse files Browse the repository at this point in the history
Issue #158.
  • Loading branch information
r12f authored Mar 13, 2022
1 parent 9ba561a commit 90d9c37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ping_runners/ping_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl PingResult {
source_port: self.source().port(),
is_warmup: self.is_warmup(),
is_succeeded: self.is_succeeded(),
rtt_in_ms: self.round_trip_time().as_millis() as f64,
rtt_in_ms: self.round_trip_time().as_micros() as f64 / 1000.0,
is_timed_out: self.is_timed_out(),
preparation_error,
ping_error,
Expand Down
14 changes: 7 additions & 7 deletions tests/ping_runner_core_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ fn ping_with_rnp_core_should_work() {
let results = actual_ping_results.lock().unwrap();
assert_eq!(
vec![
MockPingClientResult::Success(Duration::from_millis(10)),
MockPingClientResult::Success(Duration::from_micros(12345)),
MockPingClientResult::Timeout,
MockPingClientResult::PreparationFailed,
MockPingClientResult::Success(Duration::from_millis(10)),
MockPingClientResult::Success(Duration::from_micros(12345)),
MockPingClientResult::Timeout,
MockPingClientResult::PreparationFailed,
MockPingClientResult::PingFailed,
MockPingClientResult::AppHandshakeFailed(Duration::from_millis(20)),
MockPingClientResult::DisconnectFailed(Duration::from_millis(30)),
MockPingClientResult::AppHandshakeFailed(Duration::from_micros(23456)),
MockPingClientResult::DisconnectFailed(Duration::from_micros(34567)),
],
*results
);
Expand Down Expand Up @@ -153,12 +153,12 @@ fn create_mock_rnp_config(
Some(Box::new(MockPingClient::new(
config,
vec![
MockPingClientResult::Success(Duration::from_millis(10)),
MockPingClientResult::Success(Duration::from_micros(12345)),
MockPingClientResult::Timeout,
MockPingClientResult::PreparationFailed,
MockPingClientResult::PingFailed,
MockPingClientResult::AppHandshakeFailed(Duration::from_millis(20)),
MockPingClientResult::DisconnectFailed(Duration::from_millis(30)),
MockPingClientResult::AppHandshakeFailed(Duration::from_micros(23456)),
MockPingClientResult::DisconnectFailed(Duration::from_micros(34567)),
],
)))
}),
Expand Down

0 comments on commit 90d9c37

Please sign in to comment.