Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Feb 10, 2024
1 parent 3c1f05c commit fbc90fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions rs-matter/tests/common/im_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const BASIC_INFO: BasicInfoConfig<'static> = BasicInfoConfig {
device_name: "Test Device",
product_name: "TestProd",
vendor_name: "TestVendor",
unique_id: "aabbccdd",
};

struct DummyDevAtt;
Expand Down
45 changes: 29 additions & 16 deletions rs-matter/tests/data_model/long_reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ use crate::{
},
};

fn wildcard_read_resp(part: u8) -> Vec<AttrResp<'static>> {
fn wildcard_read_resp(part: u8, subscription: bool) -> Vec<AttrResp<'static>> {
// For brevity, we only check the AttrPath, not the actual 'data'
let dont_care = ElementType::U8(0);
let part1 = vec![
let mut part1 = vec![
attr_data!(0, 29, GlobalElements::FeatureMap, dont_care.clone()),
attr_data!(0, 29, GlobalElements::AttributeList, dont_care.clone()),
attr_data!(
Expand Down Expand Up @@ -123,6 +123,12 @@ fn wildcard_read_resp(part: u8) -> Vec<AttrResp<'static>> {
basic_info::AttributesDiscriminants::SerialNo,
dont_care.clone()
),
attr_data!(
0,
40,
basic_info::AttributesDiscriminants::UniqueId,
dont_care.clone()
),
attr_data!(0, 48, GlobalElements::FeatureMap, dont_care.clone()),
attr_data!(0, 48, GlobalElements::AttributeList, dont_care.clone()),
attr_data!(
Expand Down Expand Up @@ -201,21 +207,15 @@ fn wildcard_read_resp(part: u8) -> Vec<AttrResp<'static>> {
adm_comm::AttributesDiscriminants::WindowStatus,
dont_care.clone()
),
attr_data!(
0,
60,
adm_comm::AttributesDiscriminants::AdminFabricIndex,
dont_care.clone()
),
];

let mut part2 = vec![
attr_data!(
0,
60,
adm_comm::AttributesDiscriminants::AdminVendorId,
dont_care.clone()
),
];

let part2 = vec![
attr_data!(0, 62, GlobalElements::FeatureMap, dont_care.clone()),
attr_data!(0, 62, GlobalElements::AttributeList, dont_care.clone()),
attr_data!(
Expand Down Expand Up @@ -336,10 +336,23 @@ fn wildcard_read_resp(part: u8) -> Vec<AttrResp<'static>> {
1,
echo::ID,
echo::AttributesDiscriminants::AttCustom,
dont_care
dont_care.clone()
),
];

let attr_data = attr_data!(
0,
60,
adm_comm::AttributesDiscriminants::AdminFabricIndex,
dont_care
);

if subscription {
part2.insert(0, attr_data);
} else {
part1.push(attr_data);
}

if part == 1 {
part1
} else {
Expand All @@ -362,12 +375,12 @@ fn test_long_read_success() {

let read_all = [AttrPath::new(&wc_path)];
let read_req = ReadReq::new(true).set_attr_requests(&read_all);
let expected_part1 = wildcard_read_resp(1);
let expected_part1 = wildcard_read_resp(1, false);

let status_report = StatusResp {
status: IMStatusCode::Success,
};
let expected_part2 = wildcard_read_resp(2);
let expected_part2 = wildcard_read_resp(2, false);

im.process(
&handler,
Expand Down Expand Up @@ -411,12 +424,12 @@ fn test_long_read_subscription_success() {

let read_all = [AttrPath::new(&wc_path)];
let subs_req = SubscribeReq::new(true, 1, 20).set_attr_requests(&read_all);
let expected_part1 = wildcard_read_resp(1);
let expected_part1 = wildcard_read_resp(1, true);

let status_report = StatusResp {
status: IMStatusCode::Success,
};
let expected_part2 = wildcard_read_resp(2);
let expected_part2 = wildcard_read_resp(2, true);

im.process(
&handler,
Expand Down

0 comments on commit fbc90fc

Please sign in to comment.