cargo clippy -p mint fails on master, and the assertions it flags are vacuous #27
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
vnprc/hashpool#27
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cargo clippy -p mint --all-targetsfails on master with six errors, and the assertions it objects to are vacuous — they cannot fail on any input, so they verify nothing.Primary goals:
cargo clippy -p mint --all-targetsexits 0 on master, so it can be used as a merge gate instead of being a known-red command.assert!in the affected block either constrains something that could actually be violated, or goes away.Current state and specifics
roles/mint/tests/sv2_connection_integration.rsasserts message-type constants against the bounds of their own type:The constants are
u8and the bounds are that type's own minimum and maximum, so every one of these comparisons is always true. Clippy'sabsurd_extreme_comparisonsisdenyby default, so the run fails:Six errors in total. Reproduced on the current master tree; the file is byte-identical on master, on
agent/epoch-mechanics, and at922637e9, so this is not introduced by any open branch.The deeper problem is the one clippy is pointing at rather than the lint itself. These assertions are of the shape
allod/memoryshell.mdwarns about under assertion traps: a check that cannot be shown to fail on sabotaged input does not count. Changing any of these message-type constants to a wrong-but-in-range value leaves every assertion in the block still passing, so the test gives the appearance of pinning the wire protocol's message-type ranges while pinning nothing. If the intent is to assert that each constant sits inside the range its own protocol subspace defines, the bounds need to be those subspace limits rather than the integer type's limits; if there is no such constraint worth testing, the assertions should go.Scope
In scope:
roles/mint/tests/sv2_connection_integration.rs— fix or remove the six flagged assertions, and check the rest of that file for others of the same shape that clippy does not flag because their bounds are not the type's extremes.Out of scope: the two pre-existing
translator_sv2clippy warnings (wallet.rs:15useless conversion,channel_manager.rs:900fallible conversion), which are warnings rather than errors and are recorded nits on vnprc/hashpool#23.Validation
cargo clippy -p mint --all-targetsexits 0. Then sabotage one message-type constant to a wrong in-range value and confirm the retained assertions actually fail; if they still pass, they are still vacuous and the change is not done.