TEST_F(StreamInfoImplTest, TimingTest) {
  MonotonicTime pre_start = test_time_.timeSystem().monotonicTime();
  StreamInfoImpl info(Http::Protocol::Http2, test_time_.timeSystem(), nullptr);
  info.setUpstreamInfo(std::make_shared<UpstreamInfoImpl>());
  UpstreamTiming& upstream_timing = info.upstreamInfo()->upstreamTiming();
  MonotonicTime post_start = test_time_.timeSystem().monotonicTime();

  const MonotonicTime& start = info.startTimeMonotonic();

  EXPECT_LE(pre_start, start) << "Start time was lower than expected";
  EXPECT_GE(post_start, start) << "Start time was higher than expected";

  TimingUtility timing(info);
  EXPECT_FALSE(timing.lastDownstreamRxByteReceived());
  info.downstreamTiming().onLastDownstreamRxByteReceived(test_time_.timeSystem());
  std::chrono::nanoseconds dur =
      checkDuration(std::chrono::nanoseconds{0}, timing.lastDownstreamRxByteReceived());

  EXPECT_FALSE(timing.firstUpstreamTxByteSent());
  upstream_timing.onFirstUpstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstUpstreamTxByteSent());

  EXPECT_FALSE(timing.lastUpstreamTxByteSent());
  upstream_timing.onLastUpstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastUpstreamTxByteSent());

  EXPECT_FALSE(timing.firstUpstreamRxByteReceived());
  upstream_timing.onFirstUpstreamRxByteReceived(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstUpstreamRxByteReceived());

  EXPECT_FALSE(timing.lastUpstreamRxByteReceived());
  upstream_timing.onLastUpstreamRxByteReceived(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastUpstreamRxByteReceived());

  EXPECT_FALSE(timing.firstDownstreamTxByteSent());
  info.downstreamTiming().onFirstDownstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstDownstreamTxByteSent());

  EXPECT_FALSE(timing.lastDownstreamTxByteSent());
  info.downstreamTiming().onLastDownstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastDownstreamTxByteSent());

  EXPECT_FALSE(info.requestComplete());
  info.onRequestComplete();
  dur = checkDuration(dur, info.requestComplete());
}
TEST_F(StreamInfoImplTest, TimingTest) {
  MonotonicTime pre_start = test_time_.timeSystem().monotonicTime();
  StreamInfoImpl info(Http::Protocol::Http2, test_time_.timeSystem(), nullptr);
  info.setUpstreamInfo(std::make_shared<UpstreamInfoImpl>());
  UpstreamTiming& upstream_timing = info.upstreamInfo()->upstreamTiming();
  MonotonicTime post_start = test_time_.timeSystem().monotonicTime();

  const MonotonicTime& start = info.startTimeMonotonic();

  EXPECT_LE(pre_start, start) << "Start time was lower than expected";
  EXPECT_GE(post_start, start) << "Start time was higher than expected";

  TimingUtility timing(info);
  EXPECT_FALSE(timing.lastDownstreamRxByteReceived());
  info.downstreamTiming().onLastDownstreamRxByteReceived(test_time_.timeSystem());
  std::chrono::nanoseconds dur =
      checkDuration(std::chrono::nanoseconds{0}, timing.lastDownstreamRxByteReceived());

  EXPECT_FALSE(timing.firstUpstreamTxByteSent());
  upstream_timing.onFirstUpstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstUpstreamTxByteSent());

  EXPECT_FALSE(timing.lastUpstreamTxByteSent());
  upstream_timing.onLastUpstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastUpstreamTxByteSent());

  EXPECT_FALSE(timing.firstUpstreamRxByteReceived());
  upstream_timing.onFirstUpstreamRxByteReceived(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstUpstreamRxByteReceived());

  EXPECT_FALSE(timing.lastUpstreamRxByteReceived());
  upstream_timing.onLastUpstreamRxByteReceived(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastUpstreamRxByteReceived());

  EXPECT_FALSE(timing.firstDownstreamTxByteSent());
  info.downstreamTiming().onFirstDownstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.firstDownstreamTxByteSent());

  EXPECT_FALSE(timing.lastDownstreamTxByteSent());
  info.downstreamTiming().onLastDownstreamTxByteSent(test_time_.timeSystem());
  dur = checkDuration(dur, timing.lastDownstreamTxByteSent());

  EXPECT_FALSE(info.requestComplete());
  info.onRequestComplete();
  dur = checkDuration(dur, info.requestComplete());
}