CodeSampleX

샘플

tokio 1.53.1: Make tokio timer code deterministic and instant in tests with a paused clock, driving sleep, timeout, interval and select! on virtual time from a hand-built runtime rather than #[tokio::test]

검증된 샘플 — cargo tokio 1.53.1: Make tokio timer code deterministic and instant in tests with a paused clock, driving sleep, timeout, interval and select! on…

sha256:bcc9f63d5a6beb65a8a582a8dcb9de5d559b3aa848d5a70a231e9c0e7d6ee136

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 rust 1 linux x64 rust 1 rust cargo

검증 실행 환경

환경 컨트랙트 단계 실행일
rust 1 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-14
rust 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · cargo@1
2026-08-18

케이스

HOW
목표
Make tokio timer code deterministic and instant in tests with a paused clock, driving sleep, timeout, interval and select! on virtual time from a hand-built runtime rather than #[tokio::test]
패키지
심벌
  • tokio::runtime::Builder::start_paused
  • tokio::runtime::Builder::enable_time
  • tokio::time::sleep
  • tokio::time::timeout
  • tokio::time::interval
  • tokio::time::advance
  • tokio::time::Instant
  • tokio::select
환경
rust 1
생성일
2026-08-14T12:58:22Z

컨트랙트

  1. assert a one hour sleep under a paused clock advances tokio::time::Instant by exactly one hour
  2. assert that hour of virtual time costs under 250 milliseconds of real time
  3. assert timeout on a future that never completes returns Err(Elapsed) whose Display is "deadline has elapsed"
  4. assert the clock stops exactly on the timeout deadline rather than somewhere past it
  5. assert a fresh Interval already has one tick due before anything awaits it
  6. assert taking that first tick costs zero virtual time
  7. assert advance() past five periods makes five ticks due at once under the default MissedTickBehavior::Burst
  8. assert the clock sits exactly 300 virtual seconds on from the interval's creation after that advance
  9. assert four ticks of a 60 second interval take 180 seconds of virtual time, not 240
  10. assert select! with a timeout branch picks the timeout when the other branch can never resolve
  11. assert the clock lands exactly on that select! timeout deadline
  12. assert two select! branches one millisecond apart resolve to the shorter one 100 times in a row
  13. assert those 100 races cost exactly one second of virtual time in total
  14. assert the whole run adds up to exactly 4116 seconds of virtual time
  15. assert 4116 seconds of virtual time pass in under a second of real time
  16. assert start_paused without enable_time still builds, then panics on the first sleep with the message naming enable_time
  17. assert a Sleep constructed outside the runtime instead panics that no reactor is running, even when that runtime has its time driver enabled
  18. assert start_paused on a multi_thread runtime panics inside build() with the message naming the current_thread runtime, instead of returning Err

파일

  • Cargo.lock
  • Cargo.toml
  • csx.json
  • src/main.rs

소스 아티팩트 내려받기 (tar.gz)

오리진 시더

anonymous