aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralpaylan2021-04-16 04:19:40 +0300
committeralpaylan2021-04-16 04:19:40 +0300
commitee16f0e9f03d9d25c10419f3ab0013bbdc3e892e (patch)
treec0dcb96f51e5386306d6dc78d22b1c6939c653ee
parent80cadecb77c048b5e18630c1a153949e69714a31 (diff)
downloadgradecoin-ee16f0e9f03d9d25c10419f3ab0013bbdc3e892e.tar.gz
gradecoin-ee16f0e9f03d9d25c10419f3ab0013bbdc3e892e.tar.bz2
gradecoin-ee16f0e9f03d9d25c10419f3ab0013bbdc3e892e.zip
work on post auth transaction 201 test
-rw-r--r--src/handlers.rs5
-rw-r--r--tests/route_tests.rs8
2 files changed, 5 insertions, 8 deletions
diff --git a/src/handlers.rs b/src/handlers.rs
index e76e72f..376d079 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -608,10 +608,7 @@ pub async fn authorized_propose_transaction(
608 // this transaction was already checked for correctness at custom_filters, we can panic here if 608 // this transaction was already checked for correctness at custom_filters, we can panic here if
609 // it has been changed since 609 // it has been changed since
610 610
611 let hashed_transaction = Md5::digest(&serde_json::to_vec(&new_transaction).unwrap()); 611 let hashed_transaction = Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref());
612 println!("{:?}", new_transaction);
613 println!("{:?}", &serde_json::to_vec(&new_transaction).unwrap());
614 println!("{:x}", hashed_transaction);
615 if token_payload.claims.tha != format!("{:x}", hashed_transaction) { 612 if token_payload.claims.tha != format!("{:x}", hashed_transaction) {
616 println!( 613 println!(
617 "the hash of the request {:x} did not match the hash given in jwt {:?}", 614 "the hash of the request {:x} did not match the hash given in jwt {:?}",
diff --git a/tests/route_tests.rs b/tests/route_tests.rs
index bae58ee..e00510e 100644
--- a/tests/route_tests.rs
+++ b/tests/route_tests.rs
@@ -131,8 +131,8 @@ FQIDAQAB
131 } 131 }
132 fn mocked_transaction2() -> Transaction { 132 fn mocked_transaction2() -> Transaction {
133 Transaction { 133 Transaction {
134 by: "mock_transaction_source".to_owned(), 134 by: "mock_transaction_source2".to_owned(),
135 source: "mock_transaction_source".to_owned(), 135 source: "mock_transaction_source2".to_owned(),
136 target: "mock_transaction_target".to_owned(), 136 target: "mock_transaction_target".to_owned(),
137 amount: 25, 137 amount: 25,
138 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 09).and_hms(14, 30, 00), 138 timestamp: chrono::NaiveDate::from_ymd(2021, 04, 09).and_hms(14, 30, 00),
@@ -214,8 +214,8 @@ FQIDAQAB
214 214
215 let res = warp::test::request() 215 let res = warp::test::request()
216 .method("POST") 216 .method("POST")
217 .json(&mocked_transaction()) 217 .json(&mocked_transaction2())
218 .header("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aGEiOiJmODRmNTBjNjZkNDdhZTAzNzcwZjY0ZjUwMDgzMTAwMSIsImlhdCI6MTUxNjIzOTAyMiwiZXhwIjoyMDE2MjM5MDIyfQ.APOAH0nOqxnW5FoRjM-T9Mm0VThLrDZspKeTGXioKZJNkAMc6ZbQ_wqdvRXG-GRzivyVAW8849kbnQ-smWFHQjftKEF-aiKxWeO17vsQ4j5I9UdwwPJpGDbxU5vBgLAPXYG8wEndvC4bgy_a0P3FAlD8gIHebMh1YsbyfyEc6DFD4nvZwHzRFJtR43xRfCVgFAjSF_pB5YPAccB0DmYz_uKaGj69-9eNQYKr6giwXaiYIcF-G561kKLmTFPjCuACYNLMHONjwg8i0pT-tdiZgS7SiiWAOAo_98X54W0bCvn6i5tUPpzWKv61QXCWDdHi831YA8kMNJ2az_baRMtmhg") 218 .header("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aGEiOiI2NDNmOGYzMjkxNTMzNTMzOTcwMDZmNjVmOWQ1ZmViMyIsImlhdCI6MTUxNjIzOTAyMiwiZXhwIjoyMDE2MjM5MDIyfQ.yNca1RJOkSEKoF7S4PSF4iB8zmnj13ujcfsdVRcJMcQNN4CxP-pJwbUBdRgR8kNwdfLP3nLo0UBwevP42TBoujMKx7oaIl-JXsO37x7Y9GWMAHYBxEOoq1EsBeaxv9pCdyZvuVeJYIMrOpzW7oTcF4tHHvmvySD2ITnQTWu_ioCXEFdX21QQIvsqpRn7XumfCMvWfUy_C2XTFIQEAGdakPmkZ2Xt66k9zhT9hazJgAwELv5VyMV54iF8vyvvmnLkiODwTt_8VdqC6fr6jPwYaP1mzgd58r0fM76Wu0g9tIXVU83rcFMRsm_faXGbsrDJIQ06-fAO_D1sh74fhndK_g")
219 .path("/transaction") 219 .path("/transaction")
220 .reply(&filter) 220 .reply(&filter)
221 .await; 221 .await;