aboutsummaryrefslogtreecommitdiff
path: root/src/tests/handshake_types.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2020-01-14 12:35:46 +0100
committerMax Audron <audron@cocaine.farm>2020-01-17 10:48:27 +0100
commit5d50a5f0c03baf460fee394decce5898812dbd2c (patch)
treefc53a8ea19786be4dc57f9736cd4bf4e76026227 /src/tests/handshake_types.rs
parentinitial implementation done (diff)
refactor parse impl
Diffstat (limited to 'src/tests/handshake_types.rs')
-rw-r--r--src/tests/handshake_types.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/handshake_types.rs b/src/tests/handshake_types.rs
new file mode 100644
index 0000000..99fc1ed
--- /dev/null
+++ b/src/tests/handshake_types.rs
@@ -0,0 +1,29 @@
+use crate::protocol::message::handshake::{VariantMap, HandshakeSerialize, HandshakeDeserialize};
+use crate::protocol::primitive::{Variant};
+
+#[test]
+pub fn serialize_variantmap() {
+ let mut test_variantmap = VariantMap::new();
+ test_variantmap.insert("Configured".to_string(), Variant::bool(true));
+ let bytes = [0, 0, 0, 43, 0, 0, 0, 10, 0, 0, 0, 10, 0,
+ 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, 114, 0, 101, 0, 100,
+ 0, 0, 0, 1, 0, 1].to_vec();
+ assert_eq!(
+ test_variantmap.serialize(),
+ bytes
+ );
+}
+
+// #[test]
+// pub fn deserialize_variantmap() {
+// let test_bytes: &[u8] = &[0, 0, 0, 43, 0, 0, 0, 10, 0, 0, 0, 10, 0,
+// 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, 114, 0, 101, 0, 100,
+// 0, 0, 0, 1, 0, 1, 0, 0, 0, 1];
+// let mut test_variantmap = VariantMap::new();
+// test_variantmap.insert("Configured".to_string(), Variant::bool(true));
+//
+// let (len, res) = VariantMap::parse(test_bytes);
+//
+// assert_eq!(len, 43);
+// assert_eq!(res, test_variantmap);
+// }