HTLC: add two coverage tests found by mutation sweep#172
Merged
Conversation
A Haiku mutation-testing pass (16 mutations across validateClaim / validateRefund / upperBoundTime / lowerBoundTime / countScriptInputs / extractPubKeyHash) surfaced two survived mutants not pinned by the existing suite: - upperBoundTime mapping `Finite t False -> t - 1`: dropping the `-1` kept existing tests green because they only exercised the exactly-at-timeout case. Add a positive test where an exclusive upper bound one step below timeout (effective upperBound=99) must succeed. - countScriptInputs fallthrough `_ -> acc`: flipping to `_ -> acc + 1` would miscount pubkey inputs as our script. Add a positive test where a pubkey input is co-spent alongside the script input and the claim must still succeed.
There was a problem hiding this comment.
Pull request overview
Adds two new HTLC claim-path regression tests identified by mutation testing to ensure the existing validator behavior is fully pinned (no validator logic changes).
Changes:
- Add a positive claim test covering the exclusive finite upper-bound mapping case (
Finite t Exclusive), ensuring the off-by-one handling is exercised. - Add a positive claim test ensuring co-spending a pubkey input does not affect the “double satisfaction” guard (script-input counting only considers
ScriptCredentialinputs).
Rename the positive exclusive-upper-bound test and rephrase its
comment so that the name matches the actual raw bound value. Old name
('just before timeout+1') borrowed the 'timeout+1' hook from its
sibling even though the new test uses Finite 100 (= timeout itself),
relying on the exclusive flag to drop the effective bound to 99. The
new name states that explicitly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #170. A Haiku mutation-testing pass (16 mutations across
validateClaim/validateRefund/upperBoundTime/lowerBoundTime/countScriptInputs/extractPubKeyHash) surfaced two survived mutants that weren't pinned by the existing suite:upperBoundTimemappingFinite t False → t - 1: dropping the-1kept the existing tests green because they only exercised the exactly-at-timeout case. Add a positive test where an exclusive upper bound one step below timeout (effectiveupperBound = 99) must succeed — asymmetric to the existing(Finite 101) False → effective 100 → failtest.countScriptInputsfallthrough_ -> acc: flipping to_ -> acc + 1would miscount pubkey inputs as our script input. Add a positive test where a pubkey input is co-spent alongside the script input and the claim must still succeed.Net: 27 → 29 HTLC tests. No validator changes.
Test plan
cabal test cape-tests --test-option='--match=HTLC'— 29/29 pass