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

Function test_handle

chirpstack/src/maccommand/device_time.rs:47–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46 #[test]
47 fn test_handle() {
48 let rx_time = Utc::now();
49
50 let ufs = UplinkFrameSet {
51 uplink_set_id: Uuid::new_v4(),
52 dr: 0,
53 ch: 0,
54 phy_payload: lrwn::PhyPayload {
55 mhdr: lrwn::MHDR {
56 f_type: lrwn::FType::UnconfirmedDataUp,
57 major: lrwn::Major::LoRaWANR1,
58 },
59 payload: lrwn::Payload::MACPayload(lrwn::MACPayload {
60 fhdr: Default::default(),
61 f_port: None,
62 frm_payload: None,
63 }),
64 mic: None,
65 },
66 tx_info: Default::default(),
67 rx_info_set: vec![gw::UplinkRxInfo {
68 gw_time: Some(rx_time.into()),
69 ..Default::default()
70 }],
71 gateway_private_up_map: HashMap::new(),
72 gateway_private_down_map: HashMap::new(),
73 gateway_tenant_id_map: HashMap::new(),
74 gateway_downlink_priority_map: HashMap::new(),
75 region_common_name: lrwn::region::CommonName::EU868,
76 region_config_id: "eu868".into(),
77 roaming_meta_data: None,
78 };
79
80 let gps_time = rx_time.to_gps_time();
81
82 let dev: device::Device = Default::default();
83 let block = lrwn::MACCommandSet::new(vec![lrwn::MACCommand::DeviceTimeReq]);
84
85 let resp = handle(&ufs, &dev, &block).unwrap();
86
87 assert_eq!(
88 Some(lrwn::MACCommandSet::new(vec![
89 lrwn::MACCommand::DeviceTimeAns(lrwn::DeviceTimeAnsPayload {
90 time_since_gps_epoch: gps_time.to_std().unwrap(),
91 })
92 ])),
93 resp
94 );
95 }
96}

Callers

nothing calls this directly

Calls 5

MACPayloadClass · 0.85
to_gps_timeMethod · 0.80
unwrapMethod · 0.80
handleFunction · 0.70
intoMethod · 0.45

Tested by

no test coverage detected