Skip to content

fuzz: Add LSPS message decoder fuzzing #3849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

martinsaposnic
Copy link
Contributor

Fixes #3515

The fuzz test tests the LiquidityManager's ability to parse and handle arbitrary LSPS message data safely.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 12, 2025

👋 I see @jkczyz was un-assigned.
If you'd like another reviewer assignemnt, please click here.

@ldk-reviews-bot ldk-reviews-bot requested a review from jkczyz June 12, 2025 14:53
@tnull tnull requested review from tnull and removed request for jkczyz June 12, 2025 18:48
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

One comment, otherwise lgtm

let msg_router =
Arc::new(DefaultMessageRouter::new(network_graph.clone(), Arc::clone(&keys_manager)));
let chain_source = Arc::new(TestChainSource::new(Network::Bitcoin));
let kv_store = Arc::new(FilesystemStore::new("persister".into()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use a test persister rather than something that could write to the fs in a fuzz target?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we should just be able to use the in-memory lightning::util::test_utils::TestStore for this?

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM, mod one nit and the pending question regarding the KVStore.

Great start for lightning-liquidity fuzzing!

let seed = sha256::Hash::hash(b"lsps-message-seed").to_byte_array();
let keys_manager = Arc::new(KeysManager::new(&seed, now.as_secs(), now.subsec_nanos()));
let router = Arc::new(DefaultRouter::new(
network_graph.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Given we're about to enable a lint enforcing to use Arc::clone vs. arc.clone() in #3851, let's switch all of these to Arc::clone pls.

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.92%. Comparing base (b8673f3) to head (d8176d1).
Report is 46 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3849      +/-   ##
==========================================
+ Coverage   89.88%   89.92%   +0.04%     
==========================================
  Files         162      163       +1     
  Lines      130415   131655    +1240     
  Branches   130415   131655    +1240     
==========================================
+ Hits       117217   118394    +1177     
- Misses      10509    10571      +62     
- Partials     2689     2690       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Fuzz lightning-liquidity message decoders
4 participants