diff options
| author | alpaylan | 2021-04-14 03:07:10 +0300 |
|---|---|---|
| committer | alpaylan | 2021-04-14 03:07:10 +0300 |
| commit | fbbb993144dc55b4da047f02f05b29c44758c661 (patch) | |
| tree | b822d7de08e6ab01af15c0f30894b2b446ea1df6 /tests | |
| parent | 19aaf1175e56cfc7403ad2b985e26afb164ed674 (diff) | |
| download | gradecoin-fbbb993144dc55b4da047f02f05b29c44758c661.tar.gz gradecoin-fbbb993144dc55b4da047f02f05b29c44758c661.tar.bz2 gradecoin-fbbb993144dc55b4da047f02f05b29c44758c661.zip | |
fix the serde if tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/schema_tests.rs | 26 |
1 files 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 { | |||
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | #[test] | 128 | #[test] |
| 129 | fn block_deserialize_when_vec_emptpy() { | 129 | fn block_serialize_when_vec_emptpy() { |
| 130 | // let data = r#"{"transaction_list":[],"nonce":0,"timestamp":"2021-04-02T04:02:42","hash":"hash"}"#; | 130 | let block = Block { |
| 131 | // let err: Error = serde_json::from_str::<Block>(data).unwrap_err(); | 131 | transaction_list: vec![], |
| 132 | // | 132 | nonce: 0, |
| 133 | // assert_eq!(err.is_data(), true); | 133 | timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42), |
| 134 | hash: "hash".to_owned() | ||
| 135 | }; | ||
| 136 | |||
| 137 | let json = serde_json::to_string(&block).unwrap(); | ||
| 138 | assert_eq!(json, r#"{"nonce":0,"timestamp":"2021-04-02T04:02:42","hash":"hash"}"#) | ||
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | #[test] | 141 | #[test] |
| @@ -173,8 +178,15 @@ mod tests { | |||
| 173 | } | 178 | } |
| 174 | 179 | ||
| 175 | #[test] | 180 | #[test] |
| 176 | fn naked_block_deserialize_when_vec_emptpy() { | 181 | fn naked_block_serialize_when_vec_emptpy() { |
| 177 | // | 182 | let naked_block = NakedBlock { |
| 183 | transaction_list: vec![], | ||
| 184 | nonce: 0, | ||
| 185 | timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42), | ||
| 186 | }; | ||
| 187 | |||
| 188 | let json = serde_json::to_string(&naked_block).unwrap(); | ||
| 189 | assert_eq!(json, r#"{"nonce":0,"timestamp":"2021-04-02T04:02:42"}"#) | ||
| 178 | } | 190 | } |
| 179 | 191 | ||
| 180 | #[test] | 192 | #[test] |
