p2p_io_scheduler: test read* functions
Fixes #1534 (closed)
Context
There is ongoing effort to make lib_p2p
more tested and more amenable to tests, via refactorings and abstractions. This MR is part of this larger plan. It is in draft at the moment, as only one tests was written. The point is to gather feedback.
Note that we take this opportunity to propose renaming len
to length_to_copy
to clarify its different meaning compared to a buffer length (which is its total size).
This MR is intentionally split into various commits to help reviewing. We recommend reviewing commit by commit for simplicity.
test_p2p_buffer_reader.ml
alone provides 90% code coverage on P2p_reader. The remaining 10% are:
- the encoding of the error
-
!3194 (diffs): one error case in
read_full
that I never managed to trigger...(fun _ -> fail P2p_errors.Connection_closed)
To generate the coverage report you can run:
$ rm _coverage_output/* && \
BISECT_FILE=$(pwd)/_coverage_output/ dune build @src/lib_p2p/test/runtest_p2p_buffer_reader -f --instrument-with bisect_ppx && \
make coverage-report && \
<your favorite web browser> _coverage_report/index.html
Manually testing the MR
dune build @src/lib_p2p/test/runtest_p2p_buffer_reader
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Provide automatic testing (see the testing guide). -
-opam
branch: smelc-p2p-io-scheduler-test-reads-opam
Edited by Clément Hurlin