feat(raft-library): task 4.2 — sim deliver/partition/timeout/start-all; 4 tests

This commit is contained in:
Rongsong Shen 2026-05-31 06:20:35 +00:00
parent d2e2c1ef8a
commit c1b07392df
2 changed files with 151 additions and 1 deletions

View file

@ -77,7 +77,7 @@
- _Requirements: 8.1_
- _Boundary: raft_sim.c_
- [ ] 4.2 Implement simulator network operations and test driving
- [x] 4.2 Implement simulator network operations and test driving
- `raft_sim_deliver_pending(cluster)`: routes all buffered RPCs synchronously — for each buffered `(src, dst, term)` entry, calls `raft_on_vote_request` on `dst` then routes the reply back to `src` via `raft_on_vote_reply`; skips delivery if `dst` has `partition=1`
- `raft_sim_start_all_elections(cluster)`: calls `raft_start_election` on each node in order 0..n-1
- `raft_sim_fire_timeout(cluster, node_idx)`: calls `raft_on_election_timeout` on the specified node