refactor(executor): move inline unit tests to src/tests/ module#619
refactor(executor): move inline unit tests to src/tests/ module#619diegokingston wants to merge 2 commits into
Conversation
Relocates the three inline `#[cfg(test)] mod tests` blocks in executor/src into a dedicated `executor/src/tests/` module, matching the convention already used by the prover and math crates. - flamegraph.rs -> tests/flamegraph_tests.rs (demangle) - vm/instruction/execution.rs -> tests/keccak_tests.rs (keccak-f[1600] + syscall) - vm/memory.rs -> tests/memory_tests.rs (public output, load bounds) `demangle` and `Memory::set_bytes_aligned` were module-private; bumped to pub(crate) so the relocated tests can reach them. No test logic changed.
Codex Code ReviewNo security vulnerabilities, behavioral bugs, or significant performance issues found in the PR diff. One minor cleanliness note: I attempted |
| @@ -1,3 +1,4 @@ | |||
| pub mod elf; | |||
| pub mod flamegraph; | |||
| pub mod tests; | |||
There was a problem hiding this comment.
Bug (Medium): Missing #[cfg(test)] gate — this is the exact convention the PR claims to match.
Both prover/src/lib.rs and crypto/math/src/lib.rs declare this as:
#[cfg(test)]
pub mod tests;Without the gate, the tests module is compiled into every non-test build and becomes part of the crate's public API (visible as executor::tests). It will be an empty module in non-test builds (since all sub-modules in mod.rs are individually gated), but it still pollutes the public surface.
| pub mod tests; | |
| #[cfg(test)] | |
| pub mod tests; |
| /// Helper method to store a given input at an aligned address. It may also overwrite existing bytes with zero if inputs is not divisible by 4 | ||
| /// Should only be used to write to public output and private input where these limitations are not a problem | ||
| fn set_bytes_aligned(&mut self, mut addr: u64, inputs: &[u8]) -> Result<(), MemoryError> { | ||
| pub(crate) fn set_bytes_aligned( |
There was a problem hiding this comment.
Low: The doc comment on this function already warns it "Should only be used to write to public output and private input where these limitations are not a problem." Widening it to pub(crate) to serve only tests means any future code in the crate can accidentally call it outside those two intended sites. Consider keeping it pub(super) or using a test-only re-export instead.
ReviewClean refactor overall — test bodies are moved verbatim and the logic is unchanged. One bug to fix before merging, plus a minor nit. Bug — missing
|
|
Benchmark Results for unmodified programs 🚀
|
Summary
Relocates the three inline
#[cfg(test)] mod testsblocks inexecutor/srcinto a dedicatedexecutor/src/tests/module, matching the convention already used by theproverandmathcrates.flamegraph.rstests/flamegraph_tests.rsdemanglevm/instruction/execution.rstests/keccak_tests.rsvm/memory.rstests/memory_tests.rsdemangleandMemory::set_bytes_alignedwere module-private; bumped topub(crate)so the relocated tests can reach them. No test logic changed — bodies moved verbatim, onlyuse super::*rewritten to explicitcrate::paths.Test plan
cargo clippy -p executor --all-targets -- -D warnings— cleancargo test -p executor --lib— 12 passed (1 demangle + 4 keccak + 7 memory)