nervosnetwork / ckb

The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.
https://www.nervos.org
MIT License
1.15k stars 228 forks source link

Fix Unit Test: `Shared::with_temp_db` should use a non-exist path #4369

Closed eval-exec closed 1 month ago

eval-exec commented 6 months ago

What problem does this PR solve?

Shared::with_temp_db is only used by unit test, and the rocksdb should be inited in a non exist path.

In the develop branch, if I assert that the path db_base_dir in Shared::with_temp_db does not exist, I encounter the following error:

$ make test
--- STDERR:              ckb-verification-contextual tests::uncle_verifier::test_uncle_over_count ---
thread 'tests::uncle_verifier::test_uncle_over_count' panicked at 'In test code, Shared::with_temp_db created a db path that already exist: /run/user/1000/.tmpUXdHrL, db_id: 0', shared/src/shared_builder.rs:185:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

        FAIL [   0.012s] ckb-verification-contextual tests::uncle_verifier::test_uncle_proposals_hash

--- STDOUT:              ckb-verification-contextual tests::uncle_verifier::test_uncle_proposals_hash ---

running 1 test
test tests::uncle_verifier::test_uncle_proposals_hash ... FAILED

failures:

failures:
    tests::uncle_verifier::test_uncle_proposals_hash

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

--- STDERR:              ckb-verification-contextual tests::uncle_verifier::test_uncle_proposals_hash ---
thread 'tests::uncle_verifier::test_uncle_proposals_hash' panicked at 'In test code, Shared::with_temp_db created a db path that already exist: /run/user/1000/.tmpmjLMrO, db_id: 0', shared/src/shared_builder.rs:185:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

        FAIL [   0.013s] ckb-verification-contextual tests::uncle_verifier::test_uncle_with_uncle_descendant

--- STDOUT:              ckb-verification-contextual tests::uncle_verifier::test_uncle_with_uncle_descendant ---

running 1 test
test tests::uncle_verifier::test_uncle_with_uncle_descendant ... FAILED

failures:

failures:
    tests::uncle_verifier::test_uncle_with_uncle_descendant

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

--- STDERR:              ckb-verification-contextual tests::uncle_verifier::test_uncle_with_uncle_descendant ---
thread 'tests::uncle_verifier::test_uncle_with_uncle_descendant' panicked at 'In test code, Shared::with_temp_db created a db path that already exist: /run/user/1000/.tmpYeObhI, db_id: 0', shared/src/shared_builder.rs:185:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: test run failed
make: *** [Makefile:33: test] Error 100

What's Changed:

Related changes

Check List

Tests

Side effects

Release note

None: Exclude this PR from the release note.
github-actions[bot] commented 1 month ago

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.