Skip to content

Commit

Permalink
Use genTxValidityUpperBound and genTxValidityLowerBound in Arbitrary …
Browse files Browse the repository at this point in the history
…instances
  • Loading branch information
locallycompact committed Jan 3, 2025
1 parent 186e95f commit e46535d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions hydra-cardano-api/src/Hydra/Cardano/Api/ValidityInterval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import Hydra.Cardano.Api.Prelude

import Cardano.Ledger.Allegra.Scripts qualified as Ledger
import Cardano.Ledger.BaseTypes (StrictMaybe (..), maybeToStrictMaybe)
import Test.QuickCheck (oneof)
import Test.Gen.Cardano.Api.Typed (genTxValidityLowerBound, genTxValidityUpperBound)
import Test.QuickCheck.Hedgehog (hedgehog)

toLedgerValidityInterval ::
(TxValidityLowerBound era, TxValidityUpperBound era) ->
Expand Down Expand Up @@ -35,11 +36,7 @@ fromLedgerValidityInterval validityInterval =
in (lowerBound, upperBound)

instance Arbitrary (TxValidityLowerBound Era) where
arbitrary =
oneof
[ pure TxValidityNoLowerBound
, TxValidityLowerBound allegraBasedEra . SlotNo <$> arbitrary
]
arbitrary = hedgehog $ genTxValidityLowerBound cardanoEra

instance Arbitrary (TxValidityUpperBound Era) where
arbitrary = TxValidityUpperBound (shelleyBasedEra @Era) . fmap SlotNo <$> arbitrary
arbitrary = hedgehog $ genTxValidityUpperBound shelleyBasedEra

0 comments on commit e46535d

Please sign in to comment.