aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoralpaylan2021-04-14 02:07:08 +0300
committeralpaylan2021-04-14 02:07:08 +0300
commit75cf1be9e4b70fd9300e373ab56469d69e340170 (patch)
treeaeb4d6aad372bc33f070d5a8c7cb99badbd4ee90 /tests
parent5060aef6f931e10286591c210e2a89b95d7ee0a0 (diff)
downloadgradecoin-75cf1be9e4b70fd9300e373ab56469d69e340170.tar.gz
gradecoin-75cf1be9e4b70fd9300e373ab56469d69e340170.tar.bz2
gradecoin-75cf1be9e4b70fd9300e373ab56469d69e340170.zip
finished claim testing.
Diffstat (limited to 'tests')
-rw-r--r--tests/schema_tests.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/schema_tests.rs b/tests/schema_tests.rs
index c6fae9d..fc06796 100644
--- a/tests/schema_tests.rs
+++ b/tests/schema_tests.rs
@@ -3,6 +3,7 @@ mod tests {
3 use gradecoin::schema::*; 3 use gradecoin::schema::*;
4 use serde_json::error::Error; 4 use serde_json::error::Error;
5 use serde_test::{assert_tokens, Token}; 5 use serde_test::{assert_tokens, Token};
6 use chrono::{NaiveDate, NaiveTime, NaiveDateTime};
6 7
7 #[test] 8 #[test]
8 fn claims_serialize_correctly() { 9 fn claims_serialize_correctly() {
@@ -40,12 +41,46 @@ mod tests {
40 41
41 #[test] 42 #[test]
42 fn transaction_serialize_correctly() { 43 fn transaction_serialize_correctly() {
44 let transaction = Transaction {
45 by: "source".to_owned(),
46 source: "source".to_owned(),
47 target: "target".to_owned(),
48 amount: 0,
49 timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42),
50 };
43 51
52 assert_tokens(
53 &transaction,
54 &[
55 Token::Struct{name: "Transaction", len: 5},
56 Token::String("by"),
57 Token::String("source"),
58 Token::String("source"),
59 Token::String("source"),
60 Token::String("target"),
61 Token::String("target"),
62 Token::String("amount"),
63 Token::I32(0),
64 Token::String("timestamp"),
65 Token::String("2021-04-02T04:02:42"),
66 Token::StructEnd,
67 ]
68 )
44 } 69 }
45 70
46 #[test] 71 #[test]
47 fn transaction_deserialize_correctly() { 72 fn transaction_deserialize_correctly() {
73 let data = r#"{"by":"source","source":"source","target":"target","amount":0,"timestamp":"2021-04-02T04:02:42"}"#;
74 let transaction: Transaction = serde_json::from_str(data).unwrap();
75 let expected_transaction = Transaction {
76 by: "source".to_owned(),
77 source: "source".to_owned(),
78 target: "target".to_owned(),
79 amount: 0,
80 timestamp: NaiveDate::from_ymd(2021, 4, 2).and_hms(4, 2, 42),
81 };
48 82
83 assert_eq!(transaction, expected_transaction);
49 } 84 }
50 85
51 #[test] 86 #[test]