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

Function test_handle

chirpstack/src/maccommand/notify_new_end_device.rs:86–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84
85 #[tokio::test]
86 async fn test_handle() {
87 let _guard = test::prepare().await;
88 integration::set_mock().await;
89
90 let t = tenant::Tenant {
91 id: Uuid::new_v4().into(),
92 name: "tenant".to_string(),
93 ..Default::default()
94 };
95
96 let app = application::Application {
97 id: Uuid::new_v4().into(),
98 name: "app".to_string(),
99 ..Default::default()
100 };
101
102 let dp = device_profile::DeviceProfile {
103 id: Uuid::new_v4().into(),
104 name: "dp".to_string(),
105 tags: fields::KeyValue::new(
106 [("dp_tag".to_string(), "dp_value".to_string())]
107 .iter()
108 .cloned()
109 .collect(),
110 ),
111 ..Default::default()
112 };
113
114 let dev = device::Device {
115 dev_eui: lrwn::EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
116 name: "dev".to_string(),
117 tags: fields::KeyValue::new(
118 [("dev_tag".to_string(), "dev_value".to_string())]
119 .iter()
120 .cloned()
121 .collect(),
122 ),
123 ..Default::default()
124 };
125
126 let block = lrwn::MACCommandSet::new(vec![lrwn::MACCommand::NotifyNewEndDeviceReq(
127 lrwn::NotifyNewEndDeviceReqPayload {
128 dev_addr: lrwn::DevAddr::from_be_bytes([1, 2, 3, 4]),
129 power_level: lrwn::PowerLevel {
130 wor_snr: 10,
131 wor_rssi: 20,
132 },
133 },
134 )]);
135
136 handle(&t, &dp, &app, &dev, &block).await.unwrap();
137 sleep(Duration::from_millis(100)).await;
138 let mock_events = integration::mock::get_log_events().await;
139 assert_eq!(1, mock_events.len());
140
141 let mut mock_event = mock_events[0].clone();
142 assert!(mock_event.time.is_some());
143 mock_event.time = None;

Callers

nothing calls this directly

Calls 8

prepareFunction · 0.85
set_mockFunction · 0.85
get_log_eventsFunction · 0.85
to_stringMethod · 0.80
iterMethod · 0.80
unwrapMethod · 0.80
handleFunction · 0.70
intoMethod · 0.45

Tested by

no test coverage detected