gradecoin icon indicating copy to clipboard operation
gradecoin copied to clipboard

All tests are not passing

Open yagizsenal opened this issue 4 years ago • 1 comments

I don't know if I am doing anything wrong, but I created a private key in secrets/gradecoin.pem and ran cargo test. Here is the results:

   Compiling gradecoin v0.2.0 (/home/yagiz/code/personal/gradecoin)
    Finished test [unoptimized + debuginfo] target(s) in 21.04s
     Running unittests (target/debug/deps/gradecoin-5b8dcd897d5f8627)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests (target/debug/deps/main-a41d0ea5cb80ed0e)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/route_tests.rs (target/debug/deps/route_tests-0145fb9a80028179)

running 11 tests
test tests::get_pending_transactions ... ok
test tests::post_auth_json_400 ... ok
test tests::post_block_incorrect_hash ... ok
test tests::get_blockchain ... ok
test tests::post_block_with_empty_transaction_list ... ok
test tests::post_block_wrong_hash ... ok
test tests::get_nonexisting_path_404 ... ok
test tests::post_block_auth_201 ... FAILED
test tests::post_too_long_content_413 ... ok
test tests::post_auth_json_201 ... FAILED
test tests::user_authentication ... FAILED

failures:

---- tests::post_block_auth_201 stdout ----
RESPONSE: b"{\"res\":\"Error\",\"message\":\"There should be at least 8 transactions in the block\"}"
thread 'tests::post_block_auth_201' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<"0000009745f2f09c968c095af75e8ab87eba9be90a93e5df464f83ea7ec08537"
>"0000002149b72e0b348c32ac442a50ced4efbd1df7d48b377733d55dfe4f3577"

', tests/route_tests.rs:258:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- tests::post_auth_json_201 stdout ----
b"{\"res\":\"Error\",\"message\":\"Target of the transaction 31415926535897932384626433832795028841971693993751058209749445923 is not found in the system\"}"
thread 'tests::post_auth_json_201' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<400
>201

', tests/route_tests.rs:182:9

---- tests::user_authentication stdout ----
Response { status: 400, version: HTTP/1.1, headers: {"content-type": "application/json"}, body: b"{\"res\":\"Error\",\"message\":\"Failed to decrypt the 'key_ciphertext' field of the auth request\"}" }
thread 'tests::user_authentication' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<400
>201

', tests/route_tests.rs:430:9


failures:
    tests::post_auth_json_201
    tests::post_block_auth_201
    tests::user_authentication

test result: FAILED. 8 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.11s

error: test failed, to rerun pass '--test route_tests'

I think that tests post_block_auth_201 and post_auth_json_201 might be valid for an older version of the system that is updated later. I don't know about user_authentication, though.

yagizsenal avatar Sep 07 '21 19:09 yagizsenal

I could not update the tests along the code for a while so they are broken, I could clean them up and write setup functions to be reused between different tests. This is the reason post_auth_json_201 fails, since I kept changing the relevant parties from the database instead of creating a mock database for tests.

Also (iirc) some functionality do not have tests covering them, that needs to be checked out as well.

Meantime, please disregard the failing tests.

yigitsever avatar Sep 07 '21 20:09 yigitsever