diff --git a/Cargo.lock b/Cargo.lock index 66398547..7c4ffa78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -609,7 +609,7 @@ dependencies = [ [[package]] name = "backend" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "aes-kw", "anyhow", @@ -812,7 +812,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chirpstack" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "aes", "anyhow", @@ -882,6 +882,8 @@ dependencies = [ "serde_urlencoded", "serde_yaml", "sha2", + "signal-hook", + "signal-hook-tokio", "thiserror", "tokio", "tokio-executor-trait", @@ -904,7 +906,7 @@ dependencies = [ [[package]] name = "chirpstack_api" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "hex", "pbjson", @@ -921,7 +923,7 @@ dependencies = [ [[package]] name = "chirpstack_integration" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "anyhow", "async-trait", @@ -1230,27 +1232,18 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6541a3916932fe57768d4be0b1ffb5ec7cbf74ca8c903fdfd5c0fe8aa958f0ed" dependencies = [ - "deadpool-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus", - "tokio", -] - -[[package]] -name = "deadpool" -version = "0.12.1" -source = "git+https://github.com/bikeshedder/deadpool.git?rev=6c361a306059bc8b0d3426515991e253015af6be#6c361a306059bc8b0d3426515991e253015af6be" -dependencies = [ - "deadpool-runtime 0.1.4 (git+https://github.com/bikeshedder/deadpool.git?rev=6c361a306059bc8b0d3426515991e253015af6be)", + "deadpool-runtime", "num_cpus", "tokio", ] [[package]] name = "deadpool-redis" -version = "0.15.1" -source = "git+https://github.com/bikeshedder/deadpool.git?rev=6c361a306059bc8b0d3426515991e253015af6be#6c361a306059bc8b0d3426515991e253015af6be" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ed4f481f6a4770b95e09b91e183ee5ed6e1d4a34c0b09814012b3ee5e585f70" dependencies = [ - "deadpool 0.12.1 (git+https://github.com/bikeshedder/deadpool.git?rev=6c361a306059bc8b0d3426515991e253015af6be)", + "deadpool", "redis", ] @@ -1259,11 +1252,6 @@ name = "deadpool-runtime" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" - -[[package]] -name = "deadpool-runtime" -version = "0.1.4" -source = "git+https://github.com/bikeshedder/deadpool.git?rev=6c361a306059bc8b0d3426515991e253015af6be#6c361a306059bc8b0d3426515991e253015af6be" dependencies = [ "tokio", ] @@ -1331,7 +1319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb799bb6f8ca6a794462125d7b8983b0c86e6c93a33a9c55934a4a5de4409d3" dependencies = [ "async-trait", - "deadpool 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "deadpool", "diesel", "futures-util", "scoped-futures", @@ -2523,7 +2511,7 @@ dependencies = [ [[package]] name = "lrwn" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "aes", "anyhow", @@ -2537,7 +2525,7 @@ dependencies = [ [[package]] name = "lrwn_filters" -version = "4.9.0-test.5" +version = "4.9.0" dependencies = [ "hex", "lrwn", @@ -4209,6 +4197,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4218,6 +4216,18 @@ dependencies = [ "libc", ] +[[package]] +name = "signal-hook-tokio" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213241f76fb1e37e27de3b6aa1b068a2c333233b59cca6634f634b80a27ecf1e" +dependencies = [ + "futures-core", + "libc", + "signal-hook", + "tokio", +] + [[package]] name = "signature" version = "2.2.0" diff --git a/Cargo.toml b/Cargo.toml index ad71ebc3..08c67276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,3 @@ opt-level = 'z' lto = true codegen-units = 1 - -[patch.crates-io] - deadpool-redis = { git = "https://github.com/bikeshedder/deadpool.git", rev = "6c361a306059bc8b0d3426515991e253015af6be" } diff --git a/api/grpc-web/package.json b/api/grpc-web/package.json index aabfc6c3..5ff89ca6 100644 --- a/api/grpc-web/package.json +++ b/api/grpc-web/package.json @@ -1,6 +1,6 @@ { "name": "@chirpstack/chirpstack-api-grpc-web", - "version": "4.9.0-test.5", + "version": "4.9.0", "description": "Chirpstack gRPC-web API", "license": "MIT", "devDependencies": { diff --git a/api/java/build.gradle.kts b/api/java/build.gradle.kts index 5f08e520..8b50da04 100644 --- a/api/java/build.gradle.kts +++ b/api/java/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "io.chirpstack" -version = "4.9.0-test.5" +version = "4.9.0" repositories { mavenCentral() diff --git a/api/js/package.json b/api/js/package.json index 8b252c66..cf25537b 100644 --- a/api/js/package.json +++ b/api/js/package.json @@ -1,6 +1,6 @@ { "name": "@chirpstack/chirpstack-api", - "version": "4.9.0-test.5", + "version": "4.9.0", "description": "Chirpstack JS and TS API", "license": "MIT", "devDependencies": { diff --git a/api/kotlin/build.gradle.kts b/api/kotlin/build.gradle.kts index 53b82cfd..294f02b9 100644 --- a/api/kotlin/build.gradle.kts +++ b/api/kotlin/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "io.chirpstack" -version = "4.9.0-test.5" +version = "4.9.0" repositories { mavenCentral() diff --git a/api/php/composer.json b/api/php/composer.json index b11924b9..f13e1e94 100644 --- a/api/php/composer.json +++ b/api/php/composer.json @@ -3,7 +3,7 @@ "description": "Chirpstack PHP API", "license": "MIT", "type": "library", - "version": "4.9.0-test.5", + "version": "4.9.0", "require": { "php": ">=7.0.0", "grpc/grpc": "^v1.57.0", diff --git a/api/python/src/setup.py b/api/python/src/setup.py index 15c3ca8f..43770eb4 100644 --- a/api/python/src/setup.py +++ b/api/python/src/setup.py @@ -18,7 +18,7 @@ CLASSIFIERS = [ setup( name='chirpstack-api', - version = "4.9.0-test.5", + version = "4.9.0", url='https://github.com/brocaar/chirpstack-api', author='Orne Brocaar', author_email='info@brocaar.com', diff --git a/api/rust/Cargo.toml b/api/rust/Cargo.toml index d847953f..96ee92bd 100644 --- a/api/rust/Cargo.toml +++ b/api/rust/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "chirpstack_api" description = "ChirpStack Protobuf / gRPC API definitions." - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] license = "MIT" homepage = "https://www.chirpstack.io" diff --git a/api/rust/src/gw.rs b/api/rust/src/gw.rs index 9fbb1632..cb27aef6 100644 --- a/api/rust/src/gw.rs +++ b/api/rust/src/gw.rs @@ -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::(), - 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), + ); } _ => {} } diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 3025e9ff..98a51cef 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "backend" - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] edition = "2018" publish = false diff --git a/chirpstack-integration/Cargo.toml b/chirpstack-integration/Cargo.toml index 16cc442e..6f32d44b 100644 --- a/chirpstack-integration/Cargo.toml +++ b/chirpstack-integration/Cargo.toml @@ -3,7 +3,7 @@ description = "Library for building external ChirpStack integrations" homepage = "https://www.chirpstack.io/" license = "MIT" - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] edition = "2021" repository = "https://github.com/chirpstack/chirpstack" diff --git a/chirpstack/Cargo.toml b/chirpstack/Cargo.toml index dc11faaf..f964d3f0 100644 --- a/chirpstack/Cargo.toml +++ b/chirpstack/Cargo.toml @@ -3,7 +3,7 @@ description = "ChirpStack is an open-source LoRaWAN(TM) Network Server" repository = "https://github.com/chirpstack/chirpstack" homepage = "https://www.chirpstack.io/" - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] edition = "2021" publish = false @@ -38,7 +38,7 @@ tokio-postgres-rustls = { version = "0.12", optional = true } bigdecimal = "0.4" redis = { version = "0.26", features = ["tls-rustls", "tokio-rustls-comp"] } - deadpool-redis = { version = "0.15", features = ["cluster"] } + deadpool-redis = { version = "0.16", features = ["cluster"] } # Logging tracing = "0.1" @@ -154,6 +154,8 @@ prometheus-client = "0.22" pin-project = "1.1" scoped-futures = { version = "0.1", features = ["std"] } + signal-hook = "0.3" + signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } # Development and testing [dev-dependencies] diff --git a/chirpstack/src/api/application.rs b/chirpstack/src/api/application.rs index cf60a7bb..24a496b7 100644 --- a/chirpstack/src/api/application.rs +++ b/chirpstack/src/api/application.rs @@ -2050,7 +2050,7 @@ pub mod test { .unwrap(); application::create(application::Application { - tenant_id: t.id.clone(), + tenant_id: t.id, name: "test-app".into(), ..Default::default() }) @@ -2071,7 +2071,7 @@ pub mod test { fn get_request(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } diff --git a/chirpstack/src/api/auth/claims.rs b/chirpstack/src/api/auth/claims.rs index a6d1e5cb..d305c32e 100644 --- a/chirpstack/src/api/auth/claims.rs +++ b/chirpstack/src/api/auth/claims.rs @@ -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()); } } diff --git a/chirpstack/src/api/auth/validator.rs b/chirpstack/src/api/auth/validator.rs index 84d04ff7..da122cdb 100644 --- a/chirpstack/src/api/auth/validator.rs +++ b/chirpstack/src/api/auth/validator.rs @@ -2249,7 +2249,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user, &tenant_user, &tenant_admin, @@ -2493,7 +2493,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user, &user_admin, &tenant_admin, @@ -2851,7 +2851,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user_active, &user_admin, &tenant_admin, @@ -3132,7 +3132,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(); } @@ -3288,7 +3288,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user_active, &user_admin, &tenant_admin, @@ -3306,7 +3306,7 @@ 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 @@ -3603,7 +3603,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user_active, &user_admin, &tenant_admin, @@ -3863,7 +3863,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(); } @@ -3994,7 +3994,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user_active, &user_admin, &tenant_admin, @@ -4276,7 +4276,7 @@ pub mod test { ..Default::default() }; - for u in vec![ + for u in [ &user_active, &user_admin, &tenant_admin, diff --git a/chirpstack/src/api/device.rs b/chirpstack/src/api/device.rs index 4f2cd39d..7a77a617 100644 --- a/chirpstack/src/api/device.rs +++ b/chirpstack/src/api/device.rs @@ -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 { @@ -1624,7 +1618,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); @@ -1672,10 +1666,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) @@ -1732,7 +1726,7 @@ pub mod test { fn get_request(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } } diff --git a/chirpstack/src/api/device_profile.rs b/chirpstack/src/api/device_profile.rs index e2fcb947..7c7c709c 100644 --- a/chirpstack/src/api/device_profile.rs +++ b/chirpstack/src/api/device_profile.rs @@ -600,7 +600,7 @@ pub mod test { fn get_request(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } } diff --git a/chirpstack/src/api/device_profile_template.rs b/chirpstack/src/api/device_profile_template.rs index afd3105a..33e4f122 100644 --- a/chirpstack/src/api/device_profile_template.rs +++ b/chirpstack/src/api/device_profile_template.rs @@ -444,7 +444,7 @@ pub mod test { fn get_request(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } } diff --git a/chirpstack/src/api/gateway.rs b/chirpstack/src/api/gateway.rs index 4af5dac4..a1b3b389 100644 --- a/chirpstack/src/api/gateway.rs +++ b/chirpstack/src/api/gateway.rs @@ -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())?; @@ -1172,7 +1168,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() }) @@ -1184,7 +1180,7 @@ pub mod test { // insert stats let mut m = metrics::Record { kind: metrics::Kind::ABSOLUTE, - time: now.into(), + time: now, metrics: HashMap::new(), }; @@ -1269,7 +1265,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() }) @@ -1281,7 +1277,7 @@ pub mod test { // insert stats let mut m = metrics::Record { kind: metrics::Kind::COUNTER, - time: now.into(), + time: now, metrics: HashMap::new(), }; diff --git a/chirpstack/src/api/mod.rs b/chirpstack/src/api/mod.rs index 773860e7..a25aa324 100644 --- a/chirpstack/src/api/mod.rs +++ b/chirpstack/src/api/mod.rs @@ -181,7 +181,12 @@ pub async fn setup() -> Result<()> { let monitoring_handle = tokio::spawn(monitoring::setup()); let grpc_handle = tokio::spawn(grpc.serve(bind)); - let _ = try_join!(grpc_handle, backend_handle, monitoring_handle)?; + tokio::spawn(async move { + if let Err(e) = try_join!(grpc_handle, backend_handle, monitoring_handle) { + error!(error = %e, "Setup API error"); + std::process::exit(-1); + } + }); Ok(()) } diff --git a/chirpstack/src/api/multicast.rs b/chirpstack/src/api/multicast.rs index a659cf57..0a1deb85 100644 --- a/chirpstack/src/api/multicast.rs +++ b/chirpstack/src/api/multicast.rs @@ -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(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } } diff --git a/chirpstack/src/api/relay.rs b/chirpstack/src/api/relay.rs index 872fe4b0..7b1e85c3 100644 --- a/chirpstack/src/api/relay.rs +++ b/chirpstack/src/api/relay.rs @@ -315,7 +315,7 @@ pub mod test { fn get_request(user_id: &Uuid, req: T) -> Request { let mut req = Request::new(req); - req.extensions_mut().insert(AuthID::User(user_id.clone())); + req.extensions_mut().insert(AuthID::User(*user_id)); req } } diff --git a/chirpstack/src/cmd/root.rs b/chirpstack/src/cmd/root.rs index 7f4a513e..c4dc3d0c 100644 --- a/chirpstack/src/cmd/root.rs +++ b/chirpstack/src/cmd/root.rs @@ -1,5 +1,8 @@ use anyhow::Result; -use tracing::info; +use futures::stream::StreamExt; +use signal_hook::consts::signal::{SIGINT, SIGTERM}; +use signal_hook_tokio::Signals; +use tracing::{info, warn}; use crate::gateway; use crate::{adr, api, backend, downlink, integration, region, storage}; @@ -20,5 +23,10 @@ pub async fn run() -> Result<()> { downlink::setup().await; api::setup().await?; + let mut signals = Signals::new([SIGINT, SIGTERM]).unwrap(); + if let Some(signal) = signals.next().await { + warn!(signal = ?signal, "Signal received, terminating process"); + } + Ok(()) } diff --git a/chirpstack/src/downlink/classb.rs b/chirpstack/src/downlink/classb.rs index 8f69a28c..f8d0f54d 100644 --- a/chirpstack/src/downlink/classb.rs +++ b/chirpstack/src/downlink/classb.rs @@ -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; } } } diff --git a/chirpstack/src/downlink/data.rs b/chirpstack/src/downlink/data.rs index 7c4724e2..bd79af54 100644 --- a/chirpstack/src/downlink/data.rs +++ b/chirpstack/src/downlink/data.rs @@ -1352,7 +1352,7 @@ impl Data { ds.last_device_status_request = Some(Utc::now().into()); } Some(ts) => { - let ts: DateTime = ts.clone().try_into().map_err(anyhow::Error::msg)?; + let ts: DateTime = (*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; @@ -1714,8 +1714,7 @@ impl Data { match &rd.w_f_cnt_last_request { Some(v) => { - let last_req: DateTime = - v.clone().try_into().map_err(anyhow::Error::msg)?; + let last_req: DateTime = (*v).try_into().map_err(anyhow::Error::msg)?; if last_req < Utc::now() .checked_sub_signed(chrono::Duration::try_hours(24).unwrap()) diff --git a/chirpstack/src/downlink/helpers.rs b/chirpstack/src/downlink/helpers.rs index 70ccc8dd..e4093dcc 100644 --- a/chirpstack/src/downlink/helpers.rs +++ b/chirpstack/src/downlink/helpers.rs @@ -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, diff --git a/chirpstack/src/downlink/tx_ack.rs b/chirpstack/src/downlink/tx_ack.rs index e5577e50..61449320 100644 --- a/chirpstack/src/downlink/tx_ack.rs +++ b/chirpstack/src/downlink/tx_ack.rs @@ -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, diff --git a/chirpstack/src/integration/loracloud/buffer.rs b/chirpstack/src/integration/loracloud/buffer.rs index 4a55eedb..6d205a99 100644 --- a/chirpstack/src/integration/loracloud/buffer.rs +++ b/chirpstack/src/integration/loracloud/buffer.rs @@ -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; diff --git a/chirpstack/src/integration/loracloud/mod.rs b/chirpstack/src/integration/loracloud/mod.rs index 471a5e70..57636f49 100644 --- a/chirpstack/src/integration/loracloud/mod.rs +++ b/chirpstack/src/integration/loracloud/mod.rs @@ -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 = pl - .time - .as_ref() - .unwrap() - .clone() + let ts: DateTime = (*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 = pl - .time - .as_ref() - .unwrap() - .clone() + let ts: DateTime = (*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 = pl - .time - .as_ref() - .unwrap() - .clone() + let ts: DateTime = (*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 = pl - .time - .as_ref() - .unwrap() - .clone() + let ts: DateTime = (*pl.time.as_ref().unwrap()) .try_into() .map_err(anyhow::Error::msg)?; let dev_eui = EUI64::from_str(&di.dev_eui)?; diff --git a/chirpstack/src/integration/postgresql/mod.rs b/chirpstack/src/integration/postgresql/mod.rs index ae043505..6f32e788 100644 --- a/chirpstack/src/integration/postgresql/mod.rs +++ b/chirpstack/src/integration/postgresql/mod.rs @@ -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)?, diff --git a/chirpstack/src/integration/redis.rs b/chirpstack/src/integration/redis.rs index c0477841..39ceb27f 100644 --- a/chirpstack/src/integration/redis.rs +++ b/chirpstack/src/integration/redis.rs @@ -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(); diff --git a/chirpstack/src/maccommand/configure_fwd_limit.rs b/chirpstack/src/maccommand/configure_fwd_limit.rs index cb742cb5..075694d8 100644 --- a/chirpstack/src/maccommand/configure_fwd_limit.rs +++ b/chirpstack/src/maccommand/configure_fwd_limit.rs @@ -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!( diff --git a/chirpstack/src/maccommand/ctrl_uplink_list.rs b/chirpstack/src/maccommand/ctrl_uplink_list.rs index 235f32ca..8515d4af 100644 --- a/chirpstack/src/maccommand/ctrl_uplink_list.rs +++ b/chirpstack/src/maccommand/ctrl_uplink_list.rs @@ -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(); diff --git a/chirpstack/src/maccommand/dev_status.rs b/chirpstack/src/maccommand/dev_status.rs index 77c28e9a..d88dcbeb 100644 --- a/chirpstack/src/maccommand/dev_status.rs +++ b/chirpstack/src/maccommand/dev_status.rs @@ -136,22 +136,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() @@ -169,7 +169,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; @@ -200,7 +200,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::BigDecimal::from_str("100.00").unwrap().into()), d.battery_level diff --git a/chirpstack/src/maccommand/device_mode_ind.rs b/chirpstack/src/maccommand/device_mode_ind.rs index 9a13ce6d..ccfdc96c 100644 --- a/chirpstack/src/maccommand/device_mode_ind.rs +++ b/chirpstack/src/maccommand/device_mode_ind.rs @@ -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() diff --git a/chirpstack/src/maccommand/end_device_conf.rs b/chirpstack/src/maccommand/end_device_conf.rs index 10c70dbf..1b1cd642 100644 --- a/chirpstack/src/maccommand/end_device_conf.rs +++ b/chirpstack/src/maccommand/end_device_conf.rs @@ -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!( diff --git a/chirpstack/src/maccommand/filter_list.rs b/chirpstack/src/maccommand/filter_list.rs index bf744aaa..f48cf2b3 100644 --- a/chirpstack/src/maccommand/filter_list.rs +++ b/chirpstack/src/maccommand/filter_list.rs @@ -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!( diff --git a/chirpstack/src/maccommand/link_adr.rs b/chirpstack/src/maccommand/link_adr.rs index 73b2c96c..e6f37b9f 100644 --- a/chirpstack/src/maccommand/link_adr.rs +++ b/chirpstack/src/maccommand/link_adr.rs @@ -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!( diff --git a/chirpstack/src/maccommand/new_channel.rs b/chirpstack/src/maccommand/new_channel.rs index d153c691..da5a987a 100644 --- a/chirpstack/src/maccommand/new_channel.rs +++ b/chirpstack/src/maccommand/new_channel.rs @@ -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!( diff --git a/chirpstack/src/maccommand/ping_slot_channel.rs b/chirpstack/src/maccommand/ping_slot_channel.rs index b6ad2c86..d8a6b849 100644 --- a/chirpstack/src/maccommand/ping_slot_channel.rs +++ b/chirpstack/src/maccommand/ping_slot_channel.rs @@ -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!( diff --git a/chirpstack/src/maccommand/rejoin_param_setup.rs b/chirpstack/src/maccommand/rejoin_param_setup.rs index e88cf9ce..de73779a 100644 --- a/chirpstack/src/maccommand/rejoin_param_setup.rs +++ b/chirpstack/src/maccommand/rejoin_param_setup.rs @@ -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!( diff --git a/chirpstack/src/maccommand/relay_conf.rs b/chirpstack/src/maccommand/relay_conf.rs index 80a219aa..bca270e3 100644 --- a/chirpstack/src/maccommand/relay_conf.rs +++ b/chirpstack/src/maccommand/relay_conf.rs @@ -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!( diff --git a/chirpstack/src/maccommand/rx_param_setup.rs b/chirpstack/src/maccommand/rx_param_setup.rs index e3fb9688..eacf81bd 100644 --- a/chirpstack/src/maccommand/rx_param_setup.rs +++ b/chirpstack/src/maccommand/rx_param_setup.rs @@ -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!( diff --git a/chirpstack/src/maccommand/rx_timing_setup.rs b/chirpstack/src/maccommand/rx_timing_setup.rs index ad71ce69..e6f1ae6e 100644 --- a/chirpstack/src/maccommand/rx_timing_setup.rs +++ b/chirpstack/src/maccommand/rx_timing_setup.rs @@ -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!( diff --git a/chirpstack/src/maccommand/tx_param_setup.rs b/chirpstack/src/maccommand/tx_param_setup.rs index 297147b1..27affbd7 100644 --- a/chirpstack/src/maccommand/tx_param_setup.rs +++ b/chirpstack/src/maccommand/tx_param_setup.rs @@ -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!( diff --git a/chirpstack/src/maccommand/update_uplink_list.rs b/chirpstack/src/maccommand/update_uplink_list.rs index 4facbf99..2016f252 100644 --- a/chirpstack/src/maccommand/update_uplink_list.rs +++ b/chirpstack/src/maccommand/update_uplink_list.rs @@ -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!( diff --git a/chirpstack/src/storage/api_key.rs b/chirpstack/src/storage/api_key.rs index 4c082c40..f29ecb45 100644 --- a/chirpstack/src/storage/api_key.rs +++ b/chirpstack/src/storage/api_key.rs @@ -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()); } } diff --git a/chirpstack/src/storage/application.rs b/chirpstack/src/storage/application.rs index f543e9cb..f9a88e66 100644 --- a/chirpstack/src/storage/application.rs +++ b/chirpstack/src/storage/application.rs @@ -618,7 +618,7 @@ pub mod test { }; let a = Application { - tenant_id: tenant_id, + tenant_id, name: "test application".into(), description: "test application description".into(), ..Default::default() @@ -724,6 +724,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()); } } diff --git a/chirpstack/src/storage/device.rs b/chirpstack/src/storage/device.rs index 8206a3a8..9f283301 100644 --- a/chirpstack/src/storage/device.rs +++ b/chirpstack/src/storage/device.rs @@ -892,8 +892,8 @@ pub mod test { let d = Device { name: "test-dev".into(), - dev_eui: dev_eui, - application_id: application_id, + dev_eui, + application_id, device_profile_id: device_profile_id.into(), ..Default::default() }; @@ -1000,7 +1000,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] @@ -1111,7 +1111,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 @@ -1120,7 +1120,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() { @@ -1481,7 +1481,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() @@ -1498,15 +1498,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,); } } diff --git a/chirpstack/src/storage/device_keys.rs b/chirpstack/src/storage/device_keys.rs index f31990e8..9a506fdd 100644 --- a/chirpstack/src/storage/device_keys.rs +++ b/chirpstack/src/storage/device_keys.rs @@ -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()); } } diff --git a/chirpstack/src/storage/device_profile.rs b/chirpstack/src/storage/device_profile.rs index b9fb58e3..dc91d3ba 100644 --- a/chirpstack/src/storage/device_profile.rs +++ b/chirpstack/src/storage/device_profile.rs @@ -516,6 +516,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()); } } diff --git a/chirpstack/src/storage/device_profile_template.rs b/chirpstack/src/storage/device_profile_template.rs index a542f90d..6d082137 100644 --- a/chirpstack/src/storage/device_profile_template.rs +++ b/chirpstack/src/storage/device_profile_template.rs @@ -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()); } } diff --git a/chirpstack/src/storage/device_queue.rs b/chirpstack/src/storage/device_queue.rs index 93d17b95..aa0aa959 100644 --- a/chirpstack/src/storage/device_queue.rs +++ b/chirpstack/src/storage/device_queue.rs @@ -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] diff --git a/chirpstack/src/storage/gateway.rs b/chirpstack/src/storage/gateway.rs index 1e07e71e..1bbf8c07 100644 --- a/chirpstack/src/storage/gateway.rs +++ b/chirpstack/src/storage/gateway.rs @@ -435,6 +435,7 @@ pub async fn update_relay_gateway(relay: RelayGateway) -> Result Result<()> { EUI64::from_slice(&ds.dev_eui)? }; - let lifetime: DateTime = match ds.lifetime.clone() { + let lifetime: DateTime = 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"); diff --git a/chirpstack/src/storage/search.rs b/chirpstack/src/storage/search.rs index 7e985651..5ecb0a49 100644 --- a/chirpstack/src/storage/search.rs +++ b/chirpstack/src/storage/search.rs @@ -422,7 +422,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 @@ -430,7 +430,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 @@ -439,7 +439,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, tags: build_tags(&[("common_tag", "value"), ("mytag", "gw_value")]), ..Default::default() }) @@ -460,8 +460,8 @@ pub mod test { let _d = device::create(device::Device { dev_eui: EUI64::from_str("030405060708090A").unwrap(), name: "sensor".into(), - application_id: a.id.clone(), - device_profile_id: dp.id.clone(), + application_id: a.id, + device_profile_id: dp.id, tags: build_tags(&[("a", "1"), ("b", "2")]), ..Default::default() }) @@ -512,8 +512,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 diff --git a/chirpstack/src/storage/tenant.rs b/chirpstack/src/storage/tenant.rs index a7fb3f88..220b02bf 100644 --- a/chirpstack/src/storage/tenant.rs +++ b/chirpstack/src/storage/tenant.rs @@ -358,7 +358,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(); @@ -468,7 +468,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] diff --git a/chirpstack/src/storage/user.rs b/chirpstack/src/storage/user.rs index 9dc22c34..66d0ce2b 100644 --- a/chirpstack/src/storage/user.rs +++ b/chirpstack/src/storage/user.rs @@ -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()); } } diff --git a/chirpstack/src/stream/api_request.rs b/chirpstack/src/stream/api_request.rs index 77c929dc..fa73dab2 100644 --- a/chirpstack/src/stream/api_request.rs +++ b/chirpstack/src/stream/api_request.rs @@ -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") diff --git a/chirpstack/src/stream/frame.rs b/chirpstack/src/stream/frame.rs index 2d925d56..05fa828a 100644 --- a/chirpstack/src/stream/frame.rs +++ b/chirpstack/src/stream/frame.rs @@ -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, }; diff --git a/chirpstack/src/test/assert.rs b/chirpstack/src/test/assert.rs index 0717bc70..50c80c11 100644 --- a/chirpstack/src/test/assert.rs +++ b/chirpstack/src/test/assert.rs @@ -25,7 +25,7 @@ pub type Validator = Box Pin>>>; 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) -> 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) -> 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) -> 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) -> 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 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()); diff --git a/chirpstack/src/test/class_a_pr_test.rs b/chirpstack/src/test/class_a_pr_test.rs index 68638ed6..c60f8a2e 100644 --- a/chirpstack/src/test/class_a_pr_test.rs +++ b/chirpstack/src/test/class_a_pr_test.rs @@ -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), @@ -327,7 +327,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(), @@ -453,7 +453,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 @@ -461,7 +461,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, @@ -476,8 +476,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), @@ -569,7 +569,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(), @@ -682,7 +682,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(), diff --git a/chirpstack/src/test/class_a_test.rs b/chirpstack/src/test/class_a_test.rs index 24bba538..b338186c 100644 --- a/chirpstack/src/test/class_a_test.rs +++ b/chirpstack/src/test/class_a_test.rs @@ -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])), @@ -147,7 +147,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 { @@ -259,8 +259,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])), @@ -297,7 +297,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(), @@ -390,7 +390,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() }) @@ -399,7 +399,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 @@ -407,7 +407,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, @@ -419,8 +419,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])), @@ -445,7 +445,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(), @@ -587,7 +587,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() }) @@ -596,7 +596,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 @@ -604,7 +604,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, @@ -616,8 +616,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])), @@ -642,13 +642,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(), @@ -741,7 +741,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() }) @@ -750,7 +750,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 @@ -758,7 +758,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, @@ -770,8 +770,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, @@ -797,7 +797,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(), @@ -935,7 +935,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() }) @@ -944,7 +944,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 @@ -952,7 +952,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, @@ -964,8 +964,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, @@ -991,7 +991,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(), @@ -1059,7 +1059,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() }) @@ -1068,7 +1068,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 @@ -1076,7 +1076,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, @@ -1088,8 +1088,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])), @@ -1114,13 +1114,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(), @@ -1696,7 +1696,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() }) @@ -1705,7 +1705,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 @@ -1713,7 +1713,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, @@ -1725,8 +1725,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])), @@ -1751,7 +1751,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(), @@ -2024,7 +2024,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() }) @@ -2033,7 +2033,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 @@ -2041,7 +2041,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, @@ -2053,8 +2053,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])), @@ -2079,13 +2079,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(), @@ -2263,7 +2263,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() }) @@ -2272,7 +2272,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 @@ -2280,7 +2280,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, @@ -2292,8 +2292,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])), @@ -2318,13 +2318,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(), @@ -2708,7 +2708,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() }) @@ -2717,7 +2717,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 @@ -2725,7 +2725,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, @@ -2737,8 +2737,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])), @@ -2763,13 +2763,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(), @@ -2796,7 +2796,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; @@ -2804,7 +2804,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; @@ -2895,7 +2895,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; @@ -2903,7 +2903,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; @@ -3079,7 +3079,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() }) @@ -3088,7 +3088,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 @@ -3096,7 +3096,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, @@ -3108,8 +3108,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])), @@ -3134,7 +3134,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(), @@ -3273,7 +3273,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() }) @@ -3282,7 +3282,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 @@ -3290,7 +3290,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, @@ -3302,8 +3302,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])), @@ -3328,7 +3328,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(), @@ -3750,7 +3750,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() }) @@ -3759,7 +3759,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 @@ -3767,7 +3767,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, @@ -3779,8 +3779,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])), @@ -3805,7 +3805,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(), @@ -4230,7 +4230,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() }) @@ -4239,7 +4239,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 @@ -4247,7 +4247,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, @@ -4260,8 +4260,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])), @@ -4286,7 +4286,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(), @@ -5073,7 +5073,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() }) @@ -5082,7 +5082,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 @@ -5090,7 +5090,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, @@ -5103,8 +5103,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])), @@ -5129,7 +5129,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(), @@ -5339,7 +5339,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() }) @@ -5348,7 +5348,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 @@ -5356,7 +5356,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, @@ -5368,8 +5368,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])), @@ -5394,13 +5394,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(), @@ -5663,7 +5663,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(), @@ -5777,7 +5777,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; diff --git a/chirpstack/src/test/class_b_test.rs b/chirpstack/src/test/class_b_test.rs index dff6a45f..b247ff4d 100644 --- a/chirpstack/src/test/class_b_test.rs +++ b/chirpstack/src/test/class_b_test.rs @@ -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().into(), - 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().into(), - 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().into(), - 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().into(), - 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; @@ -487,7 +487,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; @@ -508,7 +508,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 { diff --git a/chirpstack/src/test/class_c_test.rs b/chirpstack/src/test/class_c_test.rs index a90297a9..a4f07cbf 100644 --- a/chirpstack/src/test/class_c_test.rs +++ b/chirpstack/src/test/class_c_test.rs @@ -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().into(), - 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().into(), - 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().into(), - 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().into(), - 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().into(), - 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; @@ -316,7 +316,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 { diff --git a/chirpstack/src/test/mod.rs b/chirpstack/src/test/mod.rs index d7941cc3..15e06d58 100644 --- a/chirpstack/src/test/mod.rs +++ b/chirpstack/src/test/mod.rs @@ -92,5 +92,5 @@ pub async fn prepare<'a>() -> std::sync::MutexGuard<'a, ()> { // setup adr adr::setup().await.unwrap(); - return guard; + guard } diff --git a/chirpstack/src/test/multicast_test.rs b/chirpstack/src/test/multicast_test.rs index 1f39bb58..5645abbf 100644 --- a/chirpstack/src/test/multicast_test.rs +++ b/chirpstack/src/test/multicast_test.rs @@ -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 @@ -234,7 +234,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(); diff --git a/chirpstack/src/test/otaa_js_test.rs b/chirpstack/src/test/otaa_js_test.rs index 533053d9..7a7921f7 100644 --- a/chirpstack/src/test/otaa_js_test.rs +++ b/chirpstack/src/test/otaa_js_test.rs @@ -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; diff --git a/chirpstack/src/test/otaa_pr_test.rs b/chirpstack/src/test/otaa_pr_test.rs index 3b1d5bf9..4a79e027 100644 --- a/chirpstack/src/test/otaa_pr_test.rs +++ b/chirpstack/src/test/otaa_pr_test.rs @@ -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![].into(), ..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![].into(), ..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(), diff --git a/chirpstack/src/test/otaa_test.rs b/chirpstack/src/test/otaa_test.rs index eb09898e..91bed7e1 100644 --- a/chirpstack/src/test/otaa_test.rs +++ b/chirpstack/src/test/otaa_test.rs @@ -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)].into(), ..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)].into(), ..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)].into(), @@ -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; diff --git a/chirpstack/src/test/relay_class_a_test.rs b/chirpstack/src/test/relay_class_a_test.rs index bf8c9072..73517a5d 100644 --- a/chirpstack/src/test/relay_class_a_test.rs +++ b/chirpstack/src/test/relay_class_a_test.rs @@ -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; diff --git a/chirpstack/src/test/relay_otaa_test.rs b/chirpstack/src/test/relay_otaa_test.rs index a0b81d7a..faf21196 100644 --- a/chirpstack/src/test/relay_otaa_test.rs +++ b/chirpstack/src/test/relay_otaa_test.rs @@ -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])), @@ -136,7 +136,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 { @@ -145,7 +145,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, @@ -268,7 +268,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(), diff --git a/chirpstack/src/uplink/data.rs b/chirpstack/src/uplink/data.rs index 0f296ab1..e7515621 100644 --- a/chirpstack/src/uplink/data.rs +++ b/chirpstack/src/uplink/data.rs @@ -1029,11 +1029,9 @@ impl Data { match v { pbjson_types::value::Kind::NumberValue(v) => { let record = metrics::Record { - time: DateTime::::try_from( - up_event.time.as_ref().unwrap().clone(), - ) - .map_err(anyhow::Error::msg)? - .with_timezone(&Local), + time: DateTime::::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, diff --git a/chirpstack/src/uplink/helpers.rs b/chirpstack/src/uplink/helpers.rs index bd6f7a8d..f503593b 100644 --- a/chirpstack/src/uplink/helpers.rs +++ b/chirpstack/src/uplink/helpers.rs @@ -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> = ts.clone().try_into().map_err(anyhow::Error::msg); + let ts: Result> = (*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 { // Then search for time. for rxi in rx_info { if let Some(ts) = &rxi.gw_time { - let ts: Result> = ts.clone().try_into().map_err(anyhow::Error::msg); + let ts: Result> = (*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 = match &self.mesh_stats.time { - Some(v) => v - .clone() + Some(v) => (*v) .try_into() .map_err(|e| anyhow!("Convert time error: {}", e))?, None => { diff --git a/chirpstack/src/uplink/stats.rs b/chirpstack/src/uplink/stats.rs index 599114c2..4994cae0 100644 --- a/chirpstack/src/uplink/stats.rs +++ b/chirpstack/src/uplink/stats.rs @@ -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(); diff --git a/lrwn-filters/Cargo.toml b/lrwn-filters/Cargo.toml index 7a71740c..44067264 100644 --- a/lrwn-filters/Cargo.toml +++ b/lrwn-filters/Cargo.toml @@ -3,7 +3,7 @@ description = "Library for filtering LoRaWAN payloads on DevAddr and JoinEUIs prefixes" homepage = "https://www.chirpstack.io/" license = "MIT" - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] edition = "2021" repository = "https://github.com/chirpstack/chirpstack" diff --git a/lrwn/Cargo.toml b/lrwn/Cargo.toml index d96f4d86..55d378f4 100644 --- a/lrwn/Cargo.toml +++ b/lrwn/Cargo.toml @@ -3,7 +3,7 @@ description = "Library for encoding / decoding LoRaWAN frames." homepage = "https://www.chirpstack.io" license = "MIT" - version = "4.9.0-test.5" + version = "4.9.0" authors = ["Orne Brocaar "] edition = "2018" repository = "https://github.com/chirpstack/chirpstack" diff --git a/lrwn/src/devaddr.rs b/lrwn/src/devaddr.rs index 0219d10d..1e0eec4c 100644 --- a/lrwn/src/devaddr.rs +++ b/lrwn/src/devaddr.rs @@ -383,7 +383,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); } diff --git a/lrwn/src/eui64.rs b/lrwn/src/eui64.rs index c4bbf733..ed7734e1 100644 --- a/lrwn/src/eui64.rs +++ b/lrwn/src/eui64.rs @@ -297,7 +297,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] diff --git a/lrwn/src/maccommand.rs b/lrwn/src/maccommand.rs index 4824d06d..5f527d04 100644 --- a/lrwn/src/maccommand.rs +++ b/lrwn/src/maccommand.rs @@ -2659,7 +2659,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, }), diff --git a/lrwn/src/payload.rs b/lrwn/src/payload.rs index 35296100..ba11eb4f 100644 --- a/lrwn/src/payload.rs +++ b/lrwn/src/payload.rs @@ -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 diff --git a/lrwn/src/region/as923.rs b/lrwn/src/region/as923.rs index 8e718e35..70bbfaf6 100644 --- a/lrwn/src/region/as923.rs +++ b/lrwn/src/region/as923.rs @@ -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] diff --git a/lrwn/src/region/au915.rs b/lrwn/src/region/au915.rs index 0196bc9d..f7937795 100644 --- a/lrwn/src/region/au915.rs +++ b/lrwn/src/region/au915.rs @@ -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!( diff --git a/lrwn/src/region/cn470.rs b/lrwn/src/region/cn470.rs index e23ba19e..16741210 100644 --- a/lrwn/src/region/cn470.rs +++ b/lrwn/src/region/cn470.rs @@ -588,8 +588,7 @@ mod tests { use crate::*; fn config_full() -> Configuration { - let c = Configuration::new(false); - c + Configuration::new(false) } #[test] diff --git a/lrwn/src/region/cn779.rs b/lrwn/src/region/cn779.rs index fdbb0f57..87fa32e6 100644 --- a/lrwn/src/region/cn779.rs +++ b/lrwn/src/region/cn779.rs @@ -566,8 +566,7 @@ mod test { use crate::*; fn config() -> Configuration { - let c = Configuration::new(false); - c + Configuration::new(false) } #[test] diff --git a/lrwn/src/region/eu868.rs b/lrwn/src/region/eu868.rs index 5053bbd1..7c169425 100644 --- a/lrwn/src/region/eu868.rs +++ b/lrwn/src/region/eu868.rs @@ -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() ), diff --git a/lrwn/src/region/us915.rs b/lrwn/src/region/us915.rs index 651af18f..8e943d31 100644 --- a/lrwn/src/region/us915.rs +++ b/lrwn/src/region/us915.rs @@ -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!( diff --git a/ui/package.json b/ui/package.json index ae38e28a..50c0606b 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "chirpstack-ui", - "version": "4.9.0-test.5", + "version": "4.9.0", "private": true, "type": "module", "scripts": { diff --git a/ui/src/views/device-profile-templates/CreateDeviceProfileTemplate.tsx b/ui/src/views/device-profile-templates/CreateDeviceProfileTemplate.tsx index 626afeca..7e688395 100644 --- a/ui/src/views/device-profile-templates/CreateDeviceProfileTemplate.tsx +++ b/ui/src/views/device-profile-templates/CreateDeviceProfileTemplate.tsx @@ -24,37 +24,39 @@ function CreateDeviceProfileTemplate() { }); }; - const codecScript = `// Decode uplink function. - // - // Input is an object with the following fields: - // - bytes = Byte array containing the uplink payload, e.g. [255, 230, 255, 0] - // - fPort = Uplink fPort. - // - variables = Object containing the configured device variables. - // - // Output must be an object with the following fields: - // - data = Object representing the decoded payload. - function decodeUplink(input) { - return { - data: { - temp: 22.5 - } - }; - } - - // Encode downlink function. - // - // Input is an object with the following fields: - // - data = Object representing the payload that must be encoded. - // - variables = Object containing the configured device variables. - // - // Output must be an object with the following fields: - // - bytes = Byte array containing the downlink payload. - function encodeDownlink(input) { - return { - bytes: [225, 230, 255, 0] - }; - } - `; + const codecScript = `/** + * Decode uplink function + * + * @param {object} input + * @param {number[]} input.bytes Byte array containing the uplink payload, e.g. [255, 230, 255, 0] + * @param {number} input.fPort Uplink fPort. + * @param {Record} input.variables Object containing the configured device variables. + * + * @returns {{data: object}} Object representing the decoded payload. + */ +function decodeUplink(input) { + return { + data: { + // temp: 22.5 + } + }; +} + +/** + * Encode downlink function. + * + * @param {object} input + * @param {object} input.data Object representing the payload that must be encoded. + * @param {Record} input.variables Object containing the configured device variables. + * + * @returns {{bytes: number[]}} Byte array containing the downlink payload. + */ +function encodeDownlink(input) { + return { + // bytes: [225, 230, 255, 0] + }; +} +`; const deviceProfileTemplate = new DeviceProfileTemplate(); deviceProfileTemplate.setPayloadCodecScript(codecScript); diff --git a/ui/src/views/device-profiles/CreateDeviceProfile.tsx b/ui/src/views/device-profiles/CreateDeviceProfile.tsx index 39a3b02e..a0424662 100644 --- a/ui/src/views/device-profiles/CreateDeviceProfile.tsx +++ b/ui/src/views/device-profiles/CreateDeviceProfile.tsx @@ -30,38 +30,39 @@ function CreateDeviceProfile(props: IProps) { }); }; - const codecScript = `// Decode uplink function. - // - // Input is an object with the following fields: - // - bytes = Byte array containing the uplink payload, e.g. [255, 230, 255, 0] - // - fPort = Uplink fPort. - // - recvTime = Uplink message timestamp as Date object. - // - variables = Object containing the configured device variables. - // - // Output must be an object with the following fields: - // - data = Object representing the decoded payload. - function decodeUplink(input) { - return { - data: { - temp: 22.5 - } - }; - } - - // Encode downlink function. - // - // Input is an object with the following fields: - // - data = Object representing the payload that must be encoded. - // - variables = Object containing the configured device variables. - // - // Output must be an object with the following fields: - // - bytes = Byte array containing the downlink payload. - function encodeDownlink(input) { - return { - bytes: [225, 230, 255, 0] - }; - } - `; + const codecScript = `/** + * Decode uplink function + * + * @param {object} input + * @param {number[]} input.bytes Byte array containing the uplink payload, e.g. [255, 230, 255, 0] + * @param {number} input.fPort Uplink fPort. + * @param {Record} input.variables Object containing the configured device variables. + * + * @returns {{data: object}} Object representing the decoded payload. + */ +function decodeUplink(input) { + return { + data: { + // temp: 22.5 + } + }; +} + +/** + * Encode downlink function. + * + * @param {object} input + * @param {object} input.data Object representing the payload that must be encoded. + * @param {Record} input.variables Object containing the configured device variables. + * + * @returns {{bytes: number[]}} Byte array containing the downlink payload. + */ +function encodeDownlink(input) { + return { + // bytes: [225, 230, 255, 0] + }; +} +`; const deviceProfile = new DeviceProfile(); deviceProfile.setPayloadCodecScript(codecScript);