Skip to content

Commit

Permalink
Label Plutus Context errors exhaustively in balanceTx property (#4618)
Browse files Browse the repository at this point in the history
- [x] Exhaustively pattern match and label Plutus context errors such
that we don't fail if we hit the `_` "other error" case.

To fix balanceTx property
[flakiness](https://buildkite.com/cardano-foundation/cardano-wallet/builds/5219#018fe7ea-3ff1-4ad1-9a1a-cc8ca1e923cc/6-3590)
observed in #4617

### Issue Number

ADP-3368
  • Loading branch information
Anviking authored Jun 5, 2024
2 parents e568d96 + 0faa29a commit 13a7b3b
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions lib/balance-tx/test/spec/Internal/Cardano/Write/Tx/BalanceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,24 +1312,8 @@ prop_balanceTxValid
(ErrBalanceTxAssignRedeemers
(ErrAssignRedeemersTranslationError x)) ->
case recentEra @era of
RecentEraBabbage -> case x of
ByronTxOutInContext _ ->
label "failed with ByronTxOutInContext"
$ property True
ReferenceScriptsNotSupported _ ->
label "ReferenceScriptsNotSupported"
$ property True
_ -> property False
RecentEraConway -> case x of
BabbageContextError y -> case y of
ByronTxOutInContext _ ->
label "failed with ByronTxOutInContext"
$ property True
ReferenceScriptsNotSupported _ ->
label "ReferenceScriptsNotSupported"
$ property True
_ -> property False
_ -> property False
RecentEraBabbage -> prop_babbageContextError x
RecentEraConway -> prop_conwayContextError x
Left ErrBalanceTxUnableToCreateChange {} ->
label "unable to create change" $ property True
Left ErrBalanceTxInputResolutionConflicts{} ->
Expand All @@ -1341,6 +1325,42 @@ prop_balanceTxValid
balanceTxArgs
Wallet _ walletUTxO _ = wallet

prop_babbageContextError :: BabbageContextError era -> Property
prop_babbageContextError = \case
AlonzoContextError (TranslationLogicMissingInput _) ->
succeedWithLabel "TranslationLogicMissingInput"
AlonzoContextError (TimeTranslationPastHorizon _) ->
succeedWithLabel "TimeTranslationPastHorizon"
ByronTxOutInContext _ ->
succeedWithLabel "ByronTxOutInContext"
RedeemerPointerPointsToNothing _ ->
succeedWithLabel "RedeemerPointerPointsToNothing"
InlineDatumsNotSupported _ ->
succeedWithLabel "InlineDatumsNotSupported"
ReferenceScriptsNotSupported _ ->
succeedWithLabel "ReferenceScriptsNotSupported"
ReferenceInputsNotSupported _ ->
succeedWithLabel "ReferenceInputsNotSupported"

prop_conwayContextError :: ConwayContextError era -> Property
prop_conwayContextError = \case
BabbageContextError e -> prop_babbageContextError e
CertificateNotSupported _ ->
succeedWithLabel "CertificateNotSupported"
PlutusPurposeNotSupported _ ->
succeedWithLabel "PlutusPurposeNotSupported"
-- Will be needed in later ledger versions:
-- CurrentTreasuryFieldNotSupported _ ->
-- succeedWithLabel "CurrentTreasuryFieldNotSupported"
-- VotingProceduresFieldNotSupported _ ->
-- succeedWithLabel "VotingProceduresFieldNotSupported"
-- ProposalProceduresFieldNotSupported _ ->
-- succeedWithLabel "ProposalProceduresFieldNotSupported"
-- TreasuryDonationFieldNotSupported _ ->
-- succeedWithLabel "TreasuryDonationFieldNotSupported"

succeedWithLabel l = label l $ property True

prop_expectFeeExcessSmallerThan
:: Coin
-> Tx era
Expand Down

0 comments on commit 13a7b3b

Please sign in to comment.