cardano-ledger-binary-1.4.0.0: Binary serialization library used throughout ledger
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Cardano.Ledger.Binary.Vintage.Helpers.GoldenRoundTrip

Description

Golden and round-trip testing of DecCBOR and EncCBOR instances

Synopsis

Documentation

goldenTestCBOR ∷ ∀ a. (DecCBOR a, EncCBOR a, Eq a, Show a, HasCallStack) ⇒ a → FilePathProperty Source #

Check that the encode and decode function of the Bi instances work as expected w.r.t. the give reference data, this is, given a value x::a, and a file path fp:

  • The encoded data should coincide with the contents of the fp.
  • Decoding fp should give as a result x

goldenTestCBORExplicit Source #

Arguments

∷ ∀ a. (Eq a, Show a, HasCallStack) 
Text

Label for error reporting when decoding.

→ (a → Encoding) 
→ (∀ s. Decoder s a) 
→ a 
FilePath 
Property 

Variant of goldenTestBi using custom encode and decode functions.

This is required for the encode/decode golden-tests for types that do no have a Bi instance.

goldenTestExplicit ∷ ∀ a. (Eq a, Show a, HasCallStack) ⇒ (a → ByteString) → (ByteStringEither DecoderError a) → a → FilePathProperty Source #

roundTripsCBORShow ∷ (DecCBOR a, EncCBOR a, Eq a, MonadTest m, Show a, HasCallStack) ⇒ a → m () Source #

Round trip test a value (any instance of DecCBOR, EncCBOR, and Show classes) by serializing it to a ByteString and back again and that also has a Show instance. If the a type has both Show and Buildable instances, it's best to use this version.

roundTripsCBORBuildable ∷ (DecCBOR a, EncCBOR a, Eq a, MonadTest m, Buildable a, HasCallStack) ⇒ a → m () Source #

Round trip (via ByteString) any instance of the DecCBOR and EncCBOR class that also has a Buildable instance.

compareHexDump ∷ (MonadTest m, HasCallStack) ⇒ HexDump → HexDump → m () Source #

A custom version of (===) for HexDumps to get prettier diffs