aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2021-04-14 00:17:18 +0300
committerYigit Sever2021-04-14 00:17:18 +0300
commit61378ccfcc0993744f110db89b0fea52545c1ce6 (patch)
tree6bac9707b6a7472ef80d7576366785e73c4b648f
parent891d0cb87ad98052cbd26692b61f31da9902dee1 (diff)
downloadgradecoin-61378ccfcc0993744f110db89b0fea52545c1ce6.tar.gz
gradecoin-61378ccfcc0993744f110db89b0fea52545c1ce6.tar.bz2
gradecoin-61378ccfcc0993744f110db89b0fea52545c1ce6.zip
Add new test
-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]