Skip to content

Add mutant catch for incompatible mixed fragment#871

Merged
nothingmuch merged 1 commit intopayjoin:masterfrom
benalleng:deprecated-fragment-mutant
Jul 11, 2025
Merged

Add mutant catch for incompatible mixed fragment#871
nothingmuch merged 1 commit intopayjoin:masterfrom
benalleng:deprecated-fragment-mutant

Conversation

@benalleng
Copy link
Collaborator

We did not have a test demonstrating that fragment delimiters could not be mixed.

Plus a test name typo

@coveralls
Copy link
Collaborator

coveralls commented Jul 11, 2025

Pull Request Test Coverage Report for Build 16227902588

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 85.566%

Totals Coverage Status
Change from base Build 16225386088: 0.02%
Covered Lines: 7570
Relevant Lines: 8847

💛 - Coveralls

@benalleng benalleng force-pushed the deprecated-fragment-mutant branch from 320119f to 130685b Compare July 11, 2025 18:52
Copy link
Collaborator

@nothingmuch nothingmuch left a comment

Choose a reason for hiding this comment

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

Derp, i forgot to check coverage on the PR that introduced that, pretty embarassing.

The test assertion seems correct but is kind of confusing, so either it needs to be simplified or I missed something and a comment is needed

Comment on lines 522 to 526
let delimiter_check = check_fragment_delimiter(fragment);

match delimiter_check {
Err(ParseFragmentError::AmbiguousDelimiter) => {
assert!(matches!(
delimiter_check.err(),
Some(ParseFragmentError::AmbiguousDelimiter)
));
}
_ => panic!("Expected AmbitiousDelimiter error, got Ok or unexpected error"),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this sufficient? seems like the inner match on .err() just re-asserts the same thing after convering the outer Err to a Some?

Suggested change
let delimiter_check = check_fragment_delimiter(fragment);
match delimiter_check {
Err(ParseFragmentError::AmbiguousDelimiter) => {
assert!(matches!(
delimiter_check.err(),
Some(ParseFragmentError::AmbiguousDelimiter)
));
}
_ => panic!("Expected AmbitiousDelimiter error, got Ok or unexpected error"),
}
}
assert!(matches!(
check_fragment_delimiter(fragment),
Err(ParseFragmentError::AmbiguousDelimiter),
));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it defintely can be the more simplified approach, good call

@benalleng benalleng force-pushed the deprecated-fragment-mutant branch from 130685b to 4ca35a5 Compare July 11, 2025 19:11
We did not have a test demonstrating that fragement delimiters could not
be mixed.
@benalleng benalleng force-pushed the deprecated-fragment-mutant branch from 4ca35a5 to 7635056 Compare July 11, 2025 19:13
@nothingmuch nothingmuch merged commit c8b4f36 into payjoin:master Jul 11, 2025
9 checks passed
@benalleng benalleng deleted the deprecated-fragment-mutant branch October 6, 2025 18:40
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.

3 participants