Available on crate feature
testing only.Expand description
A harness for driving both engines against each other, on a virtual clock.
Because the sessions are deterministic and take now as a parameter, a whole
conversation — handshake, control-type selection, a description, an instruction, a
lost acknowledgement, a timer expiring — is an ordinary unit test that runs in
microseconds. Conversation wires a RmSession and a CemSession back to
back through an in-memory pipe and records everything that crosses it.
Every message crosses the wire format on the way, so what is under test is the encoding as well as the logic.
use s2_kit::prelude::*;
use s2_kit::testing::Conversation;
let mut c = Conversation::battery();
c.open();
assert!(matches!(c.cem.state(), SessionState::Connected));
assert!(c.cem.details().is_some(), "the resource described itself");Structs§
- Conversation
- A Resource Manager and a Customer Energy Manager, talking to each other.
- Replay
Report - What a replay found, and what it saw.
- Transcript
Entry - One line of a
.s2logtranscript.
Enums§
- Direction
- Which way a message went.
- Finding
- Something a recorded conversation did that this crate would not have done.
Functions§
- battery_
details - The 20 kWh home battery from
s2-example-implementations. - battery_
system - A battery’s system description: charge, idle and discharge over a 0–100 % store.
- charge
- An FRBC instruction for the battery fixture.
- every_
message - One of every message, with every optional field set.
- pv_
constraints - The PV installation’s constraints: curtail freely between −4 kW and zero.
- pv_
details - The 2 kWp curtailable PV installation from
s2-example-implementations. - read_
s2log - Read a whole
.s2log, skipping anything that is not a transcript line. - replay
- Replay a recorded conversation and say where it departs from the standard.
- replay_
with - As
replay, with the observer configured — a different wire profile, strict decoding, an S2 Connect session where a handshake would be redundant.