Skip to content

Commit

Permalink
Round trip CBOR test on PraosNonce
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jun 8, 2021
1 parent bf43ee5 commit 901bf72
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .hlint.yaml
Expand Up @@ -65,3 +65,7 @@
- ignore:
name: Use camelCase
within: Test.Cardano.Api.KeysByron
- ignore:
name: Use camelCase
within: Test.Cardano.Api.Typed.JSON

7 changes: 5 additions & 2 deletions cardano-api/test/Test/Cardano/Api/Typed/Gen.hs
Expand Up @@ -7,6 +7,7 @@ module Test.Cardano.Api.Typed.Gen
( genAddressByron
, genAddressShelley
, genMaybePraosNonce
, genPraosNonce
, genProtocolParameters
, genValueNestedRep
, genValueNestedBundle
Expand Down Expand Up @@ -693,9 +694,11 @@ genRational = Gen.realFrac_ (Range.linearFrac 0 1)
genEpochNo :: Gen EpochNo
genEpochNo = EpochNo <$> Gen.word64 (Range.linear 0 10)

genPraosNonce :: Gen PraosNonce
genPraosNonce = makePraosNonce <$> Gen.bytes (Range.linear 0 32)

genMaybePraosNonce :: Gen (Maybe PraosNonce)
genMaybePraosNonce =
Gen.maybe (makePraosNonce <$> Gen.bytes (Range.linear 0 32))
genMaybePraosNonce = Gen.maybe genPraosNonce

genProtocolParameters :: Gen ProtocolParameters
genProtocolParameters =
Expand Down
17 changes: 11 additions & 6 deletions cardano-api/test/Test/Cardano/Api/Typed/JSON.hs
@@ -1,22 +1,27 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

{-# OPTIONS_GHC -Wno-orphans #-}

module Test.Cardano.Api.Typed.JSON
( tests
) where

import Cardano.Prelude

import Data.Aeson

import Hedgehog (Property, discover, forAll, tripping)
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import Test.Cardano.Api.Typed.Gen
import Test.Cardano.Api.Typed.Orphans ()
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog.Group (fromGroup)

import Test.Cardano.Api.Typed.Gen

import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen

{- HLINT ignore "Use camelCase" -}

Expand Down

0 comments on commit 901bf72

Please sign in to comment.