AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 15 Bitcoin

Merge rust-bitcoin/rust-bitcoin#6836: bitcoin: move tests reading `tests/data` out of `src`

Public commit record

What the developer wrote

Authored by Andrew Poelstra

100/100 · Strong
Merge rust-bitcoin/rust-bitcoin#6836: bitcoin: move tests reading `tests/data` out of `src`

b4068f4ccdfca76160893252f50c90385c815a16 p2p: move merkle_tree tests to tests/ (satsfy (Renato Britto))
a0285f0094c45870fcded03be7bddf5ac97c5c10 bitcoin: move sighash tests to tests/ (satsfy (Renato Britto))
546c31d40f6c53a3489a41d70453d235afe7efe2 bitcoin: move taproot test to tests/ (satsfy (Renato Britto))
2c248d2cae77495c2e224f8029e22aec3bf3161f bitcoin: move bip158 test to tests/ (satsfy (Renato Britto))
2dcd5ab3bc085b5231becc42f05eeadc1d05aa3e bitcoin: move block test to tests/ (satsfy (Renato Britto))
8725bffa9e012aaabd31f95bad6d024b1707e952 bitcoin: move transaction test to tests/ (satsfy (Renato Britto))

Pull request description:

Closes https://github.com/rust-bitcoin/rust-bitcoin/issues/6509
Inspired on https://github.com/rust-bitcoin/rust-bitcoin/pull/6311

We have test data in `<crate>/tests/data`. Folder `tests/` are excluded when publishing (`exclude = ["tests"]`). The problem is that some `<crate>/src/<test code>.rs` used macros like `include_str!()` or `include_bytes!()` importing data that gets excluded in published code, so the published unit tests would not compile.

This PR moves all data-based tests to folder `tests/`.

One friction point is: `tests/` only see public api from crate. So if a test imported from `tests/` using crate internal non-pub code, we would need to either add some way to access it or inline. I inlined some test vectors to cover these tests and kept them in crate code (only the first `keyPathSpending` vector of `bip341_tests.json` because `common_cache` and `taproot_cache` are private).

Note on commits: I separated them by move for ease of review. I don't like that we have so many, but its the tradeoff.


ACKs for top commit:
apoelstra:
ACK b4068f4ccdfca76160893252f50c90385c815a16; successfully ran local tests
tcharding:
ACK b4068f4ccdfca76160893252f50c90385c815a16


Tree-SHA512: 7744138905453022c06cd58ef6357537fb0e27e018932b15653caeacaa6bf10a8517d3c949ac1a72d5743e24567190727178ff28bf41c5b19b8b08666db1e3da
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit is a housekeeping change that moves test files from inside the library source code to a separate tests folder. It does not change any production code or fix a security bug. The change makes sure that tests which need data files still work after the crate is published, because the test data folder is excluded from published packages.

Recommended action

No security action required. Treat as normal maintenance/test refactor.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.