public void heartbeat(boolean successful, Instant lastHeartbeatAttempt) {
    if (successful) {
      heartbeatLastSuccess = lastHeartbeatAttempt;
      heartbeatSuccessesSinceLastFailure++;
      heartbeatFailuresSinceLastSuccess = 0;
    } else {
      heartbeatLastFailure = lastHeartbeatAttempt;
      heartbeatSuccessesSinceLastFailure = 0;
      heartbeatFailuresSinceLastSuccess++;
    }
  }
@Test
  void happy() {
    HeartbeatState state =
        new HeartbeatState(
            clock,
            clock.now(),
            new HeartbeatConfig(Duration.ofMinutes(1), 4, Duration.ofMinutes(4)));

    assertOk(state);

    clock.tick(Duration.ofSeconds(30));
    state.heartbeat(true, clock.now());

    assertOk(state);

    clock.tick(Duration.ofSeconds(60));
    state.heartbeat(false, clock.now());
    assertFailing(state, 1, 0.25);
  }