Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve roundtrip functions to report annotations on callsite #5063

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Apr 6, 2023

Before this fix, hedgehog reports look like this:

    roundtrip tx CBOR
      BabbageEra: FAIL (9.47s)
          ✗ BabbageEra failed at gen/Test/Hedgehog/Roundtrip/CBOR.hs:21:5
            after 36 tests and 388 shrinks.
            shrink path: 36:a2B3aB5cm34EX32aCL36ew32A6cCL49cmCL185

               ┏━━ gen/Test/Hedgehog/Roundtrip/CBOR.hs ━━━
            15 ┃ roundtrip_CBOR
            16 ┃   :: (SerialiseAsCBOR a, Eq a, Show a)
            17 ┃   => AsType a -> Gen a -> Property
            18 ┃ roundtrip_CBOR typeProxy gen =
            19 ┃   H.property $ do
            20 ┃     val <- H.forAll gen
               ┃     │ ShelleyTx
               ┃     │   ShelleyBasedEraBabbage
               ┃     │   AlonzoTx
               ┃     │     { body =
...
               ┃     │           , _txscripts = fromList []
               ┃     │           , _txdats = TxDatsRaw (fromList [])
               ┃     │           , _txrdmrs = RedeemersRaw (fromList [])
               ┃     │           }
               ┃     │     , isValid = IsValid False
               ┃     │     , auxiliaryData = SNothing
               ┃     │     }
            21 ┃     H.tripping val serialiseToCBOR (deserialiseFromCBOR typeProxy)
               ┃     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
               ┃     │ ━━━ Intermediate ━━━
...
               ┃     │ ━━━ - Original) (+ Roundtrip ━━━
               ┃     │ - Right
               ┃     │ -   (ShelleyTx
               ┃     │ -      ShelleyBasedEraBabbage
               ┃     │ -      AlonzoTx
               ┃     │ -        { body =
...
               ┃     │ -        })
               ┃     │ + Left
               ┃     │ +   (DecoderErrorDeserialiseFailure
               ┃     │ +      "Shelley Tx"
               ┃     │ +      (DeserialiseFailure
               ┃     │ +         439
               ┃     │ +         "Expected array with 166 entries, but encoded array has 175 entries."))

            This failure can be reproduced by running:
            > recheckAt (Seed 12871014892817788416 11819258044470470495) "36:a2B3aB5cm34EX32aCL36ew32A6cCL49cmCL185" BabbageEra

        Use "--pattern '$NF ~ /BabbageEra/' --hedgehog-replay '36:a2B3aB5cm34EX32aCL36ew32A6cCL49cmCL185 Seed 12871014892817788416 11819258044470470495'" to reproduce from the command-line.

        Use -p '/BabbageEra/&&$0=="Cardano.Api.Test.Cardano.Api.Typed.CBOR.roundtrip tx CBOR.BabbageEra"' to rerun this test only.

There is not information to allow jumping directly the the failing test.

After the change the report additionally includes this:

               ┏━━ test/Test/Cardano/Api/Typed/CBOR.hs ━━━
            32 ┃ test_roundtrip_tx_CBOR :: [TestTree]
            33 ┃ test_roundtrip_tx_CBOR =
            34 ┃   [ testPropertyNamed (show era) (fromString (show era)) $ roundtrip_CBOR (proxyToAsType Proxy) (genTx era)
               ┃   │ Tx BabbageEra
            35 ┃   | AnyCardanoEra era <- [minBound..(AnyCardanoEra BabbageEra)]
            36 ┃   ]

The additional information locates the failing test down to the line number where the failure happened.

@newhoggy newhoggy marked this pull request as ready for review April 6, 2023 08:19
@newhoggy newhoggy force-pushed the newhoggy/improve-roundtrip-functions-to-report-annotations-on-callsite branch from 2b1f6a4 to 21d1d5c Compare April 6, 2023 08:28
@newhoggy newhoggy force-pushed the newhoggy/improve-roundtrip-functions-to-report-annotations-on-callsite branch from 21d1d5c to 439d912 Compare April 6, 2023 10:02
@newhoggy newhoggy force-pushed the newhoggy/improve-roundtrip-functions-to-report-annotations-on-callsite branch from 439d912 to b634708 Compare April 6, 2023 10:05
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👌

@newhoggy newhoggy added this pull request to the merge queue Apr 6, 2023
Merged via the queue into master with commit 6434712 Apr 6, 2023
@iohk-bors iohk-bors bot deleted the newhoggy/improve-roundtrip-functions-to-report-annotations-on-callsite branch April 6, 2023 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants