Skip to content

Introduce arbitrary crate - #1662

Merged
benalleng merged 4 commits into
payjoin:masterfrom
shinghim:fuzz
Aug 27, 2026
Merged

benalleng merged 4 commits into
payjoin:masterfrom
shinghim:fuzz

Conversation

@shinghim

@shinghim shinghim commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

I've written a bunch of arbitrary impls for rust-bitcoin, so I was curious if there's any interest to do it here as well. Those changes haven't been released yet but should be released in rust-bitcoin v0.33 (or whatever the next version is named), and at that point, we will be able to use them to test this crate as well. I've looked through rust-bitcoin to implement all of the types that are used here (Amount, FeeRate, Psbt, etc), so when the new release gets cut, we should be able to add a lot of extensive fuzzing here if we use arbitrary as well.

Note: There's a derive feature, but rust-bitcoin doesn't have it enabled to cut down on dependencies, so I didn't do it here either

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls

coveralls commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33098452929

Coverage decreased (-0.08%) to 86.64%

Details

  • Coverage decreased (-0.08%) from the base build.
  • Patch coverage: 15 uncovered changes across 1 file (0 of 15 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
payjoin/src/core/url.rs 15 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 16474
Covered Lines: 14273
Line Coverage: 86.64%
Coverage Strength: 343.42 hits per line

💛 - Coveralls

@shinghim
shinghim marked this pull request as draft June 19, 2026 22:15
@shinghim
shinghim force-pushed the fuzz branch 2 times, most recently from 484d96c to bfae954 Compare June 19, 2026 22:28
@shinghim
shinghim marked this pull request as ready for review June 20, 2026 01:10

@benalleng benalleng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CACK Looks like a great start. interested to see what kinds of fuzzing we can start using on the state machine with this.

Comment thread fuzz/Cargo.toml Outdated
bench = false

[[bin]]
name = "arbitrary_url"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

needs to have the full pathname here url_arbitrary_url

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done 👍🏼

@shinghim

Copy link
Copy Markdown
Contributor Author

@benalleng addressed your feedback on the target name. Anything else that needs updating before it's good to go?

@benalleng

Copy link
Copy Markdown
Collaborator

No, sorry I have just been focused on release things lately. I want to make a quick personal fork using the unreleased rust-bitcoin additions + this branch to get a better sense of what arbitrary allows us to do but after that i will be ready to ACK

@shinghim

Copy link
Copy Markdown
Contributor Author

gotcha. I had started down that road a little bit, but a lot of stuff changed in the unreleased version 😆

@benalleng

Copy link
Copy Markdown
Collaborator

General future question - are there plans to create fuzzing around ensuring live and replay paths result in the same session states?

@xstoicunicornx I am hoping that this dep addition will allow us to better fuzz the session states.

@benalleng

benalleng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

gotcha. I had started down that road a little bit, but a lot of stuff changed in the unreleased version 😆

Ok, I also tried this and ended up spending way too much time trying to patch every dep that relies on old bitcoin versions only to still got stuck. That is a big change... I will scope my test down a bit.

@benalleng benalleng mentioned this pull request Jul 3, 2026
5 tasks
@benalleng benalleng added the fuzz Relating to the payjoin-fuzz crate label Jul 16, 2026

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tACK

Ran url_arbitrary_url for 30s locally; coverage grew from 430 to 738 without saturating, which is a meaningful improvement over the existing decode_url target.

One thing worth considering in arbitrary_url.rs: append_pair is immediately followed by clear_query, so the URL always exits that branch with an empty query. If the intent is to exercise methods that read a populated query, removing clear_query (or moving it to a separate branch) would cover that path. If the intent is specifically to test clear_query after append_pair, a comment explaining that would help.

This crate is used for fuzzing and is the same crate used in
`rust-bitcoin`, which means that we will be able to use the arbitrary
types built in that crate in this one
I moved some of the logic from the existing `decode_url` target into
this one to utilize the fuzzer to test different inputs
@benalleng

benalleng commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

I added the bitcoin arbitrary feature as well here to expand our ability to add arbitrary tests and impls across a wider range of the crate with support upstream in rust-bitcoin. The single largest limitation for our needs still I would say seems to be support for bitcoin::Psbt::Arbitrary

@benalleng benalleng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ACK 439849b

@spacebear21 I will need an additional ACK here as I made the latest push

@shinghim

shinghim commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

I added the bitcoin arbitrary feature as well here to expand our ability to add arbitrary tests and impls across a wider range of the crate with support upstream in rust-bitcoin. The single largest limitation for our needs still I would say seems to be support for bitcoin::Psbt::Arbitrary

I've been trying to implement everything for PSBTs. I don't think it all made it over to the new git forge 'rust-psbt' repo yet since it's just v0.32.x stuff right now and the impls I wrote were for the v0.33.beta one. I've been waiting patiently for the bump to 0.33 😀

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utACK 439849b

@benalleng
benalleng merged commit 0bc591f into payjoin:master Aug 27, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fuzz Relating to the payjoin-fuzz crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants