Skip to content

test(setu-vlc): add unit tests for VectorClock and VLCSnapshot - #38

Open
Alicepoltora wants to merge 1 commit into
AdvaitaLabs:mainfrom
Alicepoltora:test/setu-vlc-unit-tests
Open

test(setu-vlc): add unit tests for VectorClock and VLCSnapshot#38
Alicepoltora wants to merge 1 commit into
AdvaitaLabs:mainfrom
Alicepoltora:test/setu-vlc-unit-tests

Conversation

@Alicepoltora

Copy link
Copy Markdown

Summary

The setu-vlc crate (vector logical clocks — the causality primitive used across the consensus and networking layers) shipped with a complete public API but no tests, while sibling leaf crates carry 30–67 each (setu-merkle 67, setu-keys 35, setu-router-core 32). This PR closes that gap.

No library code is changed — the PR is behavior-preserving and only adds a #[cfg(test)] module (matching the in-module convention used by the other crates).

What's covered (32 unit tests + serde round-trips)

VectorClock: construction/defaults, increment (auto-create + returned value), set/get, merge (element-wise max, node union, idempotence), happens_before (strict prefix, new-node-in-other, empty→nonempty, transitivity), is_concurrent (equal ≠ concurrent, divergent = concurrent), dynamic membership (remove_node, reset_node), GC (gc_zero_nodes, retain_active_nodes), serde round-trip.

VLCSnapshot: construction, increment, the receive() hybrid-logical-clock update rule (logical_time = max(local, remote) + 1, merge, local bump), causal ordering across a send/receive, logical-time tiebreak when vector clocks are equal, is_concurrent, gc_inactive_nodes, serde round-trip.

Notes

  • Adds serde_json = "1.0" under [dev-dependencies] for the serialization round-trip tests (the types derive Serialize/Deserialize to travel between nodes).
  • Verified locally: cargo test -p setu-vlc → 32 passed + 1 doc-test passed; cargo clippy clean; added code is rustfmt-clean.

The setu-vlc crate (vector logical clocks, the causality primitive used
across consensus) shipped with a full public API but no tests, while
sibling leaf crates carry 30-67. This adds 32 unit tests plus serde
round-trip coverage for both VectorClock and VLCSnapshot: construction,
increment/set/merge, happens-before / concurrency semantics (including
empty-clock and new-node edge cases), transitivity, dynamic membership
(remove/reset), GC (gc_zero_nodes, retain_active_nodes), and the
receive() hybrid-logical-clock update rule.

Adds serde_json as a dev-dependency for the serialization round-trip
tests. No library code changed; behavior-preserving.
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.

1 participant