Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor network tests #16454

Merged
merged 4 commits into from
Jan 8, 2025
Merged

Conversation

dkijania
Copy link
Member

@dkijania dkijania commented Jan 7, 2025

Predecessor of #16415. Extracted mock and tests for transaction pool from transaction_pool.ml and introduced:

  • transaction_pool_mock.ml - with all necessary utilities to simulate daemon transaction pool
  • transaction_pool_tests.ml - with all existing tests for transaction pool

A few words of explanation about current split of code between mock and tests. We need to place verifier under test_module part as it fails otherwise with error:

File "src/lib/network_pool/test/dune", line 2, characters 8-12:
2 |  (names main)
            ^^^^
{"timestamp":"2025-01-07 17:24:03.028851Z","level":"Info","source":{"module":"Verifier__Prod","location":"File \"src/lib/verifier/prod.ml\", line 421, characters 4-15"},"message":"Starting a new verifier process","metadata":{}}
Uncaught exception:
  
  (monitor.ml.Error
   "You must initialize this process to run as a master before calling [spawn]. Either use a top-level [start_app] call or use the [Expert] module."
   ("Raised at Base__Error.raise in file \"src/error.ml\" (inlined), line 8, characters 14-30"
    "Called from Base__Or_error.ok_exn in file \"src/or_error.ml\", line 84, characters 17-32"
    "Called from Async_kernel__Deferred1.M.map.(fun) in file \"src/deferred1.ml\", line 17, characters 40-45"
    "Called from Async_kernel__Job_queue.run_job in file \"src/job_queue.ml\" (inlined), line 128, characters 2-5"
    "Called from Async_kernel__Job_queue.run_jobs in file \"src/job_queue.ml\", line 169, characters 6-47"
    "Caught by monitor Verifier RPC worker at file \"src/lib/verifier/prod.ml\", line 435, characters 29-29"))

Raised at Base__Result.ok_exn in file "src/result.ml" (inlined), line 201, characters 17-26
Called from Async_unix__Thread_safe.block_on_async_exn in file "src/thread_safe.ml", line 132, characters 29-63
Called from Async_unix__Thread_safe.block_on_async_exn in file "src/thread_safe.ml" (inlined), line 181, characters 27-54
Called from Network_pool__Test_utils.verifier in file "src/lib/network_pool/test_utils.ml", line 53, characters 6-299

That's why mock accepts all parameters like genesis_constants and constraint_constants

…ce test utils which holds all mocking utilities
@dkijania dkijania self-assigned this Jan 7, 2025
@dkijania
Copy link
Member Author

dkijania commented Jan 7, 2025

!ci-build-me

@dkijania dkijania force-pushed the dkijania/reorg_transaction_pool_tests branch from b90674b to 78a3628 Compare January 7, 2025 23:20
@dkijania
Copy link
Member Author

dkijania commented Jan 7, 2025

!ci-build-me

@dkijania dkijania marked this pull request as ready for review January 8, 2025 08:12
@dkijania dkijania requested a review from a team as a code owner January 8, 2025 08:12
@dkijania
Copy link
Member Author

dkijania commented Jan 8, 2025

!ci-nightly-me

@dkijania dkijania changed the title refactor network test. extract tests into separate module and introdu… refactor network tests Jan 8, 2025
@dkijania
Copy link
Member Author

dkijania commented Jan 8, 2025

@dkijania dkijania force-pushed the dkijania/reorg_transaction_pool_tests branch from e8e1e40 to 78a3628 Compare January 8, 2025 15:24
Copy link
Member

@georgeee georgeee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review in full all of the mock internals, but I assume they were just copy-pasted with adding some additional functional parameters. Changes to tests look great!


let verifier =
Async.Thread_safe.block_on_async_exn (fun () ->
Verifier.For_tests.default ~logger ~proof_level ~conf_dir:None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Verifier.For_tests.default ~logger ~proof_level ~conf_dir:None
Verifier.For_tests.default ~logger ~proof_level:Full ~conf_dir:None

And let's remove declaration verifier_full below in this file

@dkijania
Copy link
Member Author

dkijania commented Jan 8, 2025

!ci-build-me

@dkijania dkijania requested a review from a team as a code owner January 8, 2025 19:26
@dkijania dkijania force-pushed the dkijania/reorg_transaction_pool_tests branch from 011e256 to dbc1ba0 Compare January 8, 2025 19:29
@dkijania dkijania removed the request for review from a team January 8, 2025 19:32
@dkijania dkijania merged commit 40c86e2 into compatible Jan 8, 2025
44 checks passed
@dkijania dkijania deleted the dkijania/reorg_transaction_pool_tests branch January 8, 2025 19:33
dkijania added a commit that referenced this pull request Jan 9, 2025
…ansaction_pool_tests"

This reverts commit 40c86e2, reversing
changes made to de1f5e0.
dkijania added a commit that referenced this pull request Jan 9, 2025
…ansaction_pool_tests"

This reverts commit 40c86e2, reversing
changes made to de1f5e0.
dannywillems pushed a commit that referenced this pull request Jan 12, 2025
…ansaction_pool_tests"

This reverts commit 40c86e2, reversing
changes made to de1f5e0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants