Skip to content

Update tests to match on invariant rather than display #707

Closed

Description

@shinghim
          I discovered even more appropriate syntax
            assert!(matches!(
                ctx.process_proposal(proposal),
                Err(InternalProposalError::LockTimesDontMatch {
                    proposed,
                    original
                }) if proposed == proposed_locktime && original == original_locktime
            ));

which does not match on the display impl but on the variant itself, and avoids the unwrap, but I suppose that can be saved for a follow up. An LLM should be able to do this conversion and then you can self review before asking for one here, but it should be one-shot.

Originally posted by @DanGould in #663 (comment)

I believe this applies to the tests that check for:

  • SenderTxinSequenceChanged
  • LockTimesDontMatch
  • VersionsDontMatch

Activity

  1. changed the title [-]Update tests to match on invariant rather than string[/-] [+]Update tests to match on invariant rather than display[/+] on May 21, 2025
  2. nothingmuch commented on May 22, 2025

    @nothingmuch
    Contributor

    nightly std::assert has assert_matches which improves the output, so perhaps we should define a #[cfg(not(version(???))] that is just assert!(matches!(...)) so that we can use the same syntax in older versions too?

  3. added a commit that references this issue on May 22, 2025
    2d69868
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions