Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Throw spv errors as pact errors with type ContinuationError#1220

Merged
edmundnoble merged 5 commits intomasterfrom
edmund/throw-spv-errors-as-PactErrors
May 9, 2023
Merged

Throw spv errors as pact errors with type ContinuationError#1220
edmundnoble merged 5 commits intomasterfrom
edmund/throw-spv-errors-as-PactErrors

Conversation

@edmundnoble
Copy link
Copy Markdown
Contributor

No description provided.

@edmundnoble edmundnoble requested review from emilypi and jmcardon May 5, 2023 17:20
@edmundnoble edmundnoble requested a review from sirlensalot as a code owner May 5, 2023 17:20
Copy link
Copy Markdown
Contributor

@emilypi emilypi left a comment

Choose a reason for hiding this comment

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

Fastest fork in the west

Copy link
Copy Markdown
Contributor

@sirlensalot sirlensalot left a comment

Choose a reason for hiding this comment

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

Need to document what code coverage options are available for this change and why or why not to require them. Also need to document impact on replay.

@edmundnoble
Copy link
Copy Markdown
Contributor Author

Replay passes with Pact 883ae58 and chainweb a988450. I will add a test or two though.

@edmundnoble edmundnoble requested a review from jwiegley as a code owner May 8, 2023 20:03
@edmundnoble edmundnoble requested review from emilypi and sirlensalot May 8, 2023 20:22
@edmundnoble
Copy link
Copy Markdown
Contributor Author

edmundnoble commented May 8, 2023

I've added a test of the error type, re-requesting review. I made some mechanical changes to these tests:

  • uses of failsWith Nothing and succeedsWith Nothing have become fails and succeeds
  • uses of failsWith (Just e) and succeedsWith (Just e) have become failsWith (``shouldBe`` e) and succeedsWith (``shouldBe`` e)
  • Just-wrapping utilities have been deleted
    Those changes make it possible to test the error type without adding endless ad-hoc utilities for asserting on particular members of PactError etc.

Copy link
Copy Markdown
Member

@jmcardon jmcardon left a comment

Choose a reason for hiding this comment

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

Approved pending ci

succeedsWith :: HasCallStack => Command Text -> (PactValue -> Expectation) ->
ReaderT (HM.HashMap RequestKey (CommandResult Hash)) IO ()
succeedsWith cmd r = succeedsWith' cmd ((,[]) <$> r)
succeedsWith cmd r = succeedsWith' cmd (\(pv,es) -> (es `shouldBe` []) *> r pv)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 I like these changes to the testing dsl

Copy link
Copy Markdown
Member

@jmcardon jmcardon left a comment

Choose a reason for hiding this comment

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

Approved pending ci

Copy link
Copy Markdown
Contributor

@jwiegley jwiegley left a comment

Choose a reason for hiding this comment

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

This PR makes such extensive changes to the testing API, that it's hard to see what the changes are relating only to ContinuationError.

@edmundnoble
Copy link
Copy Markdown
Contributor Author

The changes appear extensive in the diff, but they're explained above as mechanical changes that are easy to audit. As is, we have a few helpers for writing assertions about nested data, but composing them is difficult when the data becomes more deeply nested, and when we need to assert on multiple fields. All I did was make the language for assertions on PactResult slightly more composable. I don't think we have time for me to convince you of the benefits of this approach now if it's not obvious, so I'll revert the larger part of the changes. Maybe at a future Kadena tech talk?

@edmundnoble edmundnoble requested a review from jwiegley May 8, 2023 23:50
Copy link
Copy Markdown
Contributor

@sirlensalot sirlensalot left a comment

Choose a reason for hiding this comment

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

Tests look good, thanks for the cleanup in aisle crufty-seven

@sirlensalot
Copy link
Copy Markdown
Contributor

@jwiegley while the changes look like a lot, it was really a teetering tower of cruft that @edmundnoble has tamed, as the author of said cruft I can confirm it's better now. Finally it was probably the only way to get coverage for the error type without making things even more cruftastic.

@sirlensalot
Copy link
Copy Markdown
Contributor

Pre-fork test looks good, LGTM to merge on CI

@edmundnoble edmundnoble merged commit f49f8d9 into master May 9, 2023
@edmundnoble edmundnoble mentioned this pull request May 9, 2023
8 tasks
@jwiegley jwiegley deleted the edmund/throw-spv-errors-as-PactErrors branch May 9, 2023 03:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants