@@ -35,7 +35,7 @@ import qualified Data.Set as Set
3535import Lens.Micro
3636import Test.Cardano.Ledger.Alonzo.Arbitrary (alwaysSucceedsLang )
3737import Test.Cardano.Ledger.Binary.Plain.Golden (Enc (.. ))
38- import Test.Cardano.Ledger.Common (Small ( .. ), Spec , describe , it , prop , (==>) )
38+ import Test.Cardano.Ledger.Common (Spec , describe , it )
3939import Test.Cardano.Ledger.Conway.Binary.Golden hiding (spec )
4040import Test.Cardano.Ledger.Core.KeyPair (mkKeyPair , mkWitnessVKey )
4141import Test.Cardano.Ledger.Core.Utils (mkDummySafeHash )
@@ -61,71 +61,44 @@ spec = describe "Golden" . forEachEraVersion @era $ \version -> do
6161goldenEmptyFields :: forall era . DijkstraEraTest era => Version -> Spec
6262goldenEmptyFields version =
6363 describe " Empty fields not allowed" $ do
64- describe " Untagged" $ do
65- let
66- it " addrTxWits" . expectFailureOnTxWitsEmptyField @ era version 0 $
64+ let
65+ decoderFailure n msg =
6766 DecoderErrorDeserialiseFailure
6867 (Binary. label $ Proxy @ (Annotator (TxWits era )))
69- (DeserialiseFailure 4 " Set cannot be empty" )
68+ (DeserialiseFailure n msg)
69+ describe " Untagged" $ do
70+ it " addrTxWits" . expectFailureOnTxWitsEmptyField @ era version 0 $
71+ decoderFailure 4 " Empty list found, expected non-empty"
7072 it " nativeScripts" . expectFailureOnTxWitsEmptyField @ era version 1 $
71- DecoderErrorCustom " Annotator " " Empty script Set is not allowed "
73+ decoderFailure 4 " Empty list found, expected non-empty "
7274 it " bootstrapWitness" . expectFailureOnTxWitsEmptyField @ era version 2 $
73- DecoderErrorDeserialiseFailure
74- (Binary. label $ Proxy @ (Annotator (TxWits era )))
75- (DeserialiseFailure 4 " Set cannot be empty" )
75+ decoderFailure 4 " Empty list found, expected non-empty"
7676 it " plutusV1Script" . expectFailureOnTxWitsEmptyField @ era version 3 $
77- DecoderErrorDeserialiseFailure
78- " Annotator (MemoBytes (AlonzoTxWitsRaw DijkstraEra))"
79- (DeserialiseFailure 4 " Empty list of scripts is not allowed" )
77+ decoderFailure 4 " Empty list of scripts is not allowed"
8078 it " plutusData" . expectFailureOnTxWitsEmptyField @ era version 4 $
81- DecoderErrorCustom " Annotator " " Empty script Set is not allowed "
79+ decoderFailure 4 " Empty list found, expected non-empty "
8280 it " redeemers" . expectFailureOnTxWitsEmptyField @ era version 5 $
83- DecoderErrorDeserialiseFailure
84- " Annotator (MemoBytes (AlonzoTxWitsRaw DijkstraEra))"
85- (DeserialiseFailure 2 " List encoding of redeemers not supported starting with PV 12" )
81+ decoderFailure 2 " List encoding of redeemers not supported starting with PV 12"
8682 it " plutusV2Script" . expectFailureOnTxWitsEmptyField @ era version 6 $
87- DecoderErrorDeserialiseFailure
88- " Annotator (MemoBytes (AlonzoTxWitsRaw DijkstraEra))"
89- (DeserialiseFailure 4 " Empty list of scripts is not allowed" )
83+ decoderFailure 4 " Empty list of scripts is not allowed"
9084 it " plutusV3Script" . expectFailureOnTxWitsEmptyField @ era version 7 $
91- DecoderErrorDeserialiseFailure
92- " Annotator (MemoBytes (AlonzoTxWitsRaw DijkstraEra))"
93- (DeserialiseFailure 4 " Empty list of scripts is not allowed" )
94- -- TODO replace this with `plutusV4Script` once that is added
95- txWitsDecodingFailsOnInvalidField @ era version [0 .. 7 ]
85+ decoderFailure 4 " Empty list of scripts is not allowed"
9686 describe " Tagged" $ do
97- let
98- it " addrTxWits" . expectFailureOnTxWitsEmptyField @ era version 0 $
99- DecoderErrorDeserialiseFailure
100- (Binary. label $ Proxy @ (Annotator (TxWits era )))
101- (DeserialiseFailure 7 " Set cannot be empty" )
102- it " nativeScripts" . expectFailureOnTxWitsEmptyField @ era version 1 $
103- DecoderErrorCustom " Annotator" " Empty script Set is not allowed"
104- it " bootstrapWitness" . expectFailureOnTxWitsEmptyField @ era version 2 $
105- DecoderErrorDeserialiseFailure
106- (Binary. label $ Proxy @ (Annotator (TxWits era )))
107- (DeserialiseFailure 7 " Set cannot be empty" )
108- it " plutusV1Script" . expectFailureOnTxWitsEmptyField @ era version 3 $
109- DecoderErrorDeserialiseFailure
110- (Binary. label $ Proxy @ (Annotator (TxWits era )))
111- (DeserialiseFailure 7 " Empty list of scripts is not allowed" )
112- it " plutusData" . expectFailureOnTxWitsEmptyField @ era version 4 $
113- DecoderErrorCustom " Annotator" " Empty script Set is not allowed"
114- it " plutusV2Script" . expectFailureOnTxWitsEmptyField @ era version 6 $
115- DecoderErrorDeserialiseFailure
116- (Binary. label $ Proxy @ (Annotator (TxWits era )))
117- (DeserialiseFailure 7 " Empty list of scripts is not allowed" )
118- it " plutusV3Script" . expectFailureOnTxWitsEmptyField @ era version 7 $
119- DecoderErrorDeserialiseFailure
120- (Binary. label $ Proxy @ (Annotator (TxWits era )))
121- (DeserialiseFailure 7 " Empty list of scripts is not allowed" )
122- prop " other fields" $ \ (Small idx) ->
123- idx `notElem` [0 .. 7 ] ==> expectFailureOnTxWitsEmptyField @ era version idx $
124- DecoderErrorDeserialiseFailure
125- (Binary. label $ Proxy @ (Annotator (TxWits era )))
126- ( DeserialiseFailure 2 $
127- " An error occurred while decoding (Int,Void) not a valid key:.\n Error: " <> show idx
128- )
87+ it " addrTxWits" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 0 $
88+ decoderFailure 7 " Empty list found, expected non-empty"
89+ it " nativeScripts" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 1 $
90+ decoderFailure 7 " Empty list found, expected non-empty"
91+ it " bootstrapWitness" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 2 $
92+ decoderFailure 7 " Empty list found, expected non-empty"
93+ it " plutusV1Script" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 3 $
94+ decoderFailure 7 " Empty list of scripts is not allowed"
95+ it " plutusData" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 4 $
96+ decoderFailure 7 " Empty list found, expected non-empty"
97+ it " plutusV2Script" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 6 $
98+ decoderFailure 7 " Empty list of scripts is not allowed"
99+ it " plutusV3Script" . expectFailureOnTxWitsEmptyFieldWithTag @ era version 7 $
100+ decoderFailure 7 " Empty list of scripts is not allowed"
101+ txWitsDecodingFailsOnInvalidField @ era version [0 .. 7 ]
129102
130103witsDuplicateVKeyWits :: Enc
131104witsDuplicateVKeyWits =
0 commit comments