Introduce directory feature module#502
Conversation
Pull Request Test Coverage Report for Build 12920617811Details
💛 - Coveralls |
6c2e4f0 to
23ebacc
Compare
23ebacc to
da07cf9
Compare
spacebear21
left a comment
There was a problem hiding this comment.
I'm not sure I really understand the motivation for splitting v1 modules into exclusive v. shared (adding complexity). Is there a significant impact from exporting those features when v1 is not explicitly enabled?
| @@ -1,3 +1,4 @@ | |||
| #[cfg(all(feature = "v1", feature = "v2"))] | |||
There was a problem hiding this comment.
This would remove the ability to run integration tests for v2 only (or for v1 only).
| #[cfg(all(feature = "v1", feature = "v2"))] | |
| #[cfg(any(feature = "v1", feature = "v2"))] |
Actually, this is probably the reason for the drastic coverage reduction.
There was a problem hiding this comment.
Hmm. I changed this because we're depending on payjoin::receive::v1::build_v1_pj_uri for both v1 and v2 tests. Why do you think this would reduce coverage? Because some runs would not check branches that they previously had, even though all of the same lines are still covered? That doesn't make sense to me.
There was a problem hiding this comment.
I see now, our coverage script:
cargo llvm-cov --no-report --no-default-features --features=v1,_danger-local-https
cargo llvm-cov --no-report --no-default-features --features=v2,_danger-local-https,io
Doesn't test the two in tandem since the integration/v2 test module now depends on the v1 feature since there are many v2 tests that test backwards compatibility.
We can combine these to use cargo llvm-cov --no-report --all-features now since everything is additive. That ensures the directory feature is tested too.
There was a problem hiding this comment.
contrib/coverage.sh runs the tests like this:
cargo llvm-cov --no-report --no-default-features --features=v1,_danger-local-https
cargo llvm-cov --no-report --no-default-features --features=v2,_danger-local-https,io
Default features are disabled, so the first command wouldn't pass the cfg check.
Though now that features are additive maybe these two commands can be combined with --all-features.
(The same applies to lint and test scripts)
payjoin/src/receive/v1/mod.rs
Outdated
| let pairs = url::form_urlencoded::parse( | ||
| "maxadditionalfeecontribution=182&additionalfeeoutputindex=0".as_bytes(), | ||
| ); | ||
| let params = Params::from_query_pairs(pairs, &[1])?; | ||
| Ok(UncheckedProposal { psbt: bitcoin::Psbt::from_str(original_psbt)?, params }) |
There was a problem hiding this comment.
Note: with this change, UncheckedProposal::from_request is no longer covered by unit tests. It's still covered in v1 integration tests. We may want to consider adding a unit test to exclusive/mod.rs.
My motivation was to isolate v1-specific public API so that it could be exposed as a default-off feature. I figured it made it even more obvious the v2 feature was first-class, and was also useful in organizing the Is this overly complex and contrived? It did feel a bit leaky to use the v1 stuff to test exclusively v2 and not depend on v1 to test the v2_to_v1 / v1_to_v2 stuff |
`bitcoin::psbt::Error` is a type of PayloadError non-exclusive to v1
e96d597 to
b976a09
Compare
The exclusive module is used only when v1 is explicitly enabled. Shared components are `pub(crate)` and used when the v2 feature is enabled but not exported.
b976a09 to
d865a66
Compare
Allow payjoin and payjoin-directory to share ShortId code.
This is a BIP 77 directory-specific constant
|
Coverage fixed. Looks like once errors are stabilized and tested we might hit 80% coverage from that alone |
d865a66 to
6580519
Compare
The `exclusive` module separation stopped this unit from being tested.

other constants (like tag size) seem more appropriate for bitcoin_hpke or bitcoin_ohttp to define than for the directory module.
Close #418
In order to allow
directoryto be used independetly, I needed to make the_corefeature compilesendandreceivemodules, and madev1andv2features export their feature modules explicitly. That way whendirectoryis enabled explicitly with no-default-features no other code gets compiled.Some exclusive v1 features are used for testing v2, so perhaps these should be exported in
_test-utilas well i.e.#[cfg(any(feature = "v1", feature = "_test-util")]in a follow up.@nothingmuch This also revealed some indirection in the
bech32module, where some of it is used fordirectoryand some forv2OhttpKeys serialization. How essential is thebech32::nochecksummodule? Perhaps the bech32 calls should be made directly with theNoChecksumgeneric parameter and the tests should be placed aroundOhttpKeysanddirectory::ShortIdimplementations directly.I'm not completely sure why the coverage was reduced so much by placing some features in the exclusive submodule, but this will be covered when the json error serialization and error stabililzation issues are addressed.