Skip to content

HTLC: add two coverage tests found by mutation sweep#172

Merged
Unisay merged 2 commits intomainfrom
yura/htlc-mutation-coverage
Apr 24, 2026
Merged

HTLC: add two coverage tests found by mutation sweep#172
Unisay merged 2 commits intomainfrom
yura/htlc-mutation-coverage

Conversation

@Unisay
Copy link
Copy Markdown
Collaborator

@Unisay Unisay commented Apr 24, 2026

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:

  • upperBoundTime mapping Finite t False → t - 1: dropping the -1 kept 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 (effective upperBound = 99) must succeed — asymmetric to the existing (Finite 101) False → effective 100 → fail test.
  • countScriptInputs fallthrough _ -> acc: flipping to _ -> acc + 1 would 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
  • CI green on this PR

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.
@Unisay Unisay self-assigned this Apr 24, 2026
@Unisay Unisay requested a review from Copilot April 24, 2026 12:48
@Unisay Unisay added the UPLC-CAPE Tracks UPLC-CAPE scope label Apr 24, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ScriptCredential inputs).

Comment thread test/HTLCSpec.hs Outdated
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.
@Unisay Unisay merged commit b00b300 into main Apr 24, 2026
5 checks passed
@Unisay Unisay deleted the yura/htlc-mutation-coverage branch April 24, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UPLC-CAPE Tracks UPLC-CAPE scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants