Skip to content

Commit 85318f1

Browse files
committed
level_control: bump TestLevelControlDeviceLogic cluster revision to 6
`LevelControlHandler::validate()` panics unless `H::CLUSTER.revision` is 6, and the Matter 1.5.1 IDL declares LevelControl at revision 6. The in-tree `TestLevelControlDeviceLogic` still declared revision 5, so any caller (including `examples/src/bin/speaker.rs`) that exercised `init()` panicked at startup with "incorrect version number: expected 6 got 5". The sibling `TestOnOffDeviceLogic` already tracks revision 6; this brings LevelControl in line. Also adds a small 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.
1 parent 7d96427 commit 85318f1

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)