Add failing tests from serde-json

This commit is contained in:
sanket1729 2023-01-01 11:44:40 -08:00
parent b3246bf73f
commit a400757676
1 changed files with 15 additions and 0 deletions

View File

@ -1104,6 +1104,9 @@ mod test {
use crate::{Address, Network}; use crate::{Address, Network};
extern crate serde_json; extern crate serde_json;
#[cfg(feature = "serde")]
use serde_test::{assert_tokens, Token};
fn tag_engine(tag_name: &str) -> sha256::HashEngine { fn tag_engine(tag_name: &str) -> sha256::HashEngine {
let mut engine = sha256::Hash::engine(); let mut engine = sha256::Hash::engine();
let tag_hash = sha256::Hash::hash(tag_name.as_bytes()); let tag_hash = sha256::Hash::hash(tag_name.as_bytes());
@ -1357,6 +1360,18 @@ mod test {
} }
} }
#[test]
#[cfg(feature = "serde")]
fn test_leaf_version_serde() {
let leaf_version = LeafVersion::TapScript;
// use serde_test to test serialization and deserialization
assert_tokens(&leaf_version, &[Token::U8(192)]);
let json = serde_json::to_string(&leaf_version).unwrap();
let leaf_version2 = serde_json::from_str(&json).unwrap();
assert_eq!(leaf_version, leaf_version2);
}
#[test] #[test]
fn bip_341_tests() { fn bip_341_tests() {
fn process_script_trees( fn process_script_trees(