From 93b66c55b3f22635409f212d5fbbaec9eafae073 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Tue, 22 Mar 2022 09:32:35 +0100 Subject: [PATCH] Witness serde: test binary encoding to be backward-compatible This also removes tests for JSON backward-compatible encoding. Human-readable encoding will be changed in the next commit and this will break backward compatibility, thus that part of the test is removed. --- src/blockdata/witness.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/blockdata/witness.rs b/src/blockdata/witness.rs index 015739eb..976923f5 100644 --- a/src/blockdata/witness.rs +++ b/src/blockdata/witness.rs @@ -423,20 +423,21 @@ mod test { #[cfg(feature = "serde")] #[test] - fn test_serde() { - use serde_json; + fn test_serde_bincode() { + use bincode; let old_witness_format = vec![vec![0u8], vec![2]]; let new_witness_format = Witness::from_vec(old_witness_format.clone()); - let old = serde_json::to_string(&old_witness_format).unwrap(); - let new = serde_json::to_string(&new_witness_format).unwrap(); + let old = bincode::serialize(&old_witness_format).unwrap(); + let new = bincode::serialize(&new_witness_format).unwrap(); assert_eq!(old, new); - let back = serde_json::from_str(&new).unwrap(); + let back: Witness = bincode::deserialize(&new).unwrap(); assert_eq!(new_witness_format, back); } + }