This repository was archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
[CDEC-403] Remove partial field accessors from HandlerSpec
, InductiveValidationError
, InvariantViolation
and ValidationResult
data types.
#3263
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bc74648
[CDEC-403] Remove partial record accessors from `HandlerSpec`
Jimbo4350 7365eb2
[CDEC-403] Remove partial field accessors from `InductiveValidationEr…
Jimbo4350 9fa122b
[CDEC-403] Remove partial field accessors from `InvariantViolation`
Jimbo4350 0d5b014
[CDEC-403] Remove partial field accessors from `ValidationResult`
Jimbo4350 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,55 +45,46 @@ data ValidatedInductive h a = ValidatedInductive { | |
|
||
data InductiveValidationError h a = | ||
-- | Bootstrap transaction is invalid | ||
InductiveInvalidBoot { | ||
-- | The bootstrap transaction | ||
inductiveInvalidBoot :: Transaction h a | ||
|
||
-- | The error message | ||
, inductiveInvalidError :: Text | ||
} | ||
-- InductiveInvalidBoot | ||
-- inductiveInvalidBoot = The bootstrap transaction | ||
-- inductiveInvalidError = The error message | ||
InductiveInvalidBoot !(Transaction h a) !Text | ||
|
||
-- | Invalid transaction in the given block | ||
| InductiveInvalidApplyBlock { | ||
-- | The events leading up to the error | ||
inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a) | ||
|
||
-- | The transactions in the block we successfully validated | ||
, inductiveInvalidBlockPrefix :: OldestFirst [] (Transaction h a) | ||
|
||
-- | The transaction that was invalid | ||
, inductiveInvalidTransaction :: Transaction h a | ||
|
||
-- | The error message | ||
, inductiveInvalidError :: Text | ||
} | ||
-- InductiveInvalidApplyBlock | ||
-- inductiveInvalidEvents = The events leading up to the error | ||
-- inductiveInvalidBlockPrefix = The transactions in the block we | ||
-- successfully validated | ||
-- inductiveInvalidTransaction = The transaction that was invalid | ||
-- inductiveInvalidError = The error message | ||
| InductiveInvalidApplyBlock | ||
!(OldestFirst [] (WalletEvent h a)) | ||
!(OldestFirst [] (Transaction h a)) | ||
!(Transaction h a) | ||
!Text | ||
|
||
-- | A 'NewPending' call was invalid because the input was already spent | ||
| InductiveInvalidNewPendingAlreadySpent { | ||
-- | The events leading up to the error | ||
inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a) | ||
|
||
-- | The transaction that was invalid | ||
, inductiveInvalidTransaction :: Transaction h a | ||
|
||
-- | The specific input that was not valid | ||
, inductiveInvalidInput :: Input h a | ||
} | ||
-- InductiveInvalidNewPendingAlreadySpent | ||
-- inductiveInvalidEvents = The events leading up to the error | ||
-- inductiveInvalidTransaction = The transaction that was invalid | ||
-- inductiveInvalidInput = The specific input that was not valid | ||
| InductiveInvalidNewPendingAlreadySpent | ||
!(OldestFirst [] (WalletEvent h a)) | ||
!(Transaction h a) | ||
!(Input h a) | ||
|
||
-- | A 'NewPending' call was invalid because the input was not @ours@ | ||
| InductiveInvalidNewPendingNotOurs { | ||
-- | The events leading up to the error | ||
inductiveInvalidEvents :: OldestFirst [] (WalletEvent h a) | ||
|
||
-- | The transaction that was invalid | ||
, inductiveInvalidTransaction :: Transaction h a | ||
-- InductiveInvalidNewPendingNotOurs | ||
-- inductiveInvalidEvents = The events leading up to the error | ||
-- inductiveInvalidTransaction = The transaction that was invalid | ||
-- inductiveInvalidInput = The specific input that was not valid | ||
-- inductiveInvalidAddress = The address this input belonged to | ||
| InductiveInvalidNewPendingNotOurs | ||
!(OldestFirst [] (WalletEvent h a)) | ||
!(Transaction h a) | ||
!(Input h a) | ||
!a | ||
|
||
-- | The specific input that was not valid | ||
, inductiveInvalidInput :: Input h a | ||
|
||
-- | The address this input belonged to | ||
, inductiveInvalidAddress :: a | ||
} | ||
|
||
{------------------------------------------------------------------------------- | ||
Validation proper | ||
|
@@ -150,19 +141,20 @@ inductiveIsValid Inductive{..} = do | |
forM_ (zip inputs resolved) $ \(input, mAddr) -> | ||
case mAddr of | ||
Nothing -> | ||
throwError InductiveInvalidNewPendingAlreadySpent { | ||
inductiveInvalidEvents = toOldestFirst viEvents | ||
, inductiveInvalidTransaction = t | ||
, inductiveInvalidInput = input | ||
} | ||
throwError | ||
$ InductiveInvalidNewPendingAlreadySpent | ||
(toOldestFirst viEvents) | ||
t | ||
input | ||
Just addr -> | ||
unless (addr `Set.member` inductiveOurs) $ | ||
throwError InductiveInvalidNewPendingNotOurs { | ||
inductiveInvalidEvents = toOldestFirst viEvents | ||
, inductiveInvalidTransaction = t | ||
, inductiveInvalidInput = input | ||
, inductiveInvalidAddress = addr | ||
} | ||
throwError | ||
$ InductiveInvalidNewPendingNotOurs | ||
(toOldestFirst viEvents) | ||
t | ||
input | ||
addr | ||
|
||
goEvents es vi | ||
|
||
goBlock :: OldestFirst [] (WalletEvent h a) -- Events leading to this point (for err msgs) | ||
|
@@ -201,15 +193,21 @@ inductiveIsValid Inductive{..} = do | |
-------------------------------------------------------------------------------} | ||
|
||
instance (Hash h a, Buildable a) => Buildable (InductiveValidationError h a) where | ||
build InductiveInvalidBoot{..} = bprint | ||
build (InductiveInvalidBoot | ||
inductiveInvalidBoot | ||
inductiveInvalidError) = bprint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 for removing uses of RecordWildcards. Maybe at some point we can go through and drop it from |
||
( "InductiveInvalidBoot" | ||
% "{ boot: " % build | ||
% ", error: " % build | ||
% "}" | ||
) | ||
inductiveInvalidBoot | ||
inductiveInvalidError | ||
build InductiveInvalidApplyBlock{..} = bprint | ||
build (InductiveInvalidApplyBlock | ||
inductiveInvalidEvents | ||
inductiveInvalidBlockPrefix | ||
inductiveInvalidTransaction | ||
inductiveInvalidError) = bprint | ||
( "InductiveInvalidApplyBlock" | ||
% "{ events: " % build | ||
% ", blockPrefix: " % build | ||
|
@@ -220,7 +218,10 @@ instance (Hash h a, Buildable a) => Buildable (InductiveValidationError h a) whe | |
inductiveInvalidBlockPrefix | ||
inductiveInvalidTransaction | ||
inductiveInvalidError | ||
build InductiveInvalidNewPendingAlreadySpent{..} = bprint | ||
build (InductiveInvalidNewPendingAlreadySpent | ||
inductiveInvalidEvents | ||
inductiveInvalidTransaction | ||
inductiveInvalidInput) = bprint | ||
( "InductiveInvalidNewPendingAlreadySpent" | ||
% "{ events: " % build | ||
% ", transaction: " % build | ||
|
@@ -230,7 +231,11 @@ instance (Hash h a, Buildable a) => Buildable (InductiveValidationError h a) whe | |
inductiveInvalidEvents | ||
inductiveInvalidTransaction | ||
inductiveInvalidInput | ||
build InductiveInvalidNewPendingNotOurs{..} = bprint | ||
build (InductiveInvalidNewPendingNotOurs | ||
inductiveInvalidEvents | ||
inductiveInvalidTransaction | ||
inductiveInvalidInput | ||
inductiveInvalidAddress) = bprint | ||
( "InductiveInvalidNewPendingNotOurs" | ||
% "{ events: " % build | ||
% ", transaction: " % build | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't seem to have golden/bitripping tests for
HandlerSpec
. At least not in theinfra
package.We need that before we go changing things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, I'll create a ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests created in #3268 and merged. Rebased [CDEC-403] onto develop with golden and bitripping tests still passing.