From a9a3c3579718b93705e2a93b992adc3a33111311 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Mon, 11 Apr 2022 15:08:07 +0100 Subject: [PATCH] Revert "Revert to 2018 edition to support older Rust versions." This reverts commit ad49c2959275dda5b1d76c11ab2d61896c705783. Some dependencies require 2021 edition. --- .gitignore | 3 - chirpstack/Cargo.toml | 3 +- chirpstack/src/api/device.rs | 1 - chirpstack/src/api/gateway.rs | 1 - chirpstack/src/certificate.rs | 1 - chirpstack/src/downlink/data.rs | 1 - .../src/integration/azure_service_bus.rs | 1 - chirpstack/src/integration/http.rs | 1 - .../src/integration/loracloud/buffer.rs | 1 - .../src/integration/loracloud/client.rs | 1 - chirpstack/src/integration/loracloud/mod.rs | 1 - chirpstack/src/storage/multicast.rs | 3 +- chirpstack/src/test/class_a_test.rs | 268 ++++++++---------- chirpstack/src/test/otaa_test.rs | 200 ++++++------- chirpstack/src/uplink/data.rs | 1 - chirpstack/src/uplink/helpers.rs | 1 - chirpstack/src/uplink/stats.rs | 1 - 17 files changed, 211 insertions(+), 278 deletions(-) diff --git a/.gitignore b/.gitignore index 9ef71cd3..9354cbf8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,3 @@ # API /api/js/node_modules - -# Bitbake recipes -*.bb diff --git a/chirpstack/Cargo.toml b/chirpstack/Cargo.toml index 71287af3..06e69188 100644 --- a/chirpstack/Cargo.toml +++ b/chirpstack/Cargo.toml @@ -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 "] -edition = "2018" +edition = "2021" publish = false license = "MIT" diff --git a/chirpstack/src/api/device.rs b/chirpstack/src/api/device.rs index bb600048..2a483ab7 100644 --- a/chirpstack/src/api/device.rs +++ b/chirpstack/src/api/device.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::str::FromStr; use std::time::SystemTime; diff --git a/chirpstack/src/api/gateway.rs b/chirpstack/src/api/gateway.rs index d3950b94..1b33c818 100644 --- a/chirpstack/src/api/gateway.rs +++ b/chirpstack/src/api/gateway.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::str::FromStr; use std::time::SystemTime; diff --git a/chirpstack/src/certificate.rs b/chirpstack/src/certificate.rs index 0d18d676..56d6cddc 100644 --- a/chirpstack/src/certificate.rs +++ b/chirpstack/src/certificate.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::ops::Add; use std::time::{SystemTime, UNIX_EPOCH}; diff --git a/chirpstack/src/downlink/data.rs b/chirpstack/src/downlink/data.rs index 49357ac8..672eb0fe 100644 --- a/chirpstack/src/downlink/data.rs +++ b/chirpstack/src/downlink/data.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::convert::TryInto; use std::sync::Arc; use std::time::Duration; diff --git a/chirpstack/src/integration/azure_service_bus.rs b/chirpstack/src/integration/azure_service_bus.rs index 50896492..f1b5ba10 100644 --- a/chirpstack/src/integration/azure_service_bus.rs +++ b/chirpstack/src/integration/azure_service_bus.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::convert::TryFrom; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use anyhow::Result; diff --git a/chirpstack/src/integration/http.rs b/chirpstack/src/integration/http.rs index 7470b66b..88b2ca4f 100644 --- a/chirpstack/src/integration/http.rs +++ b/chirpstack/src/integration/http.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::convert::TryFrom; use std::time::Duration; use anyhow::Result; diff --git a/chirpstack/src/integration/loracloud/buffer.rs b/chirpstack/src/integration/loracloud/buffer.rs index 11d0a663..3a42f67e 100644 --- a/chirpstack/src/integration/loracloud/buffer.rs +++ b/chirpstack/src/integration/loracloud/buffer.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::io::Cursor; use anyhow::{Context, Result}; diff --git a/chirpstack/src/integration/loracloud/client.rs b/chirpstack/src/integration/loracloud/client.rs index 7591854d..e4a1e88a 100644 --- a/chirpstack/src/integration/loracloud/client.rs +++ b/chirpstack/src/integration/loracloud/client.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt; use std::time::Duration; diff --git a/chirpstack/src/integration/loracloud/mod.rs b/chirpstack/src/integration/loracloud/mod.rs index 67cb5d9c..a86139a0 100644 --- a/chirpstack/src/integration/loracloud/mod.rs +++ b/chirpstack/src/integration/loracloud/mod.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::convert::TryInto; use std::str::FromStr; use anyhow::{Context, Result}; diff --git a/chirpstack/src/storage/multicast.rs b/chirpstack/src/storage/multicast.rs index 71ca214b..809c1ae5 100644 --- a/chirpstack/src/storage/multicast.rs +++ b/chirpstack/src/storage/multicast.rs @@ -341,7 +341,6 @@ pub async fn enqueue( qi: MulticastGroupQueueItem, gateway_ids: &[EUI64], ) -> Result<(Vec, 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, 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)) } diff --git a/chirpstack/src/test/class_a_test.rs b/chirpstack/src/test/class_a_test.rs index 12f89cc9..bcacaf43 100644 --- a/chirpstack/src/test/class_a_test.rs +++ b/chirpstack/src/test/class_a_test.rs @@ -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()), diff --git a/chirpstack/src/test/otaa_test.rs b/chirpstack/src/test/otaa_test.rs index ea448559..c46be5ae 100644 --- a/chirpstack/src/test/otaa_test.rs +++ b/chirpstack/src/test/otaa_test.rs @@ -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(), diff --git a/chirpstack/src/uplink/data.rs b/chirpstack/src/uplink/data.rs index d6da7447..51017c83 100644 --- a/chirpstack/src/uplink/data.rs +++ b/chirpstack/src/uplink/data.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::convert::TryInto; use anyhow::{Context, Result}; use chrono::{DateTime, Duration, Local, Utc}; diff --git a/chirpstack/src/uplink/helpers.rs b/chirpstack/src/uplink/helpers.rs index 223a9b96..8597996d 100644 --- a/chirpstack/src/uplink/helpers.rs +++ b/chirpstack/src/uplink/helpers.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::time::{Duration, SystemTime}; use anyhow::Result; diff --git a/chirpstack/src/uplink/stats.rs b/chirpstack/src/uplink/stats.rs index 735b9ac2..0f1c7a1e 100644 --- a/chirpstack/src/uplink/stats.rs +++ b/chirpstack/src/uplink/stats.rs @@ -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};