Skip to content

Commit da2d79e

Browse files
authored
level_control: bump TestLevelControlDeviceLogic cluster revision to 6 (#453)
## Summary `LevelControlHandler::validate()` panics unless `H::CLUSTER.revision == 6`, and the Matter 1.5.1 IDL declares LevelControl at revision 6. The in-tree `TestLevelControlDeviceLogic` still declared revision 5, so any caller that exercises `init()` panics at startup with: ``` LevelControl validation: incorrect version number: expected 6 got 5 ``` `examples/src/bin/speaker.rs` L99–115 hits this — it constructs the handler with `new(...) + .init(...)`. The sibling `TestOnOffDeviceLogic` already tracks revision 6, so this just brings LevelControl in line. ## Changes - `rs-matter/src/dm/clusters/app/level_control.rs:1778` — `with_revision(5)` → `with_revision(6)`. - Same file — adds a regression test that constructs the LevelControl + OnOff handler pair the same way `speaker.rs` does, so future drift between `TestLevelControlDeviceLogic::CLUSTER` and what `LevelControlHandler::validate()` requires is caught at CI time rather than at first runtime use. ## References - `rs-matter/src/dm/clusters/app/level_control.rs` L290–296 — validator (`if H::CLUSTER.revision != 6 { panic!(...) }`). - `rs-matter-codegen/src/idl/parser/controller-clusters-V1.5.1.0.matter` L557–558 — IDL says revision 6. ## Test plan - [x] `cargo test --package rs-matter --lib dm::clusters::app::level_control::tests::` — passes. - [x] Reverted the revision to 5 to confirm the new test fails with the original panic; restored.
1 parent 7d96427 commit da2d79e

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

rs-matter/src/dm/clusters/app/level_control.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ pub mod test {
17751775
const MAX_LEVEL: u8 = 254;
17761776
const FASTEST_RATE: u8 = 50;
17771777
const CLUSTER: Cluster<'static> = FULL_CLUSTER
1778-
.with_revision(5)
1778+
.with_revision(6)
17791779
.with_features(Feature::ON_OFF.bits())
17801780
.with_attrs(with!(
17811781
required;
@@ -1827,3 +1827,29 @@ pub mod test {
18271827
}
18281828
}
18291829
}
1830+
1831+
#[cfg(test)]
1832+
mod tests {
1833+
use super::test::TestLevelControlDeviceLogic;
1834+
use super::{AttributeDefaults, LevelControlHandler};
1835+
use crate::dm::clusters::app::on_off::test::TestOnOffDeviceLogic;
1836+
use crate::dm::clusters::app::on_off::OnOffHandler;
1837+
use crate::dm::Dataver;
1838+
1839+
/// Catches drift between `TestLevelControlDeviceLogic::CLUSTER` and
1840+
/// `LevelControlHandler::validate()`.
1841+
#[test]
1842+
fn test_logic_passes_handler_validate() {
1843+
let level_logic = TestLevelControlDeviceLogic::new();
1844+
let on_off_logic = TestOnOffDeviceLogic::new(false);
1845+
let level = LevelControlHandler::new(
1846+
Dataver::new(1),
1847+
1,
1848+
&level_logic,
1849+
AttributeDefaults::default(),
1850+
);
1851+
let on_off = OnOffHandler::new(Dataver::new(2), 1, &on_off_logic);
1852+
on_off.init(Some(&level));
1853+
level.init(Some(&on_off));
1854+
}
1855+
}

0 commit comments

Comments
 (0)