Skip to content

Commit

Permalink
Witness serde: test binary encoding to be backward-compatible
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-orlovsky authored and tcharding committed Jul 12, 2022
1 parent b409ae7 commit 93b66c5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/blockdata/witness.rs
Expand Up @@ -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);
}

}


Expand Down

0 comments on commit 93b66c5

Please sign in to comment.