aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYigit Sever2021-04-14 00:17:18 +0300
committerYigit Sever2021-04-14 00:17:18 +0300
commitec6bcf166032d0820716189308020c2b2d1faa67 (patch)
tree6a2d7a5eb35c4718a24989ce3af384a9879b0611 /tests
parent75f2a8b794c754ee0f2f6cfe7c2b214aae0f72ea (diff)
downloadgradecoin-ec6bcf166032d0820716189308020c2b2d1faa67.tar.gz
gradecoin-ec6bcf166032d0820716189308020c2b2d1faa67.tar.bz2
gradecoin-ec6bcf166032d0820716189308020c2b2d1faa67.zip
Add new test
Diffstat (limited to 'tests')
-rw-r--r--tests/route_tests.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index d24bbfb..d88b0da 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -234,6 +234,7 @@ sQIDAQAB
234 234
235 let res = warp::test::request() 235 let res = warp::test::request()
236 .method("POST") 236 .method("POST")
237 .header("Authorization", "Bearer foo.bar.baz")
237 .json(&Block { 238 .json(&Block {
238 transaction_list: vec!["foobarbaz".to_owned(), "dazsaz".to_owned()], 239 transaction_list: vec!["foobarbaz".to_owned(), "dazsaz".to_owned()],
239 nonce: 1000, // not valid 240 nonce: 1000, // not valid
@@ -251,6 +252,32 @@ sQIDAQAB
251 /// 252 ///
252 /// https://tools.ietf.org/html/rfc7231#section-6.3.2 253 /// https://tools.ietf.org/html/rfc7231#section-6.3.2
253 /// 254 ///
255 /// Should reject the block because transaction list is empty
256 #[tokio::test]
257 async fn post_block_with_empty_transaction_list() {
258 let db = mocked_db();
259 let filter = consensus_routes(db.clone());
260
261 let res = warp::test::request()
262 .method("POST")
263 .header("Authorization", "Bearer foo.bar.baz")
264 .json(&Block {
265 transaction_list: vec![],
266 nonce: 1000, // not valid
267 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 12).and_hms(05, 29, 30),
268 hash: "thisisnotavalidhash".to_owned(),
269 })
270 .path("/block")
271 .reply(&filter)
272 .await;
273
274 assert_eq!(res.status(), StatusCode::BAD_REQUEST);
275 }
276
277 /// Test a POST request to /block, an endpoint that exists
278 ///
279 /// https://tools.ietf.org/html/rfc7231#section-6.3.2
280 ///
254 /// Should reject the block because hash has enough zeroes but is not the actual hash of the 281 /// Should reject the block because hash has enough zeroes but is not the actual hash of the
255 /// block 282 /// block
256 #[tokio::test] 283 #[tokio::test]