cardano-api:gen
Safe HaskellNone
LanguageHaskell2010

Test.Hedgehog.Roundtrip.CBOR

Synopsis

Documentation

decodeOnlyPlutusScriptBytes Source #

Arguments

:: forall era lang m. (HasCallStack, Era (ShelleyLedgerEra era), MonadTest m, PlutusLanguage (ToLedgerPlutusLanguage lang), IsPlutusScriptLanguage lang, HasTypeProxy era) 
=> ShelleyBasedEra era 
-> PlutusScriptVersion lang 
-> ByteString

This can be a double encoded or "normal" plutus script

-> AsType (Script lang) 
-> m () 

We need to confirm the existing SerialiseAsCBOR instance for 'Script lang' no longer double serializes scripts but is backwards compatible with doubly serialized scripts.

We would also like to check that the deserialized bytes is a valid plutus script. We can do this by using the SerialiseAsCBOR instance for PlutusScriptInEra.

We will check the following: 1. Deserializing double encoded script bytes and "normal" script bytes decode to the same byte sequence. 2. The resulting bytes are both valid plutus scripts (via PlutusScriptInEra)

If these two properties hold we can be sure that existing double encoded scripts will deserialize correctly and newly created scripts will also deserialize correctly.

trippingCbor :: (HasCallStack, MonadTest m, Show a, Eq a, SerialiseAsCBOR a) => AsType a -> a -> m () Source #

Assert that CBOR serialisation and deserialisation roundtrips.