Skip to content

Separate send version modules (part 1)#453

Merged
DanGould merged 4 commits intopayjoin:masterfrom
DanGould:separate-send-versions-p1
Jan 2, 2025
Merged

Separate send version modules (part 1)#453
DanGould merged 4 commits intopayjoin:masterfrom
DanGould:separate-send-versions-p1

Conversation

@DanGould
Copy link
Contributor

@DanGould DanGould commented Jan 2, 2025

The goal of this PR is to expose descriptive, accurate send errors so that we can switch on them in implementations and mark payjoin sessions in persistent storage accurately. We only want to spawn sessions that are capable of making forward progress and drop those that cannot.

Patch overview:

  1. housekeeping
  2. Introduce specific SenderBuilder errors
  3. make CreateRequestError v2 only since v1 can only make have sender builder errors
  4. separate the modules to reduce feature flags

This separation is incomplete because I'm still uncertain what to do with send::ValidationError's feature gated variants. Do I make a send::ValidationError and a send::v2::ValidationError separate? How do those get handled in ResponseError? Does ResponseError get split into two versions, or do I just leave a feature gated variant? That's left for the next PR predicated on this design being an appropriate one.

Note this pays back some tech debt but leaves some slop in payjoin-cli. Rather than making this PR 10 commits to review I left combining FeeRate parsing to a later PR (#452).

This error puts us on the path to #392 and #403

@coveralls
Copy link
Collaborator

coveralls commented Jan 2, 2025

Pull Request Test Coverage Report for Build 12586246418

Details

  • 311 of 417 (74.58%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 61.742%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/mod.rs 0 2 0.0%
payjoin-cli/src/app/v1.rs 0 7 0.0%
payjoin-cli/src/app/v2.rs 0 7 0.0%
payjoin/src/send/v2/mod.rs 180 187 96.26%
payjoin/src/send/mod.rs 7 16 43.75%
payjoin/src/send/v2/error.rs 5 22 22.73%
payjoin/src/send/v1.rs 119 140 85.0%
payjoin/src/send/error.rs 0 36 0.0%
Totals Coverage Status
Change from base Build 12586213780: 0.008%
Covered Lines: 2942
Relevant Lines: 4765

💛 - Coveralls

Copy link
Collaborator

@nothingmuch nothingmuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd commit message has a typo ("it's" instead of "its")

i did not carefully scrutinize the big moves so may have missed small differences if those were introduced

everything else looks good to me, and there is some overlap with stuff i haven't PR'ed yet which is a good indication that we have the same ideas for how the payjoin-cli code can be improved

This error is the first one that appears in the state machine.
SenderBuilder was using vestigial CreateRequestError even though
it was not creating any requests. It only produces errors when
building Sender. Define a BuildSenderError and Internal counterpart
separate from CreateRequestError.
Use best practice `new` instead of `from_request_and_uri`, and
provide an accurate docstring.
@DanGould DanGould force-pushed the separate-send-versions-p1 branch from fb946e9 to 8480c3c Compare January 2, 2025 17:25
Its variants only apply to extracting v2 requests.
This reduces the number of feature gates and works toward a crate
where the features are additive and potentially both available
at the same time.

Right now they're still mutually exclusive (v1 is enabled by not(v2))
@DanGould
Copy link
Contributor Author

DanGould commented Jan 2, 2025

Rebased on master and commit message amended to fix spelling error. Going to merge if tests pass

@DanGould DanGould merged commit 592d1d2 into payjoin:master Jan 2, 2025
6 checks passed
@DanGould DanGould deleted the separate-send-versions-p1 branch January 2, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants