macro_rules! run_node_contract_tests {
($mod_name:ident, {
make_nodelink: $make_nodelink:expr
}) => { ... };
}Expand description
Expand a canonical suite of node contract tests for a NodeLink factory.
§Purpose
Generate a focused #[test] module that runs the standard Node contract
fixtures (lifecycle, single-message, and batched behaviour, error/backpressure
mapping, and wrapper-specific checks for Source, Sink, and Model).
§Required argument
make_nodelink: || -> NodeLink<N, IN, OUT, InP, OutP>A zero-argument closure that returns a freshNodeLinkowning the concrete node under test. The closure is invoked once per generated test (i.e., the factory must return a new, independentNodeLinkeach time).
§Type requirements
- The node produced by your
NodeLinkmust implementNode<IN, OUT, InP, OutP>. - Payload types
InPandOutPmust implementPayload + Default + Cloneso the tests can synthesizeMessage::new(header, P::default())values.
§Behaviour
The macro expands to a mod $mod_name { ... } containing these tests:
initialize_start_stop_roundtripprocess_message_enqueues_and_made_progressstep_on_empty_returns_noinputstep_pops_and_calls_process_messagestep_batch_respects_fixed_n_disjointstep_batch_respects_sliding_windowstep_maps_backpressure_and_errorssource_specific_behavioursink_specific_behaviourmodel_specific_batching_behaviourfixed_n_with_max_delta_t_behaviour
Each generated test delegates to a fixture in node::contract_tests. The
suite is adaptive: fixtures will skip or adjust assertions for IN == 0
(sources), OUT == 0 (sinks), or when the node reports NodeKind::Source,
NodeKind::Sink, or NodeKind::Model.
§Usage
use limen_core::run_node_contract_tests;
run_node_contract_tests!(my_node_contracts, {
make_nodelink: || create_my_node_link()
});Put the macro invocation in your crate’s tests (or #[cfg(test)] module).
Keep the make_nodelink factory cheap and deterministic so the per-test
instances are reliable.
§Notes
- Tests assert node-level semantics (counts,
StepResult, telemetry) and do not inspect payload internals. Implementors should ensure payloads derive/implementDefault + Clonefor compatibility with the suite.