Revert "Revert to 2018 edition to support older Rust versions."

This reverts commit ad49c29592.

Some dependencies require 2021 edition.
This commit is contained in:
Orne Brocaar 2022-04-11 15:08:07 +01:00
parent 58b74dbf1f
commit a9a3c35797
17 changed files with 211 additions and 278 deletions

3
.gitignore vendored
View File

@ -17,6 +17,3 @@
# API
/api/js/node_modules
# Bitbake recipes
*.bb

View File

@ -1,10 +1,9 @@
[package]
name = "chirpstack"
description = "ChirpStack is an open-source LoRaWAN(TM) Network Server"
repository="https://github.com/chirpstack/chirpstack/"
version = "4.0.0-test.1"
authors = ["Orne Brocaar <info@brocaar.com>"]
edition = "2018"
edition = "2021"
publish = false
license = "MIT"

View File

@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::str::FromStr;
use std::time::SystemTime;

View File

@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::str::FromStr;
use std::time::SystemTime;

View File

@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::ops::Add;
use std::time::{SystemTime, UNIX_EPOCH};

View File

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::convert::TryInto;
use std::sync::Arc;
use std::time::Duration;

View File

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::convert::TryFrom;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use anyhow::Result;

View File

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::convert::TryFrom;
use std::time::Duration;
use anyhow::Result;

View File

@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::io::Cursor;
use anyhow::{Context, Result};

View File

@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::fmt;
use std::time::Duration;

View File

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::convert::TryInto;
use std::str::FromStr;
use anyhow::{Context, Result};

View File

@ -341,7 +341,6 @@ pub async fn enqueue(
qi: MulticastGroupQueueItem,
gateway_ids: &[EUI64],
) -> Result<(Vec<Uuid>, u32), Error> {
let mg_id = qi.multicast_group_id;
let (ids, f_cnt) = task::spawn_blocking({
let gateway_ids = gateway_ids.to_vec();
move || -> Result<(Vec<Uuid>, u32), Error> {
@ -504,7 +503,7 @@ pub async fn enqueue(
}
})
.await??;
info!(multicast_group_id = %mg_id, f_cnt = f_cnt, "Multicast-group queue item created");
info!(multicast_group_id = %qi.multicast_group_id, f_cnt = f_cnt, "Multicast-group queue item created");
Ok((ids, f_cnt))
}

View File

@ -1421,25 +1421,21 @@ async fn test_lorawan_10_uplink() {
Test {
name: "uplink of class-c device sets lock".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
device_profile::update(dp.clone()).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
device_profile::update(dp.clone()).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
device_profile::update(dp).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
device_profile::update(dp).await.unwrap();
})
})),
device_session: Some(ds.clone()),
tx_info: tx_info.clone(),
@ -2016,25 +2012,21 @@ async fn test_lorawan_10_mac_commands() {
Test {
name: "unconfirmed uplink + device-status request downlink (FOpts)".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 1;
device_profile::update(dp.clone()).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 1;
device_profile::update(dp.clone()).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 0;
device_profile::update(dp.clone()).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 0;
device_profile::update(dp.clone()).await.unwrap();
})
})),
device_session: Some(ds.clone()),
tx_info: tx_info.clone(),
@ -2118,25 +2110,21 @@ async fn test_lorawan_10_mac_commands() {
data: vec![1, 2, 3, 4],
..Default::default()
}],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 1;
device_profile::update(dp.clone()).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 1;
device_profile::update(dp.clone()).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 0;
device_profile::update(dp.clone()).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.device_status_req_interval = 0;
device_profile::update(dp.clone()).await.unwrap();
})
})),
device_session: Some(ds.clone()),
tx_info: tx_info.clone(),
@ -3682,32 +3670,30 @@ async fn test_lorawan_10_adr() {
Test {
name: "acknowledgement of pending adr request".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 3,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 1,
},
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 3,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 1,
},
)]),
)
.await
.unwrap();
})
}
},
)]),
)
.await
.unwrap();
})
})),
after_func: None,
device_session: Some(ds.clone()),
@ -3751,32 +3737,30 @@ async fn test_lorawan_10_adr() {
Test {
name: "negative acknowledgement of pending adr request".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 3,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 1,
},
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 3,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 1,
},
)]),
)
.await
.unwrap();
})
}
},
)]),
)
.await
.unwrap();
})
})),
after_func: None,
device_session: Some(ds.clone()),
@ -3994,32 +3978,30 @@ async fn test_lorawan_10_adr() {
Test {
name: "new channel re-configuration ack-ed".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 1,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 1,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
)]),
)
.await
.unwrap();
})
}
},
)]),
)
.await
.unwrap();
})
})),
after_func: None,
device_session: Some(ds_7chan.clone()),
@ -4061,32 +4043,30 @@ async fn test_lorawan_10_adr() {
Test {
name: "new channel re-configuration not ack-ed".into(),
device_queue_items: vec![],
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 1,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
Box::pin(async move {
mac_command::set_pending(
&dev_eui,
lrwn::CID::LinkADRReq,
&lrwn::MACCommandSet::new(vec![lrwn::MACCommand::LinkADRReq(
lrwn::LinkADRReqPayload {
dr: 0,
tx_power: 1,
ch_mask: lrwn::ChMask::new([
true, true, true, false, false, false, false, false, false,
false, false, false, false, false, false, false,
]),
redundancy: lrwn::Redundancy {
ch_mask_cntl: 0,
nb_rep: 0,
},
)]),
)
.await
.unwrap();
})
}
},
)]),
)
.await
.unwrap();
})
})),
after_func: None,
device_session: Some(ds_7chan.clone()),

View File

@ -150,13 +150,11 @@ async fn test_gateway_filtering() {
let tests = vec![
Test {
name: "private gateway of same tenant".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
}
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
})),
after_func: None,
rx_info: rx_info_a.clone(),
@ -196,13 +194,11 @@ async fn test_gateway_filtering() {
},
Test {
name: "private gateway other tenant".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
}
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
})),
after_func: None,
rx_info: rx_info_b.clone(),
@ -387,13 +383,11 @@ async fn test_lorawan_10() {
},
Test {
name: "join-request accepted".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
}
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
})),
after_func: None,
rx_info: rx_info.clone(),
@ -573,27 +567,23 @@ async fn test_lorawan_10() {
},
Test {
name: "join-request accepted + skip fcnt check".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
let mut dev = device::get(&dev_eui).await.unwrap();
dev.skip_fcnt_check = true;
let _ = device::update(dev).await.unwrap();
})
}
let mut dev = device::get(&dev_eui).await.unwrap();
dev.skip_fcnt_check = true;
let _ = device::update(dev).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
let mut dev = device::get(&dev_eui).await.unwrap();
dev.skip_fcnt_check = false;
let _ = device::update(dev).await.unwrap();
})
}
Box::pin(async move {
let mut dev = device::get(&dev_eui).await.unwrap();
dev.skip_fcnt_check = false;
let _ = device::update(dev).await.unwrap();
})
})),
rx_info: rx_info.clone(),
tx_info: tx_info.clone(),
@ -633,13 +623,11 @@ async fn test_lorawan_10() {
},
Test {
name: "join-request accepted + cflist".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
}
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
})),
after_func: None,
rx_info: rx_info.clone(),
@ -787,28 +775,24 @@ async fn test_lorawan_10() {
},
Test {
name: "join-request accepted + class-b supported".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_b = true;
let _ = device_profile::update(dp).await.unwrap();
})
}
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_b = true;
let _ = device_profile::update(dp).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_b = false;
let _ = device_profile::update(dp).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_b = false;
let _ = device_profile::update(dp).await.unwrap();
})
})),
rx_info: rx_info.clone(),
tx_info: tx_info.clone(),
@ -818,28 +802,24 @@ async fn test_lorawan_10() {
},
Test {
name: "join-request accepted + class-c supported".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
let _ = device_profile::update(dp).await.unwrap();
})
}
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
let _ = device_profile::update(dp).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
let _ = device_profile::update(dp).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
let _ = device_profile::update(dp).await.unwrap();
})
})),
rx_info: rx_info.clone(),
tx_info: tx_info.clone(),
@ -849,27 +829,23 @@ async fn test_lorawan_10() {
},
Test {
name: "device disabled".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
let mut dev = device::get(&dev_eui).await.unwrap();
dev.is_disabled = true;
let _ = device::update(dev).await.unwrap();
})
}
let mut dev = device::get(&dev_eui).await.unwrap();
dev.is_disabled = true;
let _ = device::update(dev).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
let mut dev = device::get(&dev_eui).await.unwrap();
dev.is_disabled = false;
let _ = device::update(dev).await.unwrap();
})
}
Box::pin(async move {
let mut dev = device::get(&dev_eui).await.unwrap();
dev.is_disabled = false;
let _ = device::update(dev).await.unwrap();
})
})),
rx_info: rx_info.clone(),
tx_info: tx_info.clone(),
@ -1022,13 +998,11 @@ async fn test_lorawan_11() {
},
Test {
name: "join-request accepted".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
}
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
})
})),
after_func: None,
rx_info: rx_info.clone(),
@ -1203,28 +1177,24 @@ async fn test_lorawan_11() {
},
Test {
name: "join-request accepted + class-c supported".into(),
before_func: Some(Box::new({
before_func: Some(Box::new(move || {
let dev_eui = dev.dev_eui.clone();
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
Box::pin(async move {
device_keys::reset_nonces(&dev_eui).await.unwrap();
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
let _ = device_profile::update(dp).await.unwrap();
})
}
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = true;
let _ = device_profile::update(dp).await.unwrap();
})
})),
after_func: Some(Box::new({
after_func: Some(Box::new(move || {
let dp_id = dp.id.clone();
move || {
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
let _ = device_profile::update(dp).await.unwrap();
})
}
Box::pin(async move {
let mut dp = device_profile::get(&dp_id).await.unwrap();
dp.supports_class_c = false;
let _ = device_profile::update(dp).await.unwrap();
})
})),
rx_info: rx_info.clone(),
tx_info: tx_info.clone(),

View File

@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::convert::TryInto;
use anyhow::{Context, Result};
use chrono::{DateTime, Duration, Local, Utc};

View File

@ -1,4 +1,3 @@
use std::convert::TryInto;
use std::time::{Duration, SystemTime};
use anyhow::Result;

View File

@ -1,6 +1,5 @@
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::hash::{Hash, Hasher};
use anyhow::{Context, Result};