mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-01-18 10:36:23 +00:00
Fix clippy feedback (cargo clippy --fix).
This commit is contained in:
parent
7158c0c610
commit
5794f41324
24
api/rust/src/gw.rs
vendored
24
api/rust/src/gw.rs
vendored
@ -95,7 +95,7 @@ impl UplinkFrame {
|
||||
})
|
||||
}
|
||||
uplink_tx_info_legacy::ModulationInfo::FskModulationInfo(info) => {
|
||||
modulation::Parameters::Fsk(info.clone())
|
||||
modulation::Parameters::Fsk(*info)
|
||||
}
|
||||
uplink_tx_info_legacy::ModulationInfo::LrFhssModulationInfo(info) => {
|
||||
modulation::Parameters::LrFhss(LrFhssModulationInfo {
|
||||
@ -120,9 +120,9 @@ impl UplinkFrame {
|
||||
self.rx_info = Some(UplinkRxInfo {
|
||||
gateway_id: hex::encode(&rx_info.gateway_id),
|
||||
uplink_id: rng.gen::<u32>(),
|
||||
gw_time: rx_info.time.clone(),
|
||||
gw_time: rx_info.time,
|
||||
ns_time: None,
|
||||
time_since_gps_epoch: rx_info.time_since_gps_epoch.clone(),
|
||||
time_since_gps_epoch: rx_info.time_since_gps_epoch,
|
||||
fine_time_since_gps_epoch: None,
|
||||
rssi: rx_info.rssi,
|
||||
snr: rx_info.lora_snr as f32,
|
||||
@ -130,7 +130,7 @@ impl UplinkFrame {
|
||||
rf_chain: rx_info.rf_chain,
|
||||
board: rx_info.board,
|
||||
antenna: rx_info.antenna,
|
||||
location: rx_info.location.clone(),
|
||||
location: rx_info.location,
|
||||
context: rx_info.context.clone(),
|
||||
metadata: rx_info.metadata.clone(),
|
||||
crc_status: rx_info.crc_status,
|
||||
@ -195,23 +195,19 @@ impl DownlinkFrame {
|
||||
Some(timing::Parameters::Immediately(v)) => {
|
||||
tx_info_legacy.timing = DownlinkTiming::Immediately.into();
|
||||
tx_info_legacy.timing_info = Some(
|
||||
downlink_tx_info_legacy::TimingInfo::ImmediatelyTimingInfo(
|
||||
v.clone(),
|
||||
),
|
||||
downlink_tx_info_legacy::TimingInfo::ImmediatelyTimingInfo(*v),
|
||||
);
|
||||
}
|
||||
Some(timing::Parameters::Delay(v)) => {
|
||||
tx_info_legacy.timing = DownlinkTiming::Delay.into();
|
||||
tx_info_legacy.timing_info = Some(
|
||||
downlink_tx_info_legacy::TimingInfo::DelayTimingInfo(v.clone()),
|
||||
);
|
||||
tx_info_legacy.timing_info =
|
||||
Some(downlink_tx_info_legacy::TimingInfo::DelayTimingInfo(*v));
|
||||
}
|
||||
Some(timing::Parameters::GpsEpoch(v)) => {
|
||||
tx_info_legacy.timing = DownlinkTiming::GpsEpoch.into();
|
||||
tx_info_legacy.timing_info =
|
||||
Some(downlink_tx_info_legacy::TimingInfo::GpsEpochTimingInfo(
|
||||
v.clone(),
|
||||
));
|
||||
tx_info_legacy.timing_info = Some(
|
||||
downlink_tx_info_legacy::TimingInfo::GpsEpochTimingInfo(*v),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1945,9 +1945,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut create_req = Request::new(create_req);
|
||||
create_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
create_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let create_resp = service.create(create_req).await.unwrap();
|
||||
let create_resp = create_resp.get_ref();
|
||||
|
||||
@ -1956,7 +1954,7 @@ pub mod test {
|
||||
id: create_resp.id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Application {
|
||||
@ -1978,7 +1976,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut up_req = Request::new(up_req);
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.update(up_req).await.unwrap();
|
||||
|
||||
//get
|
||||
@ -1986,7 +1984,7 @@ pub mod test {
|
||||
id: create_resp.id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Application {
|
||||
@ -2006,7 +2004,7 @@ pub mod test {
|
||||
offset: 0,
|
||||
};
|
||||
let mut list_req = Request::new(list_req);
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let list_resp = service.list(list_req).await.unwrap();
|
||||
assert_eq!(1, list_resp.get_ref().total_count);
|
||||
assert_eq!(1, list_resp.get_ref().result.len());
|
||||
@ -2016,14 +2014,14 @@ pub mod test {
|
||||
id: create_resp.id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.delete(del_req).await.unwrap();
|
||||
|
||||
let del_req = api::DeleteApplicationRequest {
|
||||
id: create_resp.id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let del_resp = service.delete(del_req).await;
|
||||
assert!(del_resp.is_err());
|
||||
}
|
||||
@ -2038,7 +2036,7 @@ pub mod test {
|
||||
.unwrap();
|
||||
|
||||
application::create(application::Application {
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
name: "test-app".into(),
|
||||
..Default::default()
|
||||
})
|
||||
@ -2059,7 +2057,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
|
||||
|
@ -95,14 +95,11 @@ pub mod test {
|
||||
assert_eq!(claim, decoded);
|
||||
|
||||
// different key
|
||||
assert_eq!(
|
||||
true,
|
||||
AuthClaim::decode(&token, other_secret.as_ref()).is_err()
|
||||
);
|
||||
assert!(AuthClaim::decode(&token, other_secret.as_ref()).is_err());
|
||||
|
||||
// expired
|
||||
claim.exp = Some(exp.timestamp() as usize);
|
||||
let token = claim.encode(secrect.as_ref()).unwrap();
|
||||
assert_eq!(true, AuthClaim::decode(&token, secrect.as_ref()).is_err());
|
||||
assert!(AuthClaim::decode(&token, secrect.as_ref()).is_err());
|
||||
}
|
||||
}
|
||||
|
@ -2138,7 +2138,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user,
|
||||
&tenant_user,
|
||||
&tenant_admin,
|
||||
@ -2382,7 +2382,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
@ -2654,7 +2654,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user_active,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
@ -2919,7 +2919,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![&user_active, &user_admin] {
|
||||
for u in [&user_active, &user_admin] {
|
||||
user::create(u.clone()).await.unwrap();
|
||||
}
|
||||
|
||||
@ -3075,7 +3075,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user_active,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
@ -3093,14 +3093,14 @@ pub mod test {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp".into(),
|
||||
tenant_id: tenant_a.id.clone(),
|
||||
tenant_id: tenant_a.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let dp_api_key_tenant = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp-tenant".into(),
|
||||
tenant_id: api_key_tenant.tenant_id.unwrap().clone(),
|
||||
tenant_id: api_key_tenant.tenant_id.unwrap(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -3378,7 +3378,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user_active,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
@ -3636,7 +3636,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![&user_active, &user_admin, &tenant_user] {
|
||||
for u in [&user_active, &user_admin, &tenant_user] {
|
||||
user::create(u.clone()).await.unwrap();
|
||||
}
|
||||
|
||||
@ -3765,7 +3765,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user_active,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
@ -4038,7 +4038,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
for u in vec![
|
||||
for u in [
|
||||
&user_active,
|
||||
&user_admin,
|
||||
&tenant_admin,
|
||||
|
@ -695,20 +695,18 @@ impl DeviceService for Device {
|
||||
.await?;
|
||||
|
||||
let start = SystemTime::try_from(
|
||||
req.start
|
||||
*req.start
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("start is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
let end = SystemTime::try_from(
|
||||
req.end
|
||||
*req.end
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("end is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
@ -819,20 +817,18 @@ impl DeviceService for Device {
|
||||
.await?;
|
||||
|
||||
let start = SystemTime::try_from(
|
||||
req.start
|
||||
*req.start
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("start is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
let end = SystemTime::try_from(
|
||||
req.end
|
||||
*req.end
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("end is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
@ -1256,7 +1252,7 @@ pub mod test {
|
||||
// create application
|
||||
let app = application::create(application::Application {
|
||||
name: "test-app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -1265,7 +1261,7 @@ pub mod test {
|
||||
// create device-profile
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -1421,12 +1417,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
// flush dev nonces
|
||||
let _ = device_keys::set_dev_nonces(
|
||||
&EUI64::from_str("0102030405060708").unwrap(),
|
||||
&vec![1, 2, 3],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let _ =
|
||||
device_keys::set_dev_nonces(&EUI64::from_str("0102030405060708").unwrap(), &[1, 2, 3])
|
||||
.await
|
||||
.unwrap();
|
||||
let flush_dev_nonces_req = get_request(
|
||||
&u.id,
|
||||
api::FlushDevNoncesRequest {
|
||||
@ -1618,7 +1612,7 @@ pub mod test {
|
||||
.await
|
||||
.unwrap();
|
||||
let dev_addr = DevAddr::from_str(&get_random_dev_addr_resp.get_ref().dev_addr).unwrap();
|
||||
let mut dev_addr_copy = dev_addr.clone();
|
||||
let mut dev_addr_copy = dev_addr;
|
||||
dev_addr_copy.set_dev_addr_prefix(NetID::from_str("000000").unwrap().dev_addr_prefix());
|
||||
assert_eq!(dev_addr, dev_addr_copy);
|
||||
|
||||
@ -1666,10 +1660,10 @@ pub mod test {
|
||||
assert_eq!(2, get_queue_resp.total_count);
|
||||
assert_eq!(2, get_queue_resp.result.len());
|
||||
assert_eq!(vec![3, 2, 1], get_queue_resp.result[0].data);
|
||||
assert_eq!(false, get_queue_resp.result[0].is_encrypted);
|
||||
assert!(!get_queue_resp.result[0].is_encrypted);
|
||||
assert_eq!(0, get_queue_resp.result[0].f_cnt_down);
|
||||
assert_eq!(vec![1, 2, 3], get_queue_resp.result[1].data);
|
||||
assert_eq!(true, get_queue_resp.result[1].is_encrypted);
|
||||
assert!(get_queue_resp.result[1].is_encrypted);
|
||||
assert_eq!(10, get_queue_resp.result[1].f_cnt_down);
|
||||
|
||||
// get next FCntDown (from queue)
|
||||
@ -1726,7 +1720,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
}
|
||||
|
@ -345,20 +345,18 @@ impl GatewayService for Gateway {
|
||||
.await?;
|
||||
|
||||
let start = SystemTime::try_from(
|
||||
req.start
|
||||
*req.start
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("start is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
let end = SystemTime::try_from(
|
||||
req.end
|
||||
*req.end
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("end is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
@ -634,20 +632,18 @@ impl GatewayService for Gateway {
|
||||
.await?;
|
||||
|
||||
let start = SystemTime::try_from(
|
||||
req.start
|
||||
*req.start
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("start is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
let end = SystemTime::try_from(
|
||||
req.end
|
||||
*req.end
|
||||
.as_ref()
|
||||
.ok_or_else(|| anyhow!("end is None"))
|
||||
.map_err(|e| e.status())?
|
||||
.clone(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
.map_err(|e| e.status())?;
|
||||
|
||||
@ -1032,9 +1028,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut create_req = Request::new(create_req);
|
||||
create_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
create_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.create(create_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -1042,7 +1036,7 @@ pub mod test {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Gateway {
|
||||
@ -1076,7 +1070,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut up_req = Request::new(up_req);
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.update(up_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -1084,7 +1078,7 @@ pub mod test {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Gateway {
|
||||
@ -1111,7 +1105,7 @@ pub mod test {
|
||||
..Default::default()
|
||||
};
|
||||
let mut list_req = Request::new(list_req);
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let list_resp = service.list(list_req).await.unwrap();
|
||||
assert_eq!(1, list_resp.get_ref().total_count);
|
||||
assert_eq!(1, list_resp.get_ref().result.len());
|
||||
@ -1121,14 +1115,14 @@ pub mod test {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.delete(del_req).await.unwrap();
|
||||
|
||||
let del_req = api::DeleteGatewayRequest {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let del_resp = service.delete(del_req).await;
|
||||
assert!(del_resp.is_err());
|
||||
}
|
||||
@ -1160,7 +1154,7 @@ pub mod test {
|
||||
// create gateway
|
||||
let _ = gateway::create(gateway::Gateway {
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
name: "test-gw".into(),
|
||||
..Default::default()
|
||||
})
|
||||
@ -1172,7 +1166,7 @@ pub mod test {
|
||||
// insert stats
|
||||
let mut m = metrics::Record {
|
||||
kind: metrics::Kind::ABSOLUTE,
|
||||
time: now.into(),
|
||||
time: now,
|
||||
metrics: HashMap::new(),
|
||||
};
|
||||
|
||||
@ -1204,9 +1198,7 @@ pub mod test {
|
||||
aggregation: common::Aggregation::Day.into(),
|
||||
};
|
||||
let mut stats_req = Request::new(stats_req);
|
||||
stats_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
stats_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let stats_resp = service.get_metrics(stats_req).await.unwrap();
|
||||
let stats_resp = stats_resp.get_ref();
|
||||
assert_eq!(
|
||||
@ -1257,7 +1249,7 @@ pub mod test {
|
||||
// create gateway
|
||||
let _ = gateway::create(gateway::Gateway {
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
name: "test-gw".into(),
|
||||
..Default::default()
|
||||
})
|
||||
@ -1269,7 +1261,7 @@ pub mod test {
|
||||
// insert stats
|
||||
let mut m = metrics::Record {
|
||||
kind: metrics::Kind::COUNTER,
|
||||
time: now.into(),
|
||||
time: now,
|
||||
metrics: HashMap::new(),
|
||||
};
|
||||
|
||||
@ -1297,9 +1289,7 @@ pub mod test {
|
||||
end: Some(now_st.into()),
|
||||
};
|
||||
let mut stats_req = Request::new(stats_req);
|
||||
stats_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
stats_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let stats_resp = service.get_duty_cycle_metrics(stats_req).await.unwrap();
|
||||
let stats_resp = stats_resp.get_ref();
|
||||
assert_eq!(
|
||||
|
@ -550,7 +550,7 @@ pub mod test {
|
||||
// create application
|
||||
let app = application::create(application::Application {
|
||||
name: "test-app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -559,7 +559,7 @@ pub mod test {
|
||||
// create device-profile
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -871,7 +871,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ pub mod test {
|
||||
|
||||
fn get_request<T>(user_id: &Uuid, req: T) -> Request<T> {
|
||||
let mut req = Request::new(req);
|
||||
req.extensions_mut().insert(AuthID::User(user_id.clone()));
|
||||
req.extensions_mut().insert(AuthID::User(*user_id));
|
||||
req
|
||||
}
|
||||
}
|
||||
|
@ -482,9 +482,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut create_req = Request::new(create_req);
|
||||
create_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
create_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let create_resp = service.create(create_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -492,7 +490,7 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Tenant {
|
||||
@ -520,7 +518,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut up_req = Request::new(up_req);
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.update(up_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -528,7 +526,7 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::Tenant {
|
||||
@ -551,7 +549,7 @@ pub mod test {
|
||||
user_id: "".into(),
|
||||
};
|
||||
let mut list_req = Request::new(list_req);
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let list_resp = service.list(list_req).await.unwrap();
|
||||
assert_eq!(1, list_resp.get_ref().total_count);
|
||||
assert_eq!(1, list_resp.get_ref().result.len());
|
||||
@ -561,14 +559,14 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.delete(del_req).await.unwrap();
|
||||
|
||||
let del_req = api::DeleteTenantRequest {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let del_resp = service.delete(del_req).await;
|
||||
assert!(del_resp.is_err());
|
||||
}
|
||||
|
@ -292,9 +292,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut create_req = Request::new(create_req);
|
||||
create_req
|
||||
.extensions_mut()
|
||||
.insert(AuthID::User(u.id.clone()));
|
||||
create_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let create_resp = service.create(create_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -302,7 +300,7 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::User {
|
||||
@ -328,7 +326,7 @@ pub mod test {
|
||||
}),
|
||||
};
|
||||
let mut up_req = Request::new(up_req);
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.update(up_req).await.unwrap();
|
||||
|
||||
// get
|
||||
@ -336,7 +334,7 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut get_req = Request::new(get_req);
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
get_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let get_resp = service.get(get_req).await.unwrap();
|
||||
assert_eq!(
|
||||
Some(api::User {
|
||||
@ -356,7 +354,7 @@ pub mod test {
|
||||
password: "newpassword".into(),
|
||||
};
|
||||
let mut up_req = Request::new(up_req);
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
up_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.update_password(up_req).await.unwrap();
|
||||
|
||||
// list
|
||||
@ -365,7 +363,7 @@ pub mod test {
|
||||
limit: 10,
|
||||
};
|
||||
let mut list_req = Request::new(list_req);
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
list_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let list_resp = service.list(list_req).await.unwrap();
|
||||
// * Admin from migrations
|
||||
// * User that we created for auth
|
||||
@ -378,14 +376,14 @@ pub mod test {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let _ = service.delete(del_req).await.unwrap();
|
||||
|
||||
let del_req = api::DeleteUserRequest {
|
||||
id: create_resp.get_ref().id.clone(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let del_resp = service.delete(del_req).await;
|
||||
assert!(del_resp.is_err());
|
||||
|
||||
@ -393,7 +391,7 @@ pub mod test {
|
||||
id: u.id.to_string(),
|
||||
};
|
||||
let mut del_req = Request::new(del_req);
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id.clone()));
|
||||
del_req.extensions_mut().insert(AuthID::User(u.id));
|
||||
let del_resp = service.delete(del_req).await;
|
||||
assert!(del_resp.is_err());
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ pub mod test {
|
||||
|
||||
for _ in 0..100000 {
|
||||
let offset = get_ping_offset(beacon_ts, &dev_addr, ping_nb).unwrap();
|
||||
assert!(offset <= ping_period - 1);
|
||||
beacon_ts = beacon_ts + *BEACON_PERIOD;
|
||||
assert!(offset < ping_period);
|
||||
beacon_ts += *BEACON_PERIOD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1349,7 +1349,7 @@ impl Data {
|
||||
ds.last_device_status_request = Some(Utc::now().into());
|
||||
}
|
||||
Some(ts) => {
|
||||
let ts: DateTime<Utc> = ts.clone().try_into().map_err(anyhow::Error::msg)?;
|
||||
let ts: DateTime<Utc> = (*ts).try_into().map_err(anyhow::Error::msg)?;
|
||||
let req_interval = Duration::from_secs(60 * 60 * 24)
|
||||
/ self.device_profile.device_status_req_interval as u32;
|
||||
|
||||
@ -1711,8 +1711,7 @@ impl Data {
|
||||
|
||||
match &rd.w_f_cnt_last_request {
|
||||
Some(v) => {
|
||||
let last_req: DateTime<Utc> =
|
||||
v.clone().try_into().map_err(anyhow::Error::msg)?;
|
||||
let last_req: DateTime<Utc> = (*v).try_into().map_err(anyhow::Error::msg)?;
|
||||
if last_req
|
||||
< Utc::now()
|
||||
.checked_sub_signed(chrono::Duration::try_hours(24).unwrap())
|
||||
|
@ -319,7 +319,7 @@ mod tests {
|
||||
for _ in 0..100 {
|
||||
let out = select_downlink_gateway(
|
||||
test.tenant_id,
|
||||
&"eu868",
|
||||
"eu868",
|
||||
test.min_snr_margin,
|
||||
&mut rx_info,
|
||||
)
|
||||
@ -328,8 +328,7 @@ mod tests {
|
||||
}
|
||||
|
||||
assert_eq!(test.expected_gws.len(), gw_map.len());
|
||||
assert_eq!(
|
||||
true,
|
||||
assert!(
|
||||
expected_gws.keys().all(|k| gw_map.contains_key(k)),
|
||||
"Expected: {:?}, got: {:?}",
|
||||
expected_gws,
|
||||
|
@ -649,7 +649,7 @@ impl TxAck {
|
||||
}
|
||||
|
||||
let dfl = stream_pb::DownlinkFrameLog {
|
||||
time: dfl.time.clone(),
|
||||
time: dfl.time,
|
||||
phy_payload: phy.to_vec()?,
|
||||
tx_info: dfl.tx_info.clone(),
|
||||
downlink_id: dfl.downlink_id,
|
||||
|
@ -43,7 +43,7 @@ pub async fn get_geoloc_buffer(
|
||||
None => {
|
||||
return false;
|
||||
}
|
||||
Some(v) => match v.clone().try_into() {
|
||||
Some(v) => match (*v).try_into() {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
return false;
|
||||
|
@ -44,11 +44,7 @@ impl Integration {
|
||||
let di = pl.device_info.as_ref().unwrap();
|
||||
|
||||
info!(dev_eui = %di.dev_eui, "Forwarding join notification");
|
||||
let ts: DateTime<Utc> = pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
let ts: DateTime<Utc> = (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let dev_eui = EUI64::from_str(&di.dev_eui)?;
|
||||
@ -74,11 +70,7 @@ impl Integration {
|
||||
let di = pl.device_info.as_ref().unwrap();
|
||||
|
||||
info!(dev_eui = %di.dev_eui, "Forwarding updf message");
|
||||
let ts: DateTime<Utc> = pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
let ts: DateTime<Utc> = (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let dev_eui = EUI64::from_str(&di.dev_eui)?;
|
||||
@ -150,11 +142,7 @@ impl Integration {
|
||||
) -> Result<()> {
|
||||
let di = pl.device_info.as_ref().unwrap();
|
||||
info!(dev_eui = %di.dev_eui, "Forwarding uplink meta-data");
|
||||
let ts: DateTime<Utc> = pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
let ts: DateTime<Utc> = (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let dev_eui = EUI64::from_str(&di.dev_eui)?;
|
||||
@ -242,11 +230,7 @@ impl Integration {
|
||||
}
|
||||
|
||||
let di = pl.device_info.as_ref().unwrap();
|
||||
let ts: DateTime<Utc> = pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
let ts: DateTime<Utc> = (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?;
|
||||
let dev_eui = EUI64::from_str(&di.dev_eui)?;
|
||||
|
@ -268,11 +268,7 @@ impl IntegrationTrait for Integration {
|
||||
|
||||
let e = EventUp {
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -314,11 +310,7 @@ impl IntegrationTrait for Integration {
|
||||
|
||||
let e = EventJoin {
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -352,11 +344,7 @@ impl IntegrationTrait for Integration {
|
||||
let e = EventAck {
|
||||
queue_item_id: Uuid::from_str(&pl.queue_item_id)?,
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -391,11 +379,7 @@ impl IntegrationTrait for Integration {
|
||||
let e = EventTxAck {
|
||||
queue_item_id: Uuid::from_str(&pl.queue_item_id)?,
|
||||
downlink_id: pl.downlink_id as i64,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -429,11 +413,7 @@ impl IntegrationTrait for Integration {
|
||||
info!(dev_eui = %di.dev_eui, event = "log", "Inserting event");
|
||||
|
||||
let e = EventLog {
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -469,11 +449,7 @@ impl IntegrationTrait for Integration {
|
||||
|
||||
let e = EventStatus {
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -510,11 +486,7 @@ impl IntegrationTrait for Integration {
|
||||
|
||||
let e = EventLocation {
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
@ -551,11 +523,7 @@ impl IntegrationTrait for Integration {
|
||||
|
||||
let e = EventIntegration {
|
||||
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
|
||||
time: pl
|
||||
.time
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.clone()
|
||||
time: (*pl.time.as_ref().unwrap())
|
||||
.try_into()
|
||||
.map_err(anyhow::Error::msg)?,
|
||||
tenant_id: Uuid::from_str(&di.tenant_id)?,
|
||||
|
@ -240,10 +240,10 @@ pub mod test {
|
||||
async fn assert_reply(last_id: &str, event: &str, b: &[u8]) -> String {
|
||||
let srr: StreamReadReply = redis::cmd("XREAD")
|
||||
.arg("COUNT")
|
||||
.arg(1 as usize)
|
||||
.arg(1_usize)
|
||||
.arg("STREAMS")
|
||||
.arg("device:stream:event")
|
||||
.arg(&last_id)
|
||||
.arg(last_id)
|
||||
.query_async(&mut get_async_redis_conn().await.unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -128,10 +128,10 @@ mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -297,10 +297,10 @@ mod test {
|
||||
.await;
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
let d = device::get(&dev.dev_eui).await.unwrap();
|
||||
|
@ -137,22 +137,22 @@ pub mod test {
|
||||
.await
|
||||
.unwrap();
|
||||
let app = application::create(application::Application {
|
||||
tenant_id: tenant.id.clone(),
|
||||
tenant_id: tenant.id,
|
||||
name: "test-app".into(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
tenant_id: tenant.id.clone(),
|
||||
tenant_id: tenant.id,
|
||||
name: "test-dp".into(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let dev = device::create(device::Device {
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_str("0102030405060708").unwrap(),
|
||||
name: "test-device".into(),
|
||||
..Default::default()
|
||||
@ -170,7 +170,7 @@ pub mod test {
|
||||
let resp = handle(&ufs, &tenant, &app, &dp, &dev, &block)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(true, resp.is_none());
|
||||
assert!(resp.is_none());
|
||||
|
||||
// Integration events are handled async.
|
||||
sleep(Duration::from_millis(100)).await;
|
||||
@ -201,7 +201,7 @@ pub mod test {
|
||||
|
||||
let d = device::get(&dev.dev_eui).await.unwrap();
|
||||
assert_eq!(Some(10), d.margin);
|
||||
assert_eq!(false, d.external_power_source);
|
||||
assert!(!d.external_power_source);
|
||||
assert_eq!(
|
||||
Some(BigDecimal::from_str("100.00").unwrap()),
|
||||
d.battery_level
|
||||
|
@ -50,22 +50,22 @@ pub mod test {
|
||||
.await
|
||||
.unwrap();
|
||||
let app = application::create(application::Application {
|
||||
tenant_id: tenant.id.clone(),
|
||||
tenant_id: tenant.id,
|
||||
name: "test-app".into(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
tenant_id: tenant.id.clone(),
|
||||
tenant_id: tenant.id,
|
||||
name: "test-dp".into(),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let dev = device::create(device::Device {
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_str("0102030405060708").unwrap(),
|
||||
name: "test-device".into(),
|
||||
..Default::default()
|
||||
|
@ -188,10 +188,10 @@ mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -222,10 +222,10 @@ mod test {
|
||||
let resp = handle(&mut dev, &tst.filter_list_ans, tst.filter_list_req.as_ref());
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -171,7 +171,7 @@ pub mod test {
|
||||
#[test]
|
||||
fn test() {
|
||||
region::set(
|
||||
&"eu868",
|
||||
"eu868",
|
||||
lrwn::region::get(lrwn::region::CommonName::EU868, false, false),
|
||||
);
|
||||
|
||||
@ -367,19 +367,17 @@ pub mod test {
|
||||
let block = lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRAns(
|
||||
tst.link_adr_ans.clone(),
|
||||
)]);
|
||||
let pending = match &tst.link_adr_req {
|
||||
Some(v) => Some(lrwn::MACCommandSet::new(vec![
|
||||
lrwn::MACCommand::LinkADRReq(v.clone()),
|
||||
])),
|
||||
None => None,
|
||||
};
|
||||
let pending = tst
|
||||
.link_adr_req
|
||||
.as_ref()
|
||||
.map(|v| lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(v.clone())]));
|
||||
|
||||
let res = handle(&ufs, &mut dev, &block, pending.as_ref());
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, res.is_err(), "{}", tst.name);
|
||||
assert!(res.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", res.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, res.unwrap().is_none(), "{}", tst.name);
|
||||
assert!(res.unwrap().is_none(), "{}", tst.name);
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -479,10 +479,10 @@ pub mod test {
|
||||
let res = handle(&mut dev, &tst.new_channel_ans, tst.new_channel_req.as_ref());
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, res.is_err(), "{}", tst.name);
|
||||
assert!(res.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", res.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, res.unwrap().is_none(), "{}", tst.name);
|
||||
assert!(res.unwrap().is_none(), "{}", tst.name);
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -193,10 +193,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -171,10 +171,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -186,10 +186,10 @@ mod test {
|
||||
let resp = handle(&mut dev, &tst.relay_conf_ans, tst.relay_conf_req.as_ref());
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -194,10 +194,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -113,10 +113,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -149,10 +149,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -137,10 +137,10 @@ pub mod test {
|
||||
);
|
||||
|
||||
if let Some(e) = &tst.expected_error {
|
||||
assert_eq!(true, resp.is_err(), "{}", tst.name);
|
||||
assert!(resp.is_err(), "{}", tst.name);
|
||||
assert_eq!(e, &format!("{}", resp.err().unwrap()), "{}", tst.name);
|
||||
} else {
|
||||
assert_eq!(true, resp.unwrap().is_none());
|
||||
assert!(resp.unwrap().is_none());
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
|
@ -127,7 +127,7 @@ pub mod test {
|
||||
pub async fn create_api_key(is_admin: bool, is_tenant: bool) -> ApiKey {
|
||||
let ak = ApiKey {
|
||||
name: "test api key".into(),
|
||||
is_admin: is_admin,
|
||||
is_admin,
|
||||
tenant_id: match is_tenant {
|
||||
false => None,
|
||||
true => Some(tenant::test::create_tenant().await.id),
|
||||
@ -191,6 +191,6 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&ak_admin.id).await.unwrap();
|
||||
assert_eq!(true, delete(&ak_admin.id).await.is_err());
|
||||
assert!(delete(&ak_admin.id).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ pub mod test {
|
||||
};
|
||||
|
||||
let a = Application {
|
||||
tenant_id: tenant_id,
|
||||
tenant_id,
|
||||
name: "test application".into(),
|
||||
description: "test application description".into(),
|
||||
..Default::default()
|
||||
@ -662,6 +662,6 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&app.id).await.unwrap();
|
||||
assert_eq!(true, delete(&app.id).await.is_err());
|
||||
assert!(delete(&app.id).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -795,9 +795,9 @@ pub mod test {
|
||||
|
||||
let d = Device {
|
||||
name: "test-dev".into(),
|
||||
dev_eui: dev_eui,
|
||||
application_id: application_id,
|
||||
device_profile_id: device_profile_id,
|
||||
dev_eui,
|
||||
application_id,
|
||||
device_profile_id,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -899,7 +899,7 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&d.dev_eui).await.unwrap();
|
||||
assert_eq!(true, delete(&d.dev_eui).await.is_err());
|
||||
assert!(delete(&d.dev_eui).await.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -1005,7 +1005,7 @@ pub mod test {
|
||||
#[test]
|
||||
fn test_get_full_f_cnt_up() {
|
||||
// server, device, expected
|
||||
let tests = vec![
|
||||
let tests = [
|
||||
(1, 1, 1), // frame-counter is as expected
|
||||
(1 << 16, 0, 1 << 16), // frame-counter is as expected
|
||||
((1 << 16) + 1, 1, (1 << 16) + 1), // frame-counter is as expected
|
||||
@ -1014,7 +1014,7 @@ pub mod test {
|
||||
(2, 1, 1), // re-transmission of previous frame
|
||||
((1 << 16) + 1, 0, (1 << 16)), // re-transmission of previous frame
|
||||
((1 << 16), (1 << 16) - 1, (1 << 16) - 1), // re-transmission of previous frame
|
||||
(u32::MAX, 0, 0), // 32bit frame-counter rollover
|
||||
(u32::MAX, 0, 0),
|
||||
];
|
||||
|
||||
for (i, tst) in tests.iter().enumerate() {
|
||||
@ -1363,7 +1363,7 @@ pub mod test {
|
||||
|
||||
let d = get_for_phypayload_and_incr_f_cnt_up(false, &mut phy, 0, 0).await;
|
||||
if tst.expected_error.is_some() {
|
||||
assert_eq!(true, d.is_err());
|
||||
assert!(d.is_err());
|
||||
assert_eq!(
|
||||
tst.expected_error.as_ref().unwrap(),
|
||||
&d.err().unwrap().to_string()
|
||||
@ -1380,15 +1380,15 @@ pub mod test {
|
||||
}
|
||||
|
||||
if let ValidationStatus::Ok(full_f_cnt, d) = d {
|
||||
assert_eq!(false, tst.expected_retransmission);
|
||||
assert!(!tst.expected_retransmission);
|
||||
assert_eq!(tst.expected_dev_eui, d.dev_eui,);
|
||||
assert_eq!(tst.expected_fcnt_up, full_f_cnt);
|
||||
} else if let ValidationStatus::Retransmission(full_f_cnt, d) = d {
|
||||
assert_eq!(true, tst.expected_retransmission);
|
||||
assert!(tst.expected_retransmission);
|
||||
assert_eq!(tst.expected_dev_eui, d.dev_eui,);
|
||||
assert_eq!(tst.expected_fcnt_up, full_f_cnt);
|
||||
} else if let ValidationStatus::Reset(_, d) = d {
|
||||
assert_eq!(true, tst.expected_reset);
|
||||
assert!(tst.expected_reset);
|
||||
assert_eq!(tst.expected_dev_eui, d.dev_eui,);
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ pub mod test {
|
||||
};
|
||||
|
||||
let dk = DeviceKeys {
|
||||
dev_eui: dev_eui,
|
||||
dev_eui,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -213,6 +213,6 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&dk.dev_eui).await.unwrap();
|
||||
assert_eq!(true, delete(&dk.dev_eui).await.is_err());
|
||||
assert!(delete(&dk.dev_eui).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ pub mod test {
|
||||
kv.insert("foo".into(), "bar".into());
|
||||
|
||||
let dp = DeviceProfile {
|
||||
tenant_id: tenant_id,
|
||||
tenant_id,
|
||||
name: "test device-profile".into(),
|
||||
region: CommonName::EU868,
|
||||
mac_version: MacVersion::LORAWAN_1_0_2,
|
||||
@ -501,6 +501,6 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&dp.id).await.unwrap();
|
||||
assert_eq!(true, delete(&dp.id).await.is_err());
|
||||
assert!(delete(&dp.id).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -361,6 +361,6 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&dp.id).await.unwrap();
|
||||
assert_eq!(true, delete(&dp.id).await.is_err());
|
||||
assert!(delete(&dp.id).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ pub mod test {
|
||||
// next next queue item for dev eui
|
||||
let resp = get_next_for_dev_eui(&d.dev_eui).await.unwrap();
|
||||
assert_eq!(qi, resp.0);
|
||||
assert_eq!(false, resp.1);
|
||||
assert!(!resp.1);
|
||||
|
||||
// update
|
||||
qi.is_pending = true;
|
||||
@ -244,7 +244,7 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete_item(&qi.id).await.unwrap();
|
||||
assert_eq!(true, delete_item(&qi.id).await.is_err());
|
||||
assert!(delete_item(&qi.id).await.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -269,7 +269,7 @@ pub mod test {
|
||||
|
||||
// flush
|
||||
flush_for_dev_eui(&d.dev_eui).await.unwrap();
|
||||
assert_eq!(true, delete_item(&qi.id).await.is_err());
|
||||
assert!(delete_item(&qi.id).await.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -502,7 +502,7 @@ pub mod test {
|
||||
|
||||
let gw = Gateway {
|
||||
gateway_id: id,
|
||||
tenant_id: tenant_id,
|
||||
tenant_id,
|
||||
name: "gw".into(),
|
||||
..Default::default()
|
||||
};
|
||||
@ -653,7 +653,7 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&gw.gateway_id).await.unwrap();
|
||||
assert_eq!(true, delete(&gw.gateway_id).await.is_err());
|
||||
assert!(delete(&gw.gateway_id).await.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -87,6 +87,6 @@ pub mod test {
|
||||
let resp = get_pending(&dev_eui, lrwn::CID::DevStatusReq)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(true, resp.is_none());
|
||||
assert!(resp.is_none());
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ pub async fn save(ds: &internal::PassiveRoamingDeviceSession) -> Result<()> {
|
||||
EUI64::from_slice(&ds.dev_eui)?
|
||||
};
|
||||
|
||||
let lifetime: DateTime<Utc> = match ds.lifetime.clone() {
|
||||
let lifetime: DateTime<Utc> = match ds.lifetime {
|
||||
Some(v) => v.try_into().map_err(anyhow::Error::msg)?,
|
||||
None => {
|
||||
debug!("Not saving passive-roaming device-session, no passive-roaming lifetime set");
|
||||
|
@ -254,7 +254,7 @@ pub mod test {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -262,7 +262,7 @@ pub mod test {
|
||||
|
||||
let a = application::create(application::Application {
|
||||
name: "test-app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -271,7 +271,7 @@ pub mod test {
|
||||
let _gw = gateway::create(gateway::Gateway {
|
||||
gateway_id: EUI64::from_str("0102030405060708").unwrap(),
|
||||
name: "test-gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -280,8 +280,8 @@ pub mod test {
|
||||
let _d = device::create(device::Device {
|
||||
dev_eui: EUI64::from_str("0203040506070809").unwrap(),
|
||||
name: "test-device".into(),
|
||||
application_id: a.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: a.id,
|
||||
device_profile_id: dp.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -322,8 +322,8 @@ pub mod test {
|
||||
|
||||
// User is tenant-user, this returns results.
|
||||
tenant::add_user(tenant::TenantUser {
|
||||
tenant_id: t.id.clone(),
|
||||
user_id: u.id.clone(),
|
||||
tenant_id: t.id,
|
||||
user_id: u.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
|
@ -344,7 +344,7 @@ pub mod test {
|
||||
let _guard = test::prepare().await;
|
||||
|
||||
// delete default tenant
|
||||
let _ = delete(&Uuid::from_str("52f14cd4-c6f1-4fbd-8f87-4025e1d49242").unwrap())
|
||||
delete(&Uuid::from_str("52f14cd4-c6f1-4fbd-8f87-4025e1d49242").unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@ -454,7 +454,7 @@ pub mod test {
|
||||
|
||||
// delete
|
||||
delete(&t.id).await.unwrap();
|
||||
assert_eq!(true, delete(&t.id).await.is_err());
|
||||
assert!(delete(&t.id).await.is_err());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -232,20 +232,20 @@ pub mod test {
|
||||
email_verified: true,
|
||||
..Default::default()
|
||||
};
|
||||
user.set_password_hash(&"password!", 1).unwrap();
|
||||
user.set_password_hash("password!", 1).unwrap();
|
||||
create(user).await.unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hash_password() {
|
||||
assert_eq!(true, hash_password(&"foobar", 1000).is_ok());
|
||||
assert!(hash_password("foobar", 1000).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verify_password() {
|
||||
// this is the ChirpStack Application Server default admin hash, with == removed
|
||||
// to test the compatibility betweeh the two pbkdf2 implementations.
|
||||
assert_eq!(true, verify_password(&"admin", &"$pbkdf2-sha512$i=1,l=64$l8zGKtxRESq3PA2kFhHRWA$H3lGMxOt55wjwoc+myeOoABofJY9oDpldJa7fhqdjbh700V6FLPML75UmBOt9J5VFNjAL1AvqCozA1HJM0QVGA"));
|
||||
assert!(verify_password("admin", "$pbkdf2-sha512$i=1,l=64$l8zGKtxRESq3PA2kFhHRWA$H3lGMxOt55wjwoc+myeOoABofJY9oDpldJa7fhqdjbh700V6FLPML75UmBOt9J5VFNjAL1AvqCozA1HJM0QVGA"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@ -262,23 +262,20 @@ pub mod test {
|
||||
user = update(user).await.unwrap();
|
||||
|
||||
// get by external id
|
||||
let user_get = get_by_external_id(&"external_id").await.unwrap();
|
||||
let user_get = get_by_external_id("external_id").await.unwrap();
|
||||
assert_eq!(user, user_get);
|
||||
|
||||
// get_by_email_and_pw
|
||||
assert_eq!(
|
||||
true,
|
||||
get_by_email_and_pw(&"test@example.com", &"bar")
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
let user_get = get_by_email_and_pw(&"test@example.com", &"password!")
|
||||
assert!(get_by_email_and_pw("test@example.com", "bar")
|
||||
.await
|
||||
.is_err());
|
||||
let user_get = get_by_email_and_pw("test@example.com", "password!")
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(user, user_get);
|
||||
|
||||
// delete
|
||||
delete(&user.id).await.unwrap();
|
||||
assert_eq!(true, delete(&user.id).await.is_err());
|
||||
assert!(delete(&user.id).await.is_err());
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ mod tests {
|
||||
let key = redis_key("api:stream:request".to_string());
|
||||
let srr: StreamReadReply = redis::cmd("XREAD")
|
||||
.arg("COUNT")
|
||||
.arg(1 as usize)
|
||||
.arg(1_usize)
|
||||
.arg("STREAMS")
|
||||
.arg(&key)
|
||||
.arg("0")
|
||||
|
@ -30,7 +30,7 @@ pub async fn log_uplink_for_gateways(ufl: &stream::UplinkFrameLog) -> Result<()>
|
||||
m_type: ufl.m_type,
|
||||
dev_addr: ufl.dev_addr.clone(),
|
||||
dev_eui: ufl.dev_eui.clone(),
|
||||
time: ufl.time.clone(),
|
||||
time: ufl.time,
|
||||
plaintext_f_opts: ufl.plaintext_f_opts,
|
||||
plaintext_frm_payload: ufl.plaintext_frm_payload,
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ pub type Validator = Box<dyn Fn() -> Pin<Box<dyn Future<Output = ()>>>>;
|
||||
|
||||
pub fn f_cnt_up(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -36,7 +36,7 @@ pub fn f_cnt_up(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
|
||||
pub fn n_f_cnt_down(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -47,7 +47,7 @@ pub fn n_f_cnt_down(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
|
||||
pub fn a_f_cnt_down(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -58,7 +58,7 @@ pub fn a_f_cnt_down(dev_eui: EUI64, f_cnt: u32) -> Validator {
|
||||
|
||||
pub fn tx_power_index(dev_eui: EUI64, tx_power: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -69,7 +69,7 @@ pub fn tx_power_index(dev_eui: EUI64, tx_power: u32) -> Validator {
|
||||
|
||||
pub fn nb_trans(dev_eui: EUI64, nb_trans: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -80,7 +80,7 @@ pub fn nb_trans(dev_eui: EUI64, nb_trans: u32) -> Validator {
|
||||
|
||||
pub fn enabled_uplink_channel_indices(dev_eui: EUI64, channels: Vec<u32>) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
let channels = channels.clone();
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
@ -92,7 +92,7 @@ pub fn enabled_uplink_channel_indices(dev_eui: EUI64, channels: Vec<u32>) -> Val
|
||||
|
||||
pub fn dr(dev_eui: EUI64, dr: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -103,7 +103,7 @@ pub fn dr(dev_eui: EUI64, dr: u32) -> Validator {
|
||||
|
||||
pub fn mac_command_error_count(dev_eui: EUI64, cid: lrwn::CID, count: u32) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
let ds = d.get_device_session().unwrap();
|
||||
@ -120,7 +120,7 @@ pub fn mac_command_error_count(dev_eui: EUI64, cid: lrwn::CID, count: u32) -> Va
|
||||
|
||||
pub fn uplink_adr_history(dev_eui: EUI64, uh: Vec<internal::UplinkAdrHistory>) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
let uh = uh.clone();
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
@ -361,7 +361,7 @@ pub fn downlink_frame_saved(df: internal::DownlinkFrame) -> Validator {
|
||||
pub fn device_queue_items(dev_eui: EUI64, items: Vec<device_queue::DeviceQueueItem>) -> Validator {
|
||||
Box::new(move || {
|
||||
let items = items.clone();
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let items_get = device_queue::get_for_dev_eui(&dev_eui).await.unwrap();
|
||||
|
||||
@ -394,8 +394,8 @@ pub fn device_queue_items(dev_eui: EUI64, items: Vec<device_queue::DeviceQueueIt
|
||||
|
||||
pub fn enabled_class(dev_eui: EUI64, c: DeviceClass) -> Validator {
|
||||
Box::new(move || {
|
||||
let c = c.clone();
|
||||
let dev_eui = dev_eui.clone();
|
||||
let c = c;
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let dev = device::get(&dev_eui).await.unwrap();
|
||||
assert_eq!(c, dev.enabled_class);
|
||||
@ -410,7 +410,7 @@ pub fn uplink_meta_log(um: stream::UplinkMeta) -> Validator {
|
||||
let key = redis_key("stream:meta".to_string());
|
||||
let srr: StreamReadReply = redis::cmd("XREAD")
|
||||
.arg("COUNT")
|
||||
.arg(1 as usize)
|
||||
.arg(1_usize)
|
||||
.arg("STREAMS")
|
||||
.arg(&key)
|
||||
.arg("0")
|
||||
@ -446,7 +446,7 @@ pub fn device_uplink_frame_log(uf: stream::UplinkFrameLog) -> Validator {
|
||||
let key = redis_key(format!("device:{{{}}}:stream:frame", uf.dev_eui));
|
||||
let srr: StreamReadReply = redis::cmd("XREAD")
|
||||
.arg("COUNT")
|
||||
.arg(1 as usize)
|
||||
.arg(1_usize)
|
||||
.arg("STREAMS")
|
||||
.arg(&key)
|
||||
.arg("0")
|
||||
@ -477,7 +477,7 @@ pub fn device_uplink_frame_log(uf: stream::UplinkFrameLog) -> Validator {
|
||||
|
||||
pub fn scheduler_run_after_set(dev_eui: EUI64) -> Validator {
|
||||
Box::new(move || {
|
||||
let dev_eui = dev_eui.clone();
|
||||
let dev_eui = dev_eui;
|
||||
Box::pin(async move {
|
||||
let d = device::get(&dev_eui).await.unwrap();
|
||||
assert!(d.scheduler_run_after.is_some());
|
||||
|
@ -123,7 +123,7 @@ async fn test_fns_uplink() {
|
||||
ul_meta_data: backend::ULMetaData {
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
@ -150,7 +150,7 @@ async fn test_fns_uplink() {
|
||||
.status(200);
|
||||
});
|
||||
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
// Simulate uplink
|
||||
uplink::handle_uplink(
|
||||
@ -201,7 +201,7 @@ async fn test_sns_uplink() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -209,7 +209,7 @@ async fn test_sns_uplink() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -225,8 +225,8 @@ async fn test_sns_uplink() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
dev_addr: Some(dev_addr),
|
||||
@ -324,7 +324,7 @@ async fn test_sns_uplink() {
|
||||
ul_meta_data: backend::ULMetaData {
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
@ -450,7 +450,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -458,7 +458,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -473,8 +473,8 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
dev_addr: Some(dev_addr),
|
||||
@ -563,7 +563,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
ul_meta_data: backend::ULMetaData {
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
@ -676,7 +676,7 @@ async fn test_sns_dev_not_found() {
|
||||
ul_meta_data: backend::ULMetaData {
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
|
@ -52,7 +52,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let gw_a = gateway::create(gateway::Gateway {
|
||||
name: "gateway-a".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -61,7 +61,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let gw_b = gateway::create(gateway::Gateway {
|
||||
name: "gateway-b".into(),
|
||||
tenant_id: t_b.id.clone(),
|
||||
tenant_id: t_b.id,
|
||||
gateway_id: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -70,7 +70,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -78,7 +78,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -90,8 +90,8 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -144,7 +144,7 @@ async fn test_gateway_filtering() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let tests = vec![
|
||||
Test {
|
||||
@ -256,8 +256,8 @@ async fn test_region_config_id_filtering() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -294,7 +294,7 @@ async fn test_region_config_id_filtering() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -387,7 +387,7 @@ async fn test_lorawan_10_errors() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -396,7 +396,7 @@ async fn test_lorawan_10_errors() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -404,7 +404,7 @@ async fn test_lorawan_10_errors() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -416,8 +416,8 @@ async fn test_lorawan_10_errors() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -442,7 +442,7 @@ async fn test_lorawan_10_errors() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -584,7 +584,7 @@ async fn test_lorawan_11_errors() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -593,7 +593,7 @@ async fn test_lorawan_11_errors() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -601,7 +601,7 @@ async fn test_lorawan_11_errors() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -613,8 +613,8 @@ async fn test_lorawan_11_errors() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -639,13 +639,13 @@ async fn test_lorawan_11_errors() {
|
||||
frequency: 868300000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_freq, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_freq, 0).unwrap();
|
||||
|
||||
let mut tx_info_dr = gw::UplinkTxInfo {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_dr, 3).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_dr, 3).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -738,7 +738,7 @@ async fn test_lorawan_10_skip_f_cnt() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -747,7 +747,7 @@ async fn test_lorawan_10_skip_f_cnt() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -755,7 +755,7 @@ async fn test_lorawan_10_skip_f_cnt() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -767,8 +767,8 @@ async fn test_lorawan_10_skip_f_cnt() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
skip_fcnt_check: true,
|
||||
@ -794,7 +794,7 @@ async fn test_lorawan_10_skip_f_cnt() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -932,7 +932,7 @@ async fn test_lorawan_10_device_disabled() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -941,7 +941,7 @@ async fn test_lorawan_10_device_disabled() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -949,7 +949,7 @@ async fn test_lorawan_10_device_disabled() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -961,8 +961,8 @@ async fn test_lorawan_10_device_disabled() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
is_disabled: true,
|
||||
@ -988,7 +988,7 @@ async fn test_lorawan_10_device_disabled() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -1056,7 +1056,7 @@ async fn test_lorawan_10_uplink() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -1065,7 +1065,7 @@ async fn test_lorawan_10_uplink() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -1073,7 +1073,7 @@ async fn test_lorawan_10_uplink() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -1085,8 +1085,8 @@ async fn test_lorawan_10_uplink() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -1111,13 +1111,13 @@ async fn test_lorawan_10_uplink() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut tx_info_lr_fhss = gw::UplinkTxInfo {
|
||||
frequency: 867300000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_lr_fhss, 10).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_lr_fhss, 10).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -1693,7 +1693,7 @@ async fn test_lorawan_10_end_to_end_enc() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -1702,7 +1702,7 @@ async fn test_lorawan_10_end_to_end_enc() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -1710,7 +1710,7 @@ async fn test_lorawan_10_end_to_end_enc() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -1722,8 +1722,8 @@ async fn test_lorawan_10_end_to_end_enc() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -1748,7 +1748,7 @@ async fn test_lorawan_10_end_to_end_enc() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds_sess_key_id = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -2021,7 +2021,7 @@ async fn test_lorawan_11_uplink() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -2030,7 +2030,7 @@ async fn test_lorawan_11_uplink() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -2038,7 +2038,7 @@ async fn test_lorawan_11_uplink() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -2050,8 +2050,8 @@ async fn test_lorawan_11_uplink() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -2076,13 +2076,13 @@ async fn test_lorawan_11_uplink() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut tx_info_lr_fhss = gw::UplinkTxInfo {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan110.into(),
|
||||
@ -2260,7 +2260,7 @@ async fn test_lorawan_10_rx_delay() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -2269,7 +2269,7 @@ async fn test_lorawan_10_rx_delay() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -2277,7 +2277,7 @@ async fn test_lorawan_10_rx_delay() {
|
||||
|
||||
let mut dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -2289,8 +2289,8 @@ async fn test_lorawan_10_rx_delay() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -2315,13 +2315,13 @@ async fn test_lorawan_10_rx_delay() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut tx_info_lr_fhss = gw::UplinkTxInfo {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -2705,7 +2705,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -2714,7 +2714,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -2722,7 +2722,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -2734,8 +2734,8 @@ async fn test_lorawan_10_mac_commands() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -2760,13 +2760,13 @@ async fn test_lorawan_10_mac_commands() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut tx_info_lr_fhss = gw::UplinkTxInfo {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -2793,7 +2793,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![],
|
||||
before_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.device_status_req_interval = 1;
|
||||
@ -2801,7 +2801,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.device_status_req_interval = 0;
|
||||
@ -2892,7 +2892,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
..Default::default()
|
||||
}],
|
||||
before_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.device_status_req_interval = 1;
|
||||
@ -2900,7 +2900,7 @@ async fn test_lorawan_10_mac_commands() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.device_status_req_interval = 0;
|
||||
@ -3076,7 +3076,7 @@ async fn test_lorawan_11_mac_commands() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -3085,7 +3085,7 @@ async fn test_lorawan_11_mac_commands() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -3093,7 +3093,7 @@ async fn test_lorawan_11_mac_commands() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -3105,8 +3105,8 @@ async fn test_lorawan_11_mac_commands() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -3131,7 +3131,7 @@ async fn test_lorawan_11_mac_commands() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan110.into(),
|
||||
@ -3270,7 +3270,7 @@ async fn test_lorawan_10_device_queue() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -3279,7 +3279,7 @@ async fn test_lorawan_10_device_queue() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -3287,7 +3287,7 @@ async fn test_lorawan_10_device_queue() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -3299,8 +3299,8 @@ async fn test_lorawan_10_device_queue() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -3325,7 +3325,7 @@ async fn test_lorawan_10_device_queue() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -3747,7 +3747,7 @@ async fn test_lorawan_11_device_queue() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -3756,7 +3756,7 @@ async fn test_lorawan_11_device_queue() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -3764,7 +3764,7 @@ async fn test_lorawan_11_device_queue() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -3776,8 +3776,8 @@ async fn test_lorawan_11_device_queue() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -3802,7 +3802,7 @@ async fn test_lorawan_11_device_queue() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan110.into(),
|
||||
@ -4227,7 +4227,7 @@ async fn test_lorawan_10_adr() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -4236,7 +4236,7 @@ async fn test_lorawan_10_adr() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -4244,7 +4244,7 @@ async fn test_lorawan_10_adr() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -4257,8 +4257,8 @@ async fn test_lorawan_10_adr() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -4283,7 +4283,7 @@ async fn test_lorawan_10_adr() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -5070,7 +5070,7 @@ async fn test_lorawan_10_device_status_request() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -5079,7 +5079,7 @@ async fn test_lorawan_10_device_status_request() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -5087,7 +5087,7 @@ async fn test_lorawan_10_device_status_request() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -5100,8 +5100,8 @@ async fn test_lorawan_10_device_status_request() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -5126,7 +5126,7 @@ async fn test_lorawan_10_device_status_request() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -5336,7 +5336,7 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -5345,7 +5345,7 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -5353,7 +5353,7 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -5365,8 +5365,8 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -5391,13 +5391,13 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut tx_info_lr_fhss = gw::UplinkTxInfo {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info_lr_fhss, 8).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan110.into(),
|
||||
@ -5660,7 +5660,7 @@ async fn test_lorawan_11_receive_window_selection() {
|
||||
})
|
||||
.await;
|
||||
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 5).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 5).unwrap();
|
||||
|
||||
run_test(&Test {
|
||||
name: "unconfirmed uplink with payload (rx1, payload exceeds rx2 limit)".into(),
|
||||
@ -5774,7 +5774,7 @@ async fn run_test(t: &Test) {
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
|
@ -48,7 +48,7 @@ async fn test_uplink() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -57,7 +57,7 @@ async fn test_uplink() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -65,7 +65,7 @@ async fn test_uplink() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -78,8 +78,8 @@ async fn test_uplink() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -103,7 +103,7 @@ async fn test_uplink() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let ds = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -157,8 +157,8 @@ async fn test_uplink() {
|
||||
mic: Some([241, 100, 207, 79]),
|
||||
},
|
||||
assert: vec![
|
||||
assert::f_cnt_up(dev.dev_eui.clone(), 9),
|
||||
assert::enabled_class(dev.dev_eui.clone(), DeviceClass::B),
|
||||
assert::f_cnt_up(dev.dev_eui, 9),
|
||||
assert::enabled_class(dev.dev_eui, DeviceClass::B),
|
||||
],
|
||||
})
|
||||
.await;
|
||||
@ -192,8 +192,8 @@ async fn test_uplink() {
|
||||
mic: Some([137, 180, 12, 148]),
|
||||
},
|
||||
assert: vec![
|
||||
assert::f_cnt_up(dev.dev_eui.clone(), 9),
|
||||
assert::enabled_class(dev.dev_eui.clone(), DeviceClass::A),
|
||||
assert::f_cnt_up(dev.dev_eui, 9),
|
||||
assert::enabled_class(dev.dev_eui, DeviceClass::A),
|
||||
],
|
||||
})
|
||||
.await;
|
||||
@ -213,7 +213,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -222,7 +222,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -230,7 +230,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -243,8 +243,8 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -296,7 +296,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
@ -304,8 +304,8 @@ async fn test_downlink_scheduler() {
|
||||
device_session: Some(ds.clone()),
|
||||
device_gateway_rx_info: Some(device_gateway_rx_info.clone()),
|
||||
assert: vec![
|
||||
assert::f_cnt_up(dev.dev_eui.clone(), 8),
|
||||
assert::n_f_cnt_down(dev.dev_eui.clone(), 5),
|
||||
assert::f_cnt_up(dev.dev_eui, 8),
|
||||
assert::n_f_cnt_down(dev.dev_eui, 5),
|
||||
assert::downlink_frame(gw::DownlinkFrame {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
items: vec![gw::DownlinkFrameItem {
|
||||
@ -348,7 +348,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
@ -376,14 +376,14 @@ async fn test_downlink_scheduler() {
|
||||
device_queue_items: vec![
|
||||
device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
},
|
||||
device_queue::DeviceQueueItem {
|
||||
id: Uuid::new_v4(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3, 4],
|
||||
..Default::default()
|
||||
@ -392,8 +392,8 @@ async fn test_downlink_scheduler() {
|
||||
device_session: Some(ds.clone()),
|
||||
device_gateway_rx_info: Some(device_gateway_rx_info.clone()),
|
||||
assert: vec![
|
||||
assert::f_cnt_up(dev.dev_eui.clone(), 8),
|
||||
assert::n_f_cnt_down(dev.dev_eui.clone(), 5),
|
||||
assert::f_cnt_up(dev.dev_eui, 8),
|
||||
assert::n_f_cnt_down(dev.dev_eui, 5),
|
||||
assert::downlink_frame(gw::DownlinkFrame {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
items: vec![gw::DownlinkFrameItem {
|
||||
@ -440,7 +440,7 @@ async fn run_uplink_test(t: &UplinkTest) {
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
@ -482,7 +482,7 @@ async fn run_scheduler_test(t: &DownlinkTest) {
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
@ -498,7 +498,7 @@ async fn run_scheduler_test(t: &DownlinkTest) {
|
||||
.unwrap();
|
||||
|
||||
if let Some(rx_info) = &t.device_gateway_rx_info {
|
||||
let _ = device_gateway::save_rx_info(rx_info).await.unwrap();
|
||||
device_gateway::save_rx_info(rx_info).await.unwrap();
|
||||
}
|
||||
|
||||
for qi in &t.device_queue_items {
|
||||
|
@ -38,7 +38,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -47,7 +47,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -55,7 +55,7 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_4,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -68,8 +68,8 @@ async fn test_downlink_scheduler() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::C,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([1, 2, 3, 4])),
|
||||
@ -115,7 +115,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
@ -142,7 +142,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
@ -150,7 +150,7 @@ async fn test_downlink_scheduler() {
|
||||
device_session: Some(ds.clone()),
|
||||
device_gateway_rx_info: Some(device_gateway_rx_info.clone()),
|
||||
assert: vec![
|
||||
assert::n_f_cnt_down(dev.dev_eui.clone(), 5),
|
||||
assert::n_f_cnt_down(dev.dev_eui, 5),
|
||||
assert::downlink_frame(gw::DownlinkFrame {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
items: vec![gw::DownlinkFrameItem {
|
||||
@ -189,7 +189,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
..Default::default()
|
||||
@ -216,7 +216,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![1, 2, 3],
|
||||
confirmed: true,
|
||||
@ -225,7 +225,7 @@ async fn test_downlink_scheduler() {
|
||||
device_session: Some(ds.clone()),
|
||||
device_gateway_rx_info: Some(device_gateway_rx_info.clone()),
|
||||
assert: vec![
|
||||
assert::n_f_cnt_down(dev.dev_eui.clone(), 5),
|
||||
assert::n_f_cnt_down(dev.dev_eui, 5),
|
||||
assert::downlink_frame(gw::DownlinkFrame {
|
||||
gateway_id: "0102030405060708".into(),
|
||||
items: vec![gw::DownlinkFrameItem {
|
||||
@ -277,7 +277,7 @@ async fn test_downlink_scheduler() {
|
||||
dev_eui: dev.dev_eui,
|
||||
device_queue_items: vec![device_queue::DeviceQueueItem {
|
||||
id: Uuid::nil(),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
f_port: 10,
|
||||
data: vec![0; 300],
|
||||
..Default::default()
|
||||
@ -295,7 +295,7 @@ async fn run_scheduler_test(t: &DownlinkTest) {
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
@ -311,7 +311,7 @@ async fn run_scheduler_test(t: &DownlinkTest) {
|
||||
.unwrap();
|
||||
|
||||
if let Some(rx_info) = &t.device_gateway_rx_info {
|
||||
let _ = device_gateway::save_rx_info(rx_info).await.unwrap();
|
||||
device_gateway::save_rx_info(rx_info).await.unwrap();
|
||||
}
|
||||
|
||||
for qi in &t.device_queue_items {
|
||||
|
@ -91,5 +91,5 @@ pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> {
|
||||
// setup adr
|
||||
adr::setup().await.unwrap();
|
||||
|
||||
return guard;
|
||||
guard
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ async fn test_multicast() {
|
||||
// device-profile
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "test-dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -232,7 +232,7 @@ async fn run_scheduler_test(t: &MulticastTest) {
|
||||
println!("> {}", t.name);
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
// overwrite multicast-group to deal with frame-counter increments
|
||||
multicast::update(t.multicast_group.clone()).await.unwrap();
|
||||
|
@ -33,7 +33,7 @@ async fn test_js() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gw".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -42,7 +42,7 @@ async fn test_js() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_3,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -54,7 +54,7 @@ async fn test_js() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -62,8 +62,8 @@ async fn test_js() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "dev".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -74,7 +74,7 @@ async fn test_js() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut rx_info = gw::UplinkRxInfo {
|
||||
gateway_id: gw.gateway_id.to_string(),
|
||||
@ -95,7 +95,7 @@ async fn test_js() {
|
||||
},
|
||||
payload: lrwn::Payload::JoinRequest(lrwn::JoinRequestPayload {
|
||||
join_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
dev_nonce: 1,
|
||||
}),
|
||||
mic: Some([1, 2, 3, 4]),
|
||||
@ -153,7 +153,7 @@ async fn test_js() {
|
||||
},
|
||||
assert: vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan103.into(),
|
||||
@ -220,7 +220,7 @@ async fn test_js() {
|
||||
},
|
||||
assert: vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan103.into(),
|
||||
@ -290,7 +290,7 @@ async fn test_js() {
|
||||
},
|
||||
assert: vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan103.into(),
|
||||
@ -365,7 +365,7 @@ async fn run_test(t: &Test) {
|
||||
joinserver::setup().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
|
@ -154,7 +154,7 @@ async fn test_fns() {
|
||||
dev_eui: vec![8, 7, 6, 5, 4, 3, 2, 1],
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
@ -189,7 +189,7 @@ async fn test_fns() {
|
||||
.status(200);
|
||||
});
|
||||
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::mock::reset().await;
|
||||
|
||||
// Simulate uplink
|
||||
@ -281,7 +281,7 @@ async fn test_sns() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -289,7 +289,7 @@ async fn test_sns() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -302,8 +302,8 @@ async fn test_sns() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
..Default::default()
|
||||
@ -312,7 +312,7 @@ async fn test_sns() {
|
||||
.unwrap();
|
||||
|
||||
let dk = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
|
||||
dev_nonces: vec![],
|
||||
..Default::default()
|
||||
@ -368,7 +368,7 @@ async fn test_sns() {
|
||||
dev_eui: dev.dev_eui.to_vec(),
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
@ -467,7 +467,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -475,7 +475,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -487,8 +487,8 @@ async fn test_sns_roaming_not_allowed() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
..Default::default()
|
||||
@ -497,7 +497,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
.unwrap();
|
||||
|
||||
let dk = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
|
||||
dev_nonces: vec![],
|
||||
..Default::default()
|
||||
@ -553,7 +553,7 @@ async fn test_sns_roaming_not_allowed() {
|
||||
dev_eui: dev.dev_eui.to_vec(),
|
||||
ul_freq: Some(868.1),
|
||||
data_rate: Some(0),
|
||||
recv_time: recv_time,
|
||||
recv_time,
|
||||
rf_region: "EU868".to_string(),
|
||||
gw_cnt: Some(1),
|
||||
gw_info: roaming::rx_info_to_gw_info(&[rx_info.clone()]).unwrap(),
|
||||
|
@ -51,7 +51,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let gw_a = gateway::create(gateway::Gateway {
|
||||
name: "gateway-a".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -60,7 +60,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let gw_b = gateway::create(gateway::Gateway {
|
||||
name: "gateway-b".into(),
|
||||
tenant_id: t_b.id.clone(),
|
||||
tenant_id: t_b.id,
|
||||
gateway_id: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -69,7 +69,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -77,7 +77,7 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t_a.id.clone(),
|
||||
tenant_id: t_a.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -89,8 +89,8 @@ async fn test_gateway_filtering() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
..Default::default()
|
||||
@ -99,7 +99,7 @@ async fn test_gateway_filtering() {
|
||||
.unwrap();
|
||||
|
||||
let dk = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
|
||||
dev_nonces: vec![Some(258)],
|
||||
..Default::default()
|
||||
@ -135,7 +135,7 @@ async fn test_gateway_filtering() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut jr_pl = lrwn::PhyPayload {
|
||||
mhdr: lrwn::MHDR {
|
||||
@ -144,7 +144,7 @@ async fn test_gateway_filtering() {
|
||||
},
|
||||
payload: lrwn::Payload::JoinRequest(lrwn::JoinRequestPayload {
|
||||
join_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
dev_nonce: 258,
|
||||
}),
|
||||
mic: None,
|
||||
@ -156,7 +156,7 @@ async fn test_gateway_filtering() {
|
||||
name: "private gateway of same tenant".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
})
|
||||
@ -167,7 +167,7 @@ async fn test_gateway_filtering() {
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: vec![],
|
||||
assert: vec![assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -200,7 +200,7 @@ async fn test_gateway_filtering() {
|
||||
name: "private gateway other tenant".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
})
|
||||
@ -210,7 +210,7 @@ async fn test_gateway_filtering() {
|
||||
tx_info: tx_info.clone(),
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: vec![],
|
||||
assert: vec![assert::no_device_session(dev.dev_eui.clone())],
|
||||
assert: vec![assert::no_device_session(dev.dev_eui)],
|
||||
},
|
||||
];
|
||||
|
||||
@ -232,7 +232,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -241,7 +241,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -249,7 +249,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -261,8 +261,8 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
..Default::default()
|
||||
@ -271,7 +271,7 @@ async fn test_lorawan_10() {
|
||||
.unwrap();
|
||||
|
||||
let dk = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
|
||||
dev_nonces: vec![Some(258)],
|
||||
..Default::default()
|
||||
@ -295,7 +295,7 @@ async fn test_lorawan_10() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut jr_pl = lrwn::PhyPayload {
|
||||
mhdr: lrwn::MHDR {
|
||||
@ -304,7 +304,7 @@ async fn test_lorawan_10() {
|
||||
},
|
||||
payload: lrwn::Payload::JoinRequest(lrwn::JoinRequestPayload {
|
||||
join_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
dev_nonce: 258,
|
||||
}),
|
||||
mic: None,
|
||||
@ -391,7 +391,7 @@ async fn test_lorawan_10() {
|
||||
name: "join-request accepted".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
})
|
||||
@ -407,7 +407,7 @@ async fn test_lorawan_10() {
|
||||
EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
),
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -563,8 +563,8 @@ async fn test_lorawan_10() {
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
assert::enabled_class(dev.dev_eui.clone(), DeviceClass::A),
|
||||
assert::device_queue_items(dev.dev_eui.clone(), vec![]),
|
||||
assert::enabled_class(dev.dev_eui, DeviceClass::A),
|
||||
assert::device_queue_items(dev.dev_eui, vec![]),
|
||||
assert::uplink_meta_log(stream::UplinkMeta {
|
||||
dev_eui: dev.dev_eui.to_string(),
|
||||
tx_info: Some(tx_info.clone()),
|
||||
@ -579,7 +579,7 @@ async fn test_lorawan_10() {
|
||||
name: "join-request accepted + skip fcnt check".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
|
||||
@ -589,7 +589,7 @@ async fn test_lorawan_10() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
let mut dev = device::get(&dev_eui).await.unwrap();
|
||||
dev.skip_fcnt_check = false;
|
||||
@ -601,7 +601,7 @@ async fn test_lorawan_10() {
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: vec![],
|
||||
assert: vec![assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -635,7 +635,7 @@ async fn test_lorawan_10() {
|
||||
name: "join-request accepted + cflist".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
})
|
||||
@ -647,7 +647,7 @@ async fn test_lorawan_10() {
|
||||
extra_uplink_channels: vec![867100000, 867300000, 867500000, 867700000, 867900000],
|
||||
assert: vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
@ -787,8 +787,8 @@ async fn test_lorawan_10() {
|
||||
name: "join-request accepted + class-b supported".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dp_id = dp.id.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
|
||||
@ -798,7 +798,7 @@ async fn test_lorawan_10() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.supports_class_b = false;
|
||||
@ -809,14 +809,14 @@ async fn test_lorawan_10() {
|
||||
tx_info: tx_info.clone(),
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: Vec::new(),
|
||||
assert: vec![assert::enabled_class(dev.dev_eui.clone(), DeviceClass::A)],
|
||||
assert: vec![assert::enabled_class(dev.dev_eui, DeviceClass::A)],
|
||||
},
|
||||
Test {
|
||||
name: "join-request accepted + class-c supported".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dp_id = dp.id.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
|
||||
@ -826,7 +826,7 @@ async fn test_lorawan_10() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.supports_class_c = false;
|
||||
@ -837,13 +837,13 @@ async fn test_lorawan_10() {
|
||||
tx_info: tx_info.clone(),
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: Vec::new(),
|
||||
assert: vec![assert::enabled_class(dev.dev_eui.clone(), DeviceClass::C)],
|
||||
assert: vec![assert::enabled_class(dev.dev_eui, DeviceClass::C)],
|
||||
},
|
||||
Test {
|
||||
name: "device disabled".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
|
||||
@ -853,7 +853,7 @@ async fn test_lorawan_10() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
let mut dev = device::get(&dev_eui).await.unwrap();
|
||||
dev.is_disabled = false;
|
||||
@ -887,7 +887,7 @@ async fn test_lorawan_11() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -896,7 +896,7 @@ async fn test_lorawan_11() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -904,7 +904,7 @@ async fn test_lorawan_11() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_1_0,
|
||||
reg_params_revision: lrwn::region::Revision::RP002_1_0_3,
|
||||
@ -916,8 +916,8 @@ async fn test_lorawan_11() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([2, 2, 3, 4, 5, 6, 7, 8]),
|
||||
enabled_class: DeviceClass::B,
|
||||
..Default::default()
|
||||
@ -926,7 +926,7 @@ async fn test_lorawan_11() {
|
||||
.unwrap();
|
||||
|
||||
let dk = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]),
|
||||
app_key: AES128Key::from_bytes([16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
|
||||
dev_nonces: vec![Some(258)],
|
||||
@ -951,7 +951,7 @@ async fn test_lorawan_11() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut jr_pl = lrwn::PhyPayload {
|
||||
mhdr: lrwn::MHDR {
|
||||
@ -960,7 +960,7 @@ async fn test_lorawan_11() {
|
||||
},
|
||||
payload: lrwn::Payload::JoinRequest(lrwn::JoinRequestPayload {
|
||||
join_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
dev_nonce: 258,
|
||||
}),
|
||||
mic: None,
|
||||
@ -1014,7 +1014,7 @@ async fn test_lorawan_11() {
|
||||
name: "join-request accepted".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
})
|
||||
@ -1026,7 +1026,7 @@ async fn test_lorawan_11() {
|
||||
extra_uplink_channels: vec![],
|
||||
assert: vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan110.into(),
|
||||
@ -1185,16 +1185,16 @@ async fn test_lorawan_11() {
|
||||
}),
|
||||
..Default::default()
|
||||
}),
|
||||
assert::enabled_class(dev.dev_eui.clone(), DeviceClass::A),
|
||||
assert::device_queue_items(dev.dev_eui.clone(), vec![]),
|
||||
assert::enabled_class(dev.dev_eui, DeviceClass::A),
|
||||
assert::device_queue_items(dev.dev_eui, vec![]),
|
||||
],
|
||||
},
|
||||
Test {
|
||||
name: "join-request accepted + class-c supported".into(),
|
||||
dev_eui: dev.dev_eui,
|
||||
before_func: Some(Box::new(move || {
|
||||
let dev_eui = dev.dev_eui.clone();
|
||||
let dp_id = dp.id.clone();
|
||||
let dev_eui = dev.dev_eui;
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
device_keys::test::reset_nonces(&dev_eui).await.unwrap();
|
||||
|
||||
@ -1204,7 +1204,7 @@ async fn test_lorawan_11() {
|
||||
})
|
||||
})),
|
||||
after_func: Some(Box::new(move || {
|
||||
let dp_id = dp.id.clone();
|
||||
let dp_id = dp.id;
|
||||
Box::pin(async move {
|
||||
let mut dp = device_profile::get(&dp_id).await.unwrap();
|
||||
dp.supports_class_c = false;
|
||||
@ -1215,7 +1215,7 @@ async fn test_lorawan_11() {
|
||||
tx_info: tx_info.clone(),
|
||||
phy_payload: jr_pl.clone(),
|
||||
extra_uplink_channels: Vec::new(),
|
||||
assert: vec![assert::enabled_class(dev.dev_eui.clone(), DeviceClass::A)],
|
||||
assert: vec![assert::enabled_class(dev.dev_eui, DeviceClass::A)],
|
||||
},
|
||||
];
|
||||
|
||||
@ -1242,7 +1242,7 @@ async fn run_test(t: &Test) {
|
||||
region::setup().unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
|
@ -121,7 +121,7 @@ async fn test_lorawan_10() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 5).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 5).unwrap();
|
||||
|
||||
let ds_relay = internal::DeviceSession {
|
||||
mac_version: common::MacVersion::Lorawan104.into(),
|
||||
@ -769,7 +769,7 @@ async fn run_test(t: &Test) {
|
||||
reset_redis().await.unwrap();
|
||||
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
|
@ -16,7 +16,7 @@ use lrwn::{AES128Key, DevAddr, EUI64};
|
||||
async fn test_lorawan_10() {
|
||||
let _guard = test::prepare().await;
|
||||
integration::set_mock().await;
|
||||
gateway_backend::set_backend(&"eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
gateway_backend::set_backend("eu868", Box::new(gateway_backend::mock::Backend {})).await;
|
||||
|
||||
integration::mock::reset().await;
|
||||
gateway_backend::mock::reset().await;
|
||||
@ -31,7 +31,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let gw = gateway::create(gateway::Gateway {
|
||||
name: "gateway".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -40,7 +40,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let app = application::create(application::Application {
|
||||
name: "app".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
@ -48,7 +48,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dp = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -60,7 +60,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dp_relay = device_profile::create(device_profile::DeviceProfile {
|
||||
name: "dp".into(),
|
||||
tenant_id: t.id.clone(),
|
||||
tenant_id: t.id,
|
||||
region: lrwn::region::CommonName::EU868,
|
||||
mac_version: lrwn::region::MacVersion::LORAWAN_1_0_2,
|
||||
reg_params_revision: lrwn::region::Revision::A,
|
||||
@ -73,8 +73,8 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dev = device::create(device::Device {
|
||||
name: "device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp.id,
|
||||
dev_eui: EUI64::from_be_bytes([1, 1, 1, 1, 1, 1, 1, 1]),
|
||||
enabled_class: DeviceClass::A,
|
||||
..Default::default()
|
||||
@ -83,7 +83,7 @@ async fn test_lorawan_10() {
|
||||
.unwrap();
|
||||
|
||||
let dk_dev = device_keys::create(device_keys::DeviceKeys {
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
nwk_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
..Default::default()
|
||||
})
|
||||
@ -92,8 +92,8 @@ async fn test_lorawan_10() {
|
||||
|
||||
let dev_relay = device::create(device::Device {
|
||||
name: "relay-device".into(),
|
||||
application_id: app.id.clone(),
|
||||
device_profile_id: dp_relay.id.clone(),
|
||||
application_id: app.id,
|
||||
device_profile_id: dp_relay.id,
|
||||
dev_eui: EUI64::from_be_bytes([1, 1, 1, 1, 1, 1, 1, 2]),
|
||||
enabled_class: DeviceClass::A,
|
||||
dev_addr: Some(DevAddr::from_be_bytes([4, 3, 2, 1])),
|
||||
@ -133,7 +133,7 @@ async fn test_lorawan_10() {
|
||||
frequency: 868100000,
|
||||
..Default::default()
|
||||
};
|
||||
uplink::helpers::set_uplink_modulation(&"eu868", &mut tx_info, 0).unwrap();
|
||||
uplink::helpers::set_uplink_modulation("eu868", &mut tx_info, 0).unwrap();
|
||||
|
||||
let mut jr_pl = lrwn::PhyPayload {
|
||||
mhdr: lrwn::MHDR {
|
||||
@ -142,7 +142,7 @@ async fn test_lorawan_10() {
|
||||
},
|
||||
payload: lrwn::Payload::JoinRequest(lrwn::JoinRequestPayload {
|
||||
join_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]),
|
||||
dev_eui: dev.dev_eui.clone(),
|
||||
dev_eui: dev.dev_eui,
|
||||
dev_nonce: 1,
|
||||
}),
|
||||
mic: None,
|
||||
@ -265,7 +265,7 @@ async fn test_lorawan_10() {
|
||||
|
||||
let assertions = vec![
|
||||
assert::device_session(
|
||||
dev.dev_eui.clone(),
|
||||
dev.dev_eui,
|
||||
internal::DeviceSession {
|
||||
dev_addr: vec![1, 2, 3, 4],
|
||||
mac_version: common::MacVersion::Lorawan102.into(),
|
||||
|
@ -1029,11 +1029,9 @@ impl Data {
|
||||
match v {
|
||||
pbjson_types::value::Kind::NumberValue(v) => {
|
||||
let record = metrics::Record {
|
||||
time: DateTime::<Utc>::try_from(
|
||||
up_event.time.as_ref().unwrap().clone(),
|
||||
)
|
||||
.map_err(anyhow::Error::msg)?
|
||||
.with_timezone(&Local),
|
||||
time: DateTime::<Utc>::try_from(*up_event.time.as_ref().unwrap())
|
||||
.map_err(anyhow::Error::msg)?
|
||||
.with_timezone(&Local),
|
||||
kind: match dp_m.kind {
|
||||
fields::MeasurementKind::COUNTER => metrics::Kind::COUNTER,
|
||||
fields::MeasurementKind::ABSOLUTE => metrics::Kind::ABSOLUTE,
|
||||
|
@ -69,7 +69,7 @@ pub fn get_rx_timestamp(rx_info: &[gw::UplinkRxInfo]) -> SystemTime {
|
||||
// Then search for time.
|
||||
for rxi in rx_info {
|
||||
if let Some(ts) = &rxi.gw_time {
|
||||
let ts: Result<DateTime<Utc>> = ts.clone().try_into().map_err(anyhow::Error::msg);
|
||||
let ts: Result<DateTime<Utc>> = (*ts).try_into().map_err(anyhow::Error::msg);
|
||||
if let Ok(ts) = ts {
|
||||
return ts.into();
|
||||
}
|
||||
@ -96,7 +96,7 @@ pub fn get_rx_timestamp_chrono(rx_info: &[gw::UplinkRxInfo]) -> DateTime<Utc> {
|
||||
// Then search for time.
|
||||
for rxi in rx_info {
|
||||
if let Some(ts) = &rxi.gw_time {
|
||||
let ts: Result<DateTime<Utc>> = ts.clone().try_into().map_err(anyhow::Error::msg);
|
||||
let ts: Result<DateTime<Utc>> = (*ts).try_into().map_err(anyhow::Error::msg);
|
||||
if let Ok(ts) = ts {
|
||||
return ts;
|
||||
}
|
||||
@ -140,9 +140,7 @@ pub fn get_start_location(rx_info: &[gw::UplinkRxInfo]) -> Option<common::Locati
|
||||
.cloned()
|
||||
.collect();
|
||||
with_loc.sort_by(|a, b| a.snr.partial_cmp(&b.snr).unwrap());
|
||||
with_loc
|
||||
.first()
|
||||
.map(|i| i.location.as_ref().unwrap().clone())
|
||||
with_loc.first().map(|i| *i.location.as_ref().unwrap())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -75,8 +75,7 @@ impl MeshHeartbeat {
|
||||
let border_gw = gateway::get(&self.gateway_id).await?;
|
||||
|
||||
let ts: DateTime<Utc> = match &self.mesh_stats.time {
|
||||
Some(v) => v
|
||||
.clone()
|
||||
Some(v) => (*v)
|
||||
.try_into()
|
||||
.map_err(|e| anyhow!("Convert time error: {}", e))?,
|
||||
None => {
|
||||
|
@ -102,9 +102,7 @@ impl Stats {
|
||||
|
||||
let mut m = metrics::Record {
|
||||
time: match &self.stats.time {
|
||||
Some(v) => DateTime::try_from(v.clone())
|
||||
.map_err(anyhow::Error::msg)?
|
||||
.into(),
|
||||
Some(v) => DateTime::try_from(*v).map_err(anyhow::Error::msg)?.into(),
|
||||
None => Local::now(),
|
||||
},
|
||||
kind: metrics::Kind::ABSOLUTE,
|
||||
@ -179,15 +177,12 @@ impl Stats {
|
||||
|
||||
let window: Duration = duty_cycle_stats
|
||||
.window
|
||||
.clone()
|
||||
.map(|v| v.try_into().unwrap_or_default())
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut m = metrics::Record {
|
||||
time: match &self.stats.time {
|
||||
Some(v) => DateTime::try_from(v.clone())
|
||||
.map_err(anyhow::Error::msg)?
|
||||
.into(),
|
||||
Some(v) => DateTime::try_from(*v).map_err(anyhow::Error::msg)?.into(),
|
||||
None => Local::now(),
|
||||
},
|
||||
kind: metrics::Kind::COUNTER,
|
||||
@ -197,12 +192,10 @@ impl Stats {
|
||||
for b in &duty_cycle_stats.bands {
|
||||
let load_max: Duration = b
|
||||
.load_max
|
||||
.clone()
|
||||
.map(|d| d.try_into().unwrap_or_default())
|
||||
.unwrap_or_default();
|
||||
let load_tracked: Duration = b
|
||||
.load_tracked
|
||||
.clone()
|
||||
.map(|d| d.try_into().unwrap_or_default())
|
||||
.unwrap_or_default();
|
||||
|
||||
|
@ -373,7 +373,7 @@ mod tests {
|
||||
];
|
||||
|
||||
for tst in tests {
|
||||
let mut devaddr = tst.devaddr.clone();
|
||||
let mut devaddr = tst.devaddr;
|
||||
devaddr.set_dev_addr_prefix(tst.netid.dev_addr_prefix());
|
||||
assert_eq!(tst.expected_devaddr, devaddr);
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_eui64_from_str() {
|
||||
let eui = EUI64::from_be_bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]);
|
||||
assert_eq!(eui, EUI64::from_str(&"0102030405060708").unwrap());
|
||||
assert_eq!(eui, EUI64::from_str("0102030405060708").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2649,7 +2649,7 @@ mod test {
|
||||
uplink: false,
|
||||
command: MACCommand::NewChannelReq(NewChannelReqPayload {
|
||||
ch_index: 3,
|
||||
freq: 2410_000_000,
|
||||
freq: 2_410_000_000,
|
||||
max_dr: 5,
|
||||
min_dr: 0,
|
||||
}),
|
||||
|
@ -464,7 +464,7 @@ mod tests {
|
||||
// before it can be decoded
|
||||
assert_eq!(
|
||||
Payload::Raw(vec![0x01, 0x02, 0x03]),
|
||||
Payload::from_slice(MType::JoinAccept, &vec![0x01, 0x02, 0x03]).unwrap()
|
||||
Payload::from_slice(MType::JoinAccept, &[0x01, 0x02, 0x03]).unwrap()
|
||||
);
|
||||
|
||||
// test decoding the (decrypted) join-accept payload
|
||||
|
@ -1000,8 +1000,7 @@ pub mod test {
|
||||
use crate::*;
|
||||
|
||||
fn config() -> Configuration {
|
||||
let c = Configuration::new(CommonName::AS923, true, true);
|
||||
c
|
||||
Configuration::new(CommonName::AS923, true, true)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1219,8 +1219,7 @@ pub mod test {
|
||||
use crate::*;
|
||||
|
||||
fn config_full() -> Configuration {
|
||||
let c = Configuration::new(false, false);
|
||||
c
|
||||
Configuration::new(false, false)
|
||||
}
|
||||
|
||||
fn config_chan_8_15() -> Configuration {
|
||||
@ -1340,7 +1339,7 @@ pub mod test {
|
||||
#[test]
|
||||
fn test_cf_list() {
|
||||
let c = config_chan_8_15();
|
||||
assert_eq!(true, c.get_cf_list(MacVersion::LORAWAN_1_0_2).is_none());
|
||||
assert!(c.get_cf_list(MacVersion::LORAWAN_1_0_2).is_none());
|
||||
|
||||
let lw_11_cf_list = c.get_cf_list(MacVersion::LORAWAN_1_1_0).unwrap();
|
||||
assert_eq!(
|
||||
|
@ -588,8 +588,7 @@ mod tests {
|
||||
use crate::*;
|
||||
|
||||
fn config_full() -> Configuration {
|
||||
let c = Configuration::new(false);
|
||||
c
|
||||
Configuration::new(false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -566,8 +566,7 @@ mod test {
|
||||
use crate::*;
|
||||
|
||||
fn config() -> Configuration {
|
||||
let c = Configuration::new(false);
|
||||
c
|
||||
Configuration::new(false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -872,7 +872,7 @@ mod tests {
|
||||
ch_mask_cntl: 0,
|
||||
nb_rep: 0,
|
||||
},
|
||||
ch_mask: ChMask::from_slice(&vec![true, true, true]).unwrap(),
|
||||
ch_mask: ChMask::from_slice(&[true, true, true]).unwrap(),
|
||||
}],
|
||||
},
|
||||
// Base channels are active
|
||||
@ -905,7 +905,7 @@ mod tests {
|
||||
ch_mask_cntl: 0,
|
||||
nb_rep: 0,
|
||||
},
|
||||
ch_mask: ChMask::from_slice(&vec![true, true, true]).unwrap(),
|
||||
ch_mask: ChMask::from_slice(&[true, true, true]).unwrap(),
|
||||
}],
|
||||
},
|
||||
];
|
||||
@ -934,7 +934,7 @@ mod tests {
|
||||
#[test]
|
||||
fn get_uplink_channel_index() {
|
||||
let c = config_with_user_channels();
|
||||
let tests = vec![
|
||||
let tests = [
|
||||
(false, 868100000),
|
||||
(false, 868300000),
|
||||
(false, 868500000),
|
||||
@ -953,7 +953,7 @@ mod tests {
|
||||
#[test]
|
||||
fn get_uplink_channel_index_for_freq_dr() {
|
||||
let c = config_with_user_channels();
|
||||
let tests = vec![
|
||||
let tests = [
|
||||
(3, 868100000),
|
||||
(3, 868300000),
|
||||
(3, 868500000),
|
||||
@ -978,8 +978,8 @@ mod tests {
|
||||
let c = config_with_user_channels();
|
||||
assert_eq!(
|
||||
CFList::Channels(
|
||||
CFListChannels::from_slice(&vec![
|
||||
867100000, 867300000, 867500000, 867700000, 867900000,
|
||||
CFListChannels::from_slice(&[
|
||||
867100000, 867300000, 867500000, 867700000, 867900000
|
||||
])
|
||||
.unwrap()
|
||||
),
|
||||
|
@ -907,8 +907,7 @@ pub mod test {
|
||||
use crate::*;
|
||||
|
||||
fn config_full() -> Configuration {
|
||||
let c = Configuration::new(false);
|
||||
c
|
||||
Configuration::new(false)
|
||||
}
|
||||
|
||||
fn config_chan_8_15() -> Configuration {
|
||||
@ -1030,7 +1029,7 @@ pub mod test {
|
||||
#[test]
|
||||
fn test_cf_list() {
|
||||
let c = config_chan_8_15();
|
||||
assert_eq!(true, c.get_cf_list(MacVersion::LORAWAN_1_0_2).is_none());
|
||||
assert!(c.get_cf_list(MacVersion::LORAWAN_1_0_2).is_none());
|
||||
|
||||
let lw_11_cf_list = c.get_cf_list(MacVersion::LORAWAN_1_1_0).unwrap();
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user