0xMiden / 0xMiden/node

Consistency tests, test utils and expose test helpers

Đang mở
#1,233 1 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
104
Fork
138
Merge trung bình
1 ngày 13 giờ
Pull request đã merge (30 ngày)
56

Mô tả

Currently we still have a few `testing` flags that expose additional public API. Oftentimes we do this to provide API we do not want to become public API, deliberately.

Proposal on directory structuring:

* always make `mod tests;` a separate file, but keep them in the same directory and crate
* move any mocking or dummy generation utilities for tests specifically into a `${cratename}-test-helpers` crate living in the same directory, this one can and _should_ depend on the `${cratename}`, it's for use by other crates - particularly useful for projects with more and smaller crates - we should strive in that direction

with these two small changes, test utilities are moved always where they should be, outside the actual crate and hence not public API, yet it's a unified place and naming scheme how to depend on them / find them

# Proposal on feature `"testing"` removal

The intent is to expose an API that is commonly not meant to be used by users.

While I do see the value in an established set of libraries, I recommend to expose more of `X::dangerous_construct` or `X::new_unchecked` (the latter is also present in the rust std library, commonly used with unsafe, where the former is used in codebases that want delineate logic assumptions vs memory safety, I would recommend to use the former unless it's a mem saftey issue specifically since the code doesn't become any cleaner sprinkling `unsafe {}` into it).

The risk of additive features is a single slip-up, taking a shortcut for a needed API gated behind `testing`, effectively makes all of that crates API public API through the feature unification path of `cargo`.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.