Skip to content

Introduce arbitrary crate#1662

Open
shinghim wants to merge 4 commits into
payjoin:masterfrom
shinghim:fuzz
Open

Introduce arbitrary crate#1662
shinghim wants to merge 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 28033333118

Coverage decreased (-0.09%) to 85.121%

Details

  • Coverage decreased (-0.09%) 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: 14766
Covered Lines: 12569
Line Coverage: 85.12%
Coverage Strength: 369.79 hits per line

💛 - Coveralls

@shinghim shinghim marked this pull request as draft June 19, 2026 22:15
shinghim added 3 commits June 19, 2026 17:28
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
@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 👍🏼

I moved some of the logic from the existing `decode_url` target into
this one to utilize the fuzzer to test different inputs
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants