aboutsummaryrefslogtreecommitdiffstats
path: root/tests/route_tests.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-22 20:15:40 +0300
committerYigit Sever2021-04-25 23:04:39 +0300
commit32b49380880aab00057b8a663b5327d6f58def3a (patch)
tree059dc128813a93679233f5489cf1a42b2ea0374d /tests/route_tests.rs
parent97b2f6c796fd2af1c338725884189685a82adc01 (diff)
downloadgradecoin-32b49380880aab00057b8a663b5327d6f58def3a.tar.gz
gradecoin-32b49380880aab00057b8a663b5327d6f58def3a.tar.bz2
gradecoin-32b49380880aab00057b8a663b5327d6f58def3a.zip
Implement nicenet
- There are bot accounts that return what you sent them - Sending a transaction generates some coin out of thin air - No more one tx per person per block limit - Unused transactions do not disappear anymore
Diffstat (limited to 'tests/route_tests.rs')
-rw-r--r--tests/route_tests.rs78
1 files changed, 38 insertions, 40 deletions
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index decc712..a449b0b 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -1,6 +1,7 @@
1#[cfg(test)] 1#[cfg(test)]
2mod tests { 2mod tests {
3 use gradecoin::schema::{Block, Db, InitialAuthRequest, MetuId, Transaction, User}; 3 use gradecoin::schema::{Block, Db, InitialAuthRequest, MetuId, Transaction, User};
4 use pretty_assertions::assert_eq;
4 5
5 use gradecoin::routes::consensus_routes; 6 use gradecoin::routes::consensus_routes;
6 use warp::http::StatusCode; 7 use warp::http::StatusCode;
@@ -24,6 +25,7 @@ FQIDAQAB
24-----END PUBLIC KEY-----" 25-----END PUBLIC KEY-----"
25 .to_owned(), 26 .to_owned(),
26 balance: 30, 27 balance: 30,
28 is_bot: false,
27 }, 29 },
28 ); 30 );
29 31
@@ -33,45 +35,44 @@ FQIDAQAB
33 user_id: MetuId::new("e223715".to_owned(), "1H5QuOYI1b2r9ET".to_owned()).unwrap(), 35 user_id: MetuId::new("e223715".to_owned(), "1H5QuOYI1b2r9ET".to_owned()).unwrap(),
34 public_key: "NOT_USED_FOR_THIS_USER".to_owned(), 36 public_key: "NOT_USED_FOR_THIS_USER".to_owned(),
35 balance: 0, 37 balance: 0,
38 is_bot: false,
36 }, 39 },
37 ); 40 );
38 41
39 /* 42 /*
40-----BEGIN RSA PRIVATE KEY----- 43 -----BEGIN RSA PRIVATE KEY-----
41MIIEpAIBAAKCAQEA5yWTMeFqr2nvOC9oR5Wq/nzcNlwCIaziojt7rJ4BBvuwkT0t 44 MIIEpAIBAAKCAQEA5yWTMeFqr2nvOC9oR5Wq/nzcNlwCIaziojt7rJ4BBvuwkT0t
42ERDz8AgvUsaewiB+Fz5OXTeb3WAB1FEXnBXGekrGzvC8jHQMKHyNoWzUlpQJ9UMt 45 ERDz8AgvUsaewiB+Fz5OXTeb3WAB1FEXnBXGekrGzvC8jHQMKHyNoWzUlpQJ9UMt
43dQIWPOCuMyLpc+rNPL3428U8UpldjbTHHyq2/ef6abkdj+XWg/slYtrFeOf3ktc1 46 dQIWPOCuMyLpc+rNPL3428U8UpldjbTHHyq2/ef6abkdj+XWg/slYtrFeOf3ktc1
44l50R4k8VO8L6kQuh2+YIjXGPLShRaqnUQPtH8LFPX4bO9lJ9mAoMZFec6XVwumn/ 47 l50R4k8VO8L6kQuh2+YIjXGPLShRaqnUQPtH8LFPX4bO9lJ9mAoMZFec6XVwumn/
45uqu9jyWQL6qh6gtwQHgN+A9wGvzVvltJ9h8sshSHWWtBD0M19ilbXhKyBsHSSZkp 48 uqu9jyWQL6qh6gtwQHgN+A9wGvzVvltJ9h8sshSHWWtBD0M19ilbXhKyBsHSSZkp
46x+TAvFhfQ8JURw7KqahUPVlCwJ5OIKccJ/6FFQIDAQABAoIBADTZGnZlG4dPqSon 49 x+TAvFhfQ8JURw7KqahUPVlCwJ5OIKccJ/6FFQIDAQABAoIBADTZGnZlG4dPqSon
47bKgxSA83bQHgt3wLkyWUhApLdeCq2wvZ+NvWDG/s7yT11IZ991ZJIJGfjTtoIALz 50 bKgxSA83bQHgt3wLkyWUhApLdeCq2wvZ+NvW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n+TJHTXR7xUm2
64VpTrPTfaYWx83OQUn/OZqY5gIQ+jlfwqnVg+PDQQ/P09/4xygRCLvjL6NCSvtkj1 67 VpTrPTfaYWx83OQUn/OZqY5gIQ+jlfwqnVg+PDQQ/P09/4xygRCLvjL6NCSvtkj1
65MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg== 68 MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
66-----END RSA PRIVATE KEY----- 69 -----END RSA PRIVATE KEY-----
67*/ 70 */
68 71
69 db.pending_transactions.write().insert( 72 db.pending_transactions.write().insert(
70 "fingerprint_of_foo".to_owned(), 73 "fingerprint_of_foo".to_owned(),
71 Transaction { 74 Transaction {
72 by: "fingerprint_of_foo".to_owned(), 75 source: "fingerprint_of_foo".to_owned(),
73 source: "31415926535897932384626433832795028841971693993751058209749445923"
74 .to_owned(),
75 target: "fingerprint_of_foo".to_owned(), 76 target: "fingerprint_of_foo".to_owned(),
76 amount: 2, 77 amount: 2,
77 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30), 78 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30),
@@ -109,7 +110,7 @@ MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
109 110
110 assert_eq!(res.status(), StatusCode::OK); 111 assert_eq!(res.status(), StatusCode::OK);
111 112
112 let expected_json_body = r#"{"fingerprint_of_foo":{"by":"fingerprint_of_foo","source":"31415926535897932384626433832795028841971693993751058209749445923","target":"fingerprint_of_foo","amount":2,"timestamp":"2021-04-13T20:55:30"}}"#; 113 let expected_json_body = r#"{"fingerprint_of_foo":{"source":"fingerprint_of_foo","target":"fingerprint_of_foo","amount":2,"timestamp":"2021-04-13T20:55:30"}}"#;
113 114
114 assert_eq!(res.body(), expected_json_body); 115 assert_eq!(res.body(), expected_json_body);
115 } 116 }
@@ -167,9 +168,8 @@ MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
167 let res = warp::test::request() 168 let res = warp::test::request()
168 .method("POST") 169 .method("POST")
169 .json(&Transaction { 170 .json(&Transaction {
170 by: "fingerprint_of_some_guy".to_owned(), 171 source: "fingerprint_of_some_guy".to_owned(),
171 source: "31415926535897932384626433832795028841971693993751058209749445923".to_owned(), 172 target: "31415926535897932384626433832795028841971693993751058209749445923".to_owned(),
172 target: "fingerprint_of_some_guy".to_owned(),
173 amount: 2, 173 amount: 2,
174 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30), 174 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30),
175 }) 175 })
@@ -200,7 +200,6 @@ MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
200 let res = warp::test::request() 200 let res = warp::test::request()
201 .method("POST") 201 .method("POST")
202 .json(&Transaction { 202 .json(&Transaction {
203 by: "some_fingerprint".to_owned(),
204 source: "some_fingerprint".to_owned(), 203 source: "some_fingerprint".to_owned(),
205 target: "some_other_fingerprint".to_owned(), 204 target: "some_other_fingerprint".to_owned(),
206 amount: 2, 205 amount: 2,
@@ -232,10 +231,9 @@ MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
232 db.pending_transactions.write().insert( 231 db.pending_transactions.write().insert(
233 "fingerprint_of_some_guy".to_owned(), 232 "fingerprint_of_some_guy".to_owned(),
234 Transaction { 233 Transaction {
235 by: "fingerprint_of_some_guy".to_owned(), 234 source: "fingerprint_of_some_guy".to_owned(),
236 source: "31415926535897932384626433832795028841971693993751058209749445923" 235 target: "31415926535897932384626433832795028841971693993751058209749445923"
237 .to_owned(), 236 .to_owned(),
238 target: "fingerprint_of_some_guy".to_owned(),
239 amount: 2, 237 amount: 2,
240 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30), 238 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30),
241 }, 239 },
@@ -422,7 +420,7 @@ MRArEl4y68+jZLRu74TVG0lXi6ht6KhNHF6GiWKU9FHZ4B+btLicsg==
422 .json(&InitialAuthRequest { 420 .json(&InitialAuthRequest {
423 c: "D9OKSp4XD+niltqhoiTEyz3pTxGm5ZKYVNFPofW40M6Km7wE7FgIpfTkurBZ6tQsG/rYPRsd6C/Qo+o3HrgOYC8BDprwpnYb7UnJdL2pe44ZMEsPAmDAdwTP9WozY0lr+bjEjtTM1mVQnIdfknychFek/FNi3l8MrapeFTxFaTMGxWuS1+wEuAkcz4AR4+jooaXVAEpKrPiSXqbywF9OQ41tk0kRiXn234dj40ndND+GlfMgghITuBJrJx6tzLppAZNIIGwUjQDt5Oib5dEGrPOe+rran1D26YNhZOtrfYEGyUSN+/58HbItQlLrgFhL6zRT7ojw/Eg4jYXndK0xNgYGyhAn5UI/qnI2NPpZU7Wd3sJKlWc7HfrjNnKVKlcrhHtYy3FXfN/hLg7SFmuSfXqqvVbNVT6pEDU6Y5NahOYaE/vkL0no7F7lz0UjAlgQCmn5yN7mKs3yLSnlx6hmsK/fVoqGBcOIbYY5gzYMlAQ3E+lq0p2MPEoWC8NYxStSeo9M8uLYT6Jl3hYVf8aLgd1l0HEiCyT+kWxvcR5hw42I7gqaoUcnr53Zm1mYK30/fvZ6lxsrb4FphldgQC5fx6nwEgjaLUeB4n0oZTSRLbrd9ZXCjUG4FNmM+sOklhIXyTYUj4VcBSwZuAvJZEFf2em68e7ySJs/ysz+TGu3eVeRc+voAvI9mGLxWnSEjWx64po7PO61uG6ikadHZH+wIw==".to_owned(), 421 c: "D9OKSp4XD+niltqhoiTEyz3pTxGm5ZKYVNFPofW40M6Km7wE7FgIpfTkurBZ6tQsG/rYPRsd6C/Qo+o3HrgOYC8BDprwpnYb7UnJdL2pe44ZMEsPAmDAdwTP9WozY0lr+bjEjtTM1mVQnIdf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uyEh6PS5rdvO4W98AhxW4VBrRO1ljfEMeFq835NEDame511D2pim00Xv0HPIYSDW6pIJA1hy+Np/WyC7PCxvKy0hPzTmHMpFmM+aF43BknJdYlPUhY4cww/xScU6WxuKIsEQNORRhQds8CHOO0EGcOjHVvR2xqnOda1g/rI7mfNMATHj9ZRsB9GH6QG5WTUbo9/71cDAILF+28TG40jSKvY2KzO9vr668tgqoMV2vLnXQa1AD9ZWmdHHdjiXuiH3X0uXxHrfjH7HeXi/HOj/pgCX12jKsEsRwkBTGL4koObH6pQ==".to_owned(),
426 }) 424 })
427 .path("/register") 425 .path("/register")
428 .reply(&filter) 426 .reply(&filter)