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

Function test_encode

chirpstack/src/codec/js/mod.rs:388–416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

386
387 #[tokio::test]
388 pub async fn test_encode() {
389 let encoder = r#"
390 function encodeDownlink(input) {
391 if (input.data.enabled) {
392 return {
393 bytes: [0x01]
394 };
395 } else {
396 return {
397 bytes: [0x02]
398 };
399 }
400 }
401 "#
402 .to_string();
403
404 let vars: HashMap<String, String> = HashMap::new();
405
406 let mut input = prost_types::Struct::default();
407 input.fields.insert(
408 "enabled".to_string(),
409 prost_types::Value {
410 kind: Some(prost_types::value::Kind::BoolValue(true)),
411 },
412 );
413
414 let out = encode(10, &vars, &encoder, &input).await.unwrap();
415 assert_eq!((10, vec![1]), out);
416 }
417
418 #[tokio::test]
419 pub async fn test_encode_fport() {

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
encodeFunction · 0.70

Tested by

no test coverage detected