MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test

Function test

chirpstack/src/maccommand/link_adr.rs:172–391  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

170
171 #[test]
172 fn test() {
173 region::set(
174 "eu868",
175 lrwn::region::get(lrwn::region::CommonName::EU868, false, false),
176 );
177
178 let tests = vec![Test {
179 name: "pending request and positive ACK updates tx-power, nbtrans and channels".into(),
180 device_session: internal::DeviceSession {
181 adr: true,
182 enabled_uplink_channel_indices: vec![0, 1],
183 mac_command_error_count: [(lrwn::CID::LinkADRReq.to_u8() as u32, 1)]
184 .iter()
185 .cloned()
186 .collect(),
187 uplink_adr_history: vec![internal::UplinkAdrHistory {
188 ..Default::default()
189 }],
190 ..Default::default()
191 },
192 link_adr_req: Some(lrwn::LinkADRReqPayload {
193 dr: 5,
194 tx_power: 3,
195 ch_mask: lrwn::ChMask::from_slice(&[true, true, true]).unwrap(),
196 redundancy: lrwn::Redundancy {
197 ch_mask_cntl: 0,
198 nb_rep: 2,
199 },
200 }),
201 link_adr_ans: lrwn::LinkADRAnsPayload {
202 ch_mask_ack: true,
203 dr_ack: true,
204 tx_power_ack: true,
205 },
206 expected_device_session: internal::DeviceSession {
207 adr: true,
208 enabled_uplink_channel_indices: vec![0, 1, 2],
209 tx_power_index: 3,
210 nb_trans: 2,
211 dr: 5,
212 mac_command_error_count: HashMap::new(),
213 uplink_adr_history: vec![],
214 ..Default::default()
215 },
216 expected_error: None,
217 }, Test {
218 name: "pending request and negative tx-power ack decrements the max allowed tx-power index".into(),
219 device_session: internal::DeviceSession{
220 adr: true,
221 enabled_uplink_channel_indices: vec![0, 1],
222 ..Default::default()
223 },
224 link_adr_req: Some(lrwn::LinkADRReqPayload {
225 dr: 5,
226 tx_power: 3,
227 ch_mask: lrwn::ChMask::from_slice(&[true, true, true]).unwrap(),
228 redundancy: lrwn::Redundancy {
229 ch_mask_cntl: 0,

Callers

nothing calls this directly

Calls 7

MACPayloadClass · 0.85
unwrapMethod · 0.80
as_refMethod · 0.80
handleFunction · 0.70
setFunction · 0.50
getFunction · 0.50
intoMethod · 0.45

Tested by

no test coverage detected