From c5eeb6a8ba775782802e85e7e9ce47e5faff1e06 Mon Sep 17 00:00:00 2001 From: alpaylan Date: Wed, 14 Apr 2021 03:07:10 +0300 Subject: fix the serde if tests. --- tests/schema_tests.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/schema_tests.rs b/tests/schema_tests.rs index 35ed6e6..c1880b9 100644 --- a/tests/schema_tests.rs +++ b/tests/schema_tests.rs @@ -126,11 +126,16 @@ mod tests { } #[test] - fn block_deserialize_when_vec_emptpy() { - // let data = r#"{"transaction_list":[],"nonce":0,"timestamp":"2021-04-02T04:02:42","hash":"hash"}"#; - // let err: Error = serde_json::from_str::(data).unwrap_err(); - // - // assert_eq!(err.is_data(), true); + fn block_serialize_when_vec_emptpy() { + let block = Block { + transaction_list: vec![], + nonce: 0, + timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42), + hash: "hash".to_owned() + }; + + let json = serde_json::to_string(&block).unwrap(); + assert_eq!(json, r#"{"nonce":0,"timestamp":"2021-04-02T04:02:42","hash":"hash"}"#) } #[test] @@ -173,8 +178,15 @@ mod tests { } #[test] - fn naked_block_deserialize_when_vec_emptpy() { - // + fn naked_block_serialize_when_vec_emptpy() { + let naked_block = NakedBlock { + transaction_list: vec![], + nonce: 0, + timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42), + }; + + let json = serde_json::to_string(&naked_block).unwrap(); + assert_eq!(json, r#"{"nonce":0,"timestamp":"2021-04-02T04:02:42"}"#) } #[test] -- cgit v1.2.3-70-g09d2