Skip to content

Commit 710e24c

Browse files
test(pi): make heartbeat proof deterministic
agent-identity: dev3.direct.omp.9exwnk6h agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.1.7 agent-runtime: OMP 18.1.7 tooling-profile: dotfiles@931583a
1 parent 7a1e2eb commit 710e24c

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

src/pi_channel.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -846,10 +846,7 @@ mod tests {
846846

847847
tx.send(Ok(r#"{"type":"state","state":"active"}"#.to_string()))
848848
.unwrap();
849-
let disconnect = thread::spawn(move || {
850-
thread::sleep(Duration::from_millis(40));
851-
drop(tx);
852-
});
849+
drop(tx);
853850
let mut out = Vec::new();
854851
channel_loop(
855852
&rx,
@@ -861,24 +858,19 @@ mod tests {
861858
"h.worker",
862859
&PI_KIND,
863860
Duration::from_millis(2),
864-
Duration::from_millis(5),
861+
Duration::ZERO,
865862
)
866863
.unwrap();
867864

868-
disconnect.join().unwrap();
869-
870865
let raw: Value = serde_json::from_slice(&std::fs::read(&record).unwrap()).unwrap();
871866
assert_eq!(raw["state"], "active", "EOF must not rewrite the state");
872867
assert!(
873868
raw["writtenAtMs"].as_u64().unwrap() > raw["sinceMs"].as_u64().unwrap(),
874-
"a heartbeat re-stamped the record while the connection lived: {raw}"
869+
"no heartbeat re-stamped the record while the connection lived: {raw}"
875870
);
876-
let after_eof = std::fs::read(&record).unwrap();
877-
thread::sleep(Duration::from_millis(15));
878-
assert_eq!(
879-
std::fs::read(&record).unwrap(),
880-
after_eof,
881-
"nothing may write after the connection is gone"
871+
assert!(
872+
raw.get("exit").is_none(),
873+
"EOF must not write a terminal record: {raw}"
882874
);
883875
}
884876

0 commit comments

Comments
 (0)