Skip to content

[RFC] remove the cfg test that it is not needed in a error code path #3605

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

Merged

Conversation

vincenzopalazzo
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo commented Feb 16, 2025

Trying to determine why the CI is failing (appears specific to Rust 1.63), likely due to changes in Clippy’s warning emission.

However, this commit is changing the code and not just fixing the warning because I am not able to understand why we should skip this code during tests?

I am probably missing some context here but for now I will open the PR anyway

The code is introduced in 068549d#diff-645d12c7269d09caab57d2e0c1fd34f672ee259994c86ad4bad7f4da9183671cR8289-R8290


     Running `rustc --crate-name lightning --edition=2021 lightning/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=1 -C lto=off -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on --test --cfg 'feature="default"' --cfg 'feature="grind_signatures"' --cfg 'feature="std"' -C metadata=7f2d308b97eed1fd -C extra-filename=-7f2d308b97eed1fd --out-dir /home/runner/work/rust-lightning/rust-lightning/target/debug/deps -C incremental=/home/runner/work/rust-lightning/rust-lightning/target/debug/incremental -L dependency=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps --extern bech32=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libbech32-16d69ba236ca57d8.rlib --extern bitcoin=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libbitcoin-eca0fe041fbfc4dc.rlib --extern dnssec_prover=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libdnssec_prover-1dd31ceabfa87dd5.rlib --extern hashbrown=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libhashbrown-d9958110f8162c77.rlib --extern libm=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblibm-274dde3847e6cc8d.rlib --extern lightning_invoice=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_invoice-56ed15b130ee9288.rlib --extern lightning_macros=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_macros-528cdf9e072c4caf.so --extern lightning_types=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_types-2a1be369ae37a72c.rlib --extern possiblyrandom=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libpossiblyrandom-5fb85e240a23737f.rlib --extern regex=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libregex-187d4eaedfe307ba.rlib -D warnings -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/bitcoinconsensus-9dfaf2ad2edfe5f6/out -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/bitcoinconsensus-9dfaf2ad2edfe5f6/out -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/secp256k1-sys-44754c91469ec6ec/out`
error: constant `MAX_PEER_STORAGE_SIZE` is never used
    --> lightning/src/ln/channelmanager.rs:2882:1
     |
2882 | const MAX_PEER_STORAGE_SIZE: usize = 1024;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `-D dead-code` implied by `-D warnings`

error: could not compile `lightning` due to previous error

looking at the code, the #[cfg(not(test))] is not needed, so I remove it
because the CI is failing for some reason on the following code path
with rustc 1.63

     Running `rustc --crate-name lightning --edition=2021 lightning/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=1 -C lto=off -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on --test --cfg 'feature="default"' --cfg 'feature="grind_signatures"' --cfg 'feature="std"' -C metadata=7f2d308b97eed1fd -C extra-filename=-7f2d308b97eed1fd --out-dir /home/runner/work/rust-lightning/rust-lightning/target/debug/deps -C incremental=/home/runner/work/rust-lightning/rust-lightning/target/debug/incremental -L dependency=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps --extern bech32=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libbech32-16d69ba236ca57d8.rlib --extern bitcoin=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libbitcoin-eca0fe041fbfc4dc.rlib --extern dnssec_prover=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libdnssec_prover-1dd31ceabfa87dd5.rlib --extern hashbrown=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libhashbrown-d9958110f8162c77.rlib --extern libm=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblibm-274dde3847e6cc8d.rlib --extern lightning_invoice=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_invoice-56ed15b130ee9288.rlib --extern lightning_macros=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_macros-528cdf9e072c4caf.so --extern lightning_types=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/liblightning_types-2a1be369ae37a72c.rlib --extern possiblyrandom=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libpossiblyrandom-5fb85e240a23737f.rlib --extern regex=/home/runner/work/rust-lightning/rust-lightning/target/debug/deps/libregex-187d4eaedfe307ba.rlib -D warnings -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/bitcoinconsensus-9dfaf2ad2edfe5f6/out -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/bitcoinconsensus-9dfaf2ad2edfe5f6/out -L native=/home/runner/work/rust-lightning/rust-lightning/target/debug/build/secp256k1-sys-44754c91469ec6ec/out`
error: constant `MAX_PEER_STORAGE_SIZE` is never used
    --> lightning/src/ln/channelmanager.rs:2882:1
     |
2882 | const MAX_PEER_STORAGE_SIZE: usize = 1024;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `-D dead-code` implied by `-D warnings`

error: could not compile `lightning` due to previous error

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo vincenzopalazzo changed the title remove the cfg test that it is not needed remove the cfg test that it is not needed in a error code path Feb 16, 2025
@vincenzopalazzo vincenzopalazzo changed the title remove the cfg test that it is not needed in a error code path [RFC] remove the cfg test that it is not needed in a error code path Feb 16, 2025
Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.60%. Comparing base (bce5db7) to head (0a5a7d9).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3605   +/-   ##
=======================================
  Coverage   88.60%   88.60%           
=======================================
  Files         149      149           
  Lines      116878   116877    -1     
  Branches   116878   116877    -1     
=======================================
  Hits       103557   103557           
- Misses      10798    10810   +12     
+ Partials     2523     2510   -13     

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

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.

Thanks. i think later PRs using the peer storage stuff have tests that rely on being able to store more, but we can change this when those PRs come up. In the mean time, CI needs to pass.

@TheBlueMatt TheBlueMatt merged commit 2d2c542 into lightningdevkit:main Feb 16, 2025
24 of 26 checks passed
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.

2 participants