Skip to content

test(runtime): assert guest-observed wasi:clocks time under a ManualClock override#282

Merged
mfw78 merged 1 commit into
developfrom
test/guest-clock-e2e
Jul 9, 2026
Merged

test(runtime): assert guest-observed wasi:clocks time under a ManualClock override#282
mfw78 merged 1 commit into
developfrom
test/guest-clock-e2e

Conversation

@mfw78

@mfw78 mfw78 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Add a small clock-reader guest fixture under modules/fixtures/ that on every event reads std::time::SystemTime::now() (which routes to wasi:clocks/wall-clock under wasm32-wasip2) and logs the wall time as whole seconds. Add a nexum-runtime harness test, harness_guest_observes_the_clock_override, that pins a ManualClock to a known instant, boots the fixture under that override, dispatches a block, and asserts the guest logged the pinned instant.

The fixture is registered in the workspace members, the just ci wasm build list, and the CI test job's wasm build list so the integration test always has its artefact.

Why

e2e_manual_clock_override_boots_and_dispatches only proves the WasiClockOverride threads through boot on the host side; nothing asserted that a guest reading wasi:clocks observes the overridden time. This closes that gap with an end-to-end assertion: the logged value equals the pinned instant and not the ambient host clock, so the override is proven to reach the guest.

This is authored as a top-of-train car so the new workspace member and fixture do not conflict-cascade against the in-flight epic stack.

Closes #281

Testing

  • Built the fixture: cargo build -p clock-reader --target wasm32-wasip2 --release. Confirmed the emitted component imports wasi:clocks/wall-clock@0.2.6 via wasm-tools component wit.
  • cargo test -p nexum-runtime --all-features harness_guest_observes_the_clock_override passes: the guest logs clock wall 1700000000, parsed back and asserted equal to the pinned seconds.
  • Falsified the assertion by removing the clock().set(...) call: the override then defaults to the epoch, the guest logs 0, and the test fails on the timeout, confirming the assertion is live and the guest is bound to the override rather than the ambient clock.
  • cargo clippy -p nexum-runtime --all-targets --features test-utils -- -D warnings and cargo clippy -p clock-reader --all-targets -- -D warnings are clean.
  • cargo fmt -p nexum-runtime -p clock-reader -- --check reports only a pre-existing, unrelated drift in builder.rs (untouched here).

AI Assistance

AI Assistance: Claude Code (Opus 4.8) used for the fixture, test and PR authoring.

@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from f904fdd to a5dff05 Compare July 8, 2026 07:46
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from d7f492e to 0cbbf13 Compare July 8, 2026 07:49
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from a5dff05 to ec3f266 Compare July 8, 2026 07:54
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 0cbbf13 to 209af78 Compare July 8, 2026 07:55
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from ec3f266 to f4d7a23 Compare July 8, 2026 08:36
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 209af78 to ac66518 Compare July 8, 2026 08:36
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from f4d7a23 to bb88b17 Compare July 8, 2026 08:45
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from ac66518 to f6b39b6 Compare July 8, 2026 08:45
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from bb88b17 to b388962 Compare July 8, 2026 08:51
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from f6b39b6 to d08136d Compare July 8, 2026 08:51
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from b388962 to 146d6cb Compare July 8, 2026 08:55
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from d08136d to c930cc0 Compare July 8, 2026 08:55
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 146d6cb to 5177c22 Compare July 8, 2026 09:03
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from c930cc0 to 035550f Compare July 8, 2026 09:03
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 5177c22 to 25bccb5 Compare July 8, 2026 09:19
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 035550f to 5340905 Compare July 8, 2026 09:19
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 25bccb5 to 62b40a8 Compare July 8, 2026 12:10
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 5340905 to 84542b5 Compare July 8, 2026 12:10
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 62b40a8 to f25ce1b Compare July 8, 2026 12:20
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 84542b5 to 711da09 Compare July 8, 2026 12:20
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from f25ce1b to 5186aff Compare July 8, 2026 12:50
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 711da09 to 6346d1f Compare July 8, 2026 12:50
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 5186aff to cc3d720 Compare July 8, 2026 13:44
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 6346d1f to 5271b4a Compare July 8, 2026 13:45
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from cc3d720 to 0088a67 Compare July 8, 2026 14:00
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from 5271b4a to 454c904 Compare July 8, 2026 14:00
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from 0088a67 to aadc89c Compare July 8, 2026 14:09
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch 2 times, most recently from 4fc6d4a to 845029d Compare July 8, 2026 14:13

@jean-neiverth jean-neiverth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean test. The ManualClock sharing via Arc is correct, the timeout prevents hangs, and the CI wiring is consistent.

@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch 2 times, most recently from df45f97 to a6ec61a Compare July 8, 2026 23:05
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch 2 times, most recently from a22852e to d635bbe Compare July 8, 2026 23:24
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch 2 times, most recently from 8f1affb to 3825099 Compare July 8, 2026 23:29
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch 2 times, most recently from 35a3c85 to c13c909 Compare July 9, 2026 01:18
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch 2 times, most recently from 93006aa to fa54bf4 Compare July 9, 2026 01:35
@mfw78 mfw78 changed the base branch from chore/m0-epic-followups to fix/m1-cow-sweep July 9, 2026 01:35
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from fa54bf4 to e1282d9 Compare July 9, 2026 01:53
@mfw78 mfw78 changed the base branch from fix/m1-cow-sweep to chore/m0-epic-followups July 9, 2026 01:54
@mfw78 mfw78 force-pushed the chore/m0-epic-followups branch from c13c909 to 8a272d5 Compare July 9, 2026 07:29
Base automatically changed from chore/m0-epic-followups to develop July 9, 2026 07:38
…lock override

Add a clock-reader fixture that reads the WASI wall clock through std on
every event and logs it, plus a harness test that pins a ManualClock,
boots the fixture under that override, dispatches a block, and asserts the
guest logged the pinned instant rather than the ambient host clock. This
proves the WasiClockOverride reaches the guest end to end, not just the
host boot path.
@mfw78 mfw78 force-pushed the test/guest-clock-e2e branch from e1282d9 to 0adea04 Compare July 9, 2026 07:55
@mfw78 mfw78 merged commit f8f7957 into develop Jul 9, 2026
11 checks passed
@mfw78 mfw78 deleted the test/guest-clock-e2e branch July 9, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: assert guest-observed wasi:clocks time under a ManualClock override

2 participants