Skip to content

Commit

Permalink
Update libs/cardano-ledger-conformance/src/Test/Cardano/Ledger/Confor…
Browse files Browse the repository at this point in the history
…mance/ExecSpecRule/Core.hs

Co-authored-by: Alexey Kuleshevich <alexey.kuleshevich@iohk.io>
  • Loading branch information
Soupstraw and lehins committed May 3, 2024
1 parent 51acd44 commit 7b01f99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
34 changes: 17 additions & 17 deletions eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ instance
Testable (ImpTestM era a)
where
property m = property . fmap ioProperty . runGenT $ do
res <- liftGen $ runImpTestGenM mkImpState m
res <- liftGen $ runImpTestGenM def m
liftIO $ fst <$> res

instance MonadWriter [SomeSTSEvent era] (ImpTestM era) where
Expand Down Expand Up @@ -1117,20 +1117,20 @@ logEntry e = impLogL %= (<> pretty loc <> "\t" <> pretty e <> line)
logToExpr :: (HasCallStack, ToExpr a) => a -> ImpTestM era ()
logToExpr e = logEntry (showExpr e)

mkImpState :: ShelleyEraImp era => ImpTestState era
mkImpState =
ImpTestState
{ impNES = initShelleyImpNES
, impRootTxIn = TxIn (mkTxId 0) minBound
, impKeyPairs = mempty
, impByronKeyPairs = mempty
, impNativeScripts = mempty
, impLastTick = 0
, impGlobals = testGlobals
, impLog = mempty
, impGen = mkQCGen 2024
, impEvents = mempty
}
instance ShelleyEraImp era => Default (ImpTestState era) where
def =
ImpTestState
{ impNES = initShelleyImpNES
, impRootTxIn = TxIn (mkTxId 0) minBound
, impKeyPairs = mempty
, impByronKeyPairs = mempty
, impNativeScripts = mempty
, impLastTick = 0
, impGlobals = testGlobals
, impLog = mempty
, impGen = mkQCGen 2024
, impEvents = mempty
}

withImpState ::
ShelleyEraImp era =>
Expand All @@ -1146,7 +1146,7 @@ withImpStateModified ::
Spec
withImpStateModified f =
beforeAll $
execImpTestM Nothing (f mkImpState) $
execImpTestM Nothing (f def) $
addRootTxOut >> initImpTestState
where
rootCoin = Coin 1_000_000_000
Expand All @@ -1155,7 +1155,7 @@ withImpStateModified f =
let rootAddr = Addr Testnet (KeyHashObj rootKeyHash) StakeRefNull
rootTxOut = mkBasicTxOut rootAddr $ inject rootCoin
impNESL . nesEsL . esLStateL . lsUTxOStateL . utxosUtxoL
%= (<> UTxO (Map.singleton (impRootTxIn @era mkImpState) rootTxOut))
%= (<> UTxO (Map.singleton (impRootTxIn @era def) rootTxOut))

-- | Creates a fresh @SafeHash@
freshSafeHash :: Era era => ImpTestM era (SafeHash (EraCrypto era) a)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,12 @@ import Control.State.Transition.Extended (STS (..))
import Data.Bifunctor (Bifunctor (..))
import Data.Bitraversable (bimapM)
import Data.Functor (($>))
import Data.Typeable (Proxy (..), Typeable, showsTypeRep, typeRep)
import Data.Typeable (Proxy (..), Typeable, typeRep)
import GHC.Base (Constraint, NonEmpty, Symbol, Type)
import GHC.TypeLits (KnownSymbol)
import qualified Lib as Agda
import Test.Cardano.Ledger.Common (Arbitrary (..), Gen, Testable (..), forAllShow)
import Test.Cardano.Ledger.Conformance.SpecTranslate.Core (SpecTranslate (..), runSpecTransM)
import Test.Cardano.Ledger.Imp.Common (
MonadGen (..),
NFData,
Property,
Spec,
ToExpr,
diffExpr,
expectRight,
expectRightExpr,
expectationFailure,
forAllShrinkShow,
ioProperty,
prop,
showExpr,
unless,
within,
)
import Test.Cardano.Ledger.Imp.Common
import Test.Cardano.Ledger.Shelley.ImpTest (
ImpTestM,
ShelleyEraImp,
Expand Down Expand Up @@ -276,7 +259,7 @@ generatesWithin gen timeout =
. forAllShow gen showExpr
$ \x -> within timeout $ ioProperty (evaluateDeep x $> ())
where
aName = showsTypeRep (typeRep $ Proxy @a) ""
aName = show (typeRep $ Proxy @a)

computationResultToEither :: Agda.ComputationResult e a -> Either e a
computationResultToEither (Agda.Success x) = Right x
Expand Down

0 comments on commit 7b01f99

Please sign in to comment.