keiro-dsl-0.15.0.0: test/conformance-service-package/runtime/src/Proof/WorkspaceProof/Beta/Generated/Harness.hs
-- @generated by keiro-dsl 0.15.0.0 (language keiro-dsl 4) from aggregate Beta; do not edit.
module Proof.WorkspaceProof.Beta.Generated.Harness (harnessAssertions) where
import Proof.WorkspaceProof.Beta.Generated.Domain
import Proof.WorkspaceProof.Beta.Generated.Codec (encodeBetaEvent, parseBetaEvent, betaCodec)
import Proof.WorkspaceProof.Beta.Generated.Transducer (betaTransducer)
import Keiki.Core (applyEventsEither, defaultValidationOptions, step, validateTransducer)
import Keiro.Codec (eventType)
import Proof.WorkspaceProof.Generated.Nominals (ProofId, parseProofId)
-- | (label, passed). A driver runs these and exits non-zero on any False,
-- naming the failing assertion. Filling a hole wrongly turns a specific
-- entry False; the scaffold cannot.
harnessAssertions :: [(String, Bool)]
harnessAssertions =
[ ("validateTransducer is empty", null (validateTransducer defaultValidationOptions betaTransducer))
-- clock-free: spec samples no wall clock (verified at scaffold time)
, ("golden round-trip: BetaPinged", roundTrips sampleEventBetaPinged)
, ("accepts PingBeta from BetaActive", acceptPingBeta)
]
++ forwardReplayPingBeta
roundTrips :: BetaEvent -> Bool
roundTrips e = parseBetaEvent (eventType betaCodec e) (encodeBetaEvent e) == Right e
sampleProofId :: ProofId
sampleProofId =
case parseProofId "proof_01h455vb4pex5vsknk084sn02q" of
Right parsed -> parsed
Left problem -> error (show problem)
sampleEventBetaPinged :: BetaEvent
sampleEventBetaPinged = BetaPinged (BetaPingedData sampleProofId)
acceptPingBeta :: Bool
acceptPingBeta =
case step betaTransducer (BetaActive, initialBetaRegs) (PingBeta (PingBetaData sampleProofId)) of
Just (v, _, _) -> v == BetaActive
Nothing -> False
-- forward/replay equality (plan 147): cross the persisted codec boundary,
-- replay the emitted chain, and compare the final vertex and every register.
forwardReplayPingBeta :: [(String, Bool)]
forwardReplayPingBeta =
case step betaTransducer (BetaActive, initialBetaRegs) (PingBeta (PingBetaData sampleProofId)) of
Nothing -> [(prefix <> "forward step accepted", False)]
Just (forwardVertex, _forwardRegs, emitted) ->
case mapM (\event -> parseBetaEvent (eventType betaCodec event) (encodeBetaEvent event)) emitted of
Left _ -> [(prefix <> "emitted chain decodes", False)]
Right decodedEvents ->
case applyEventsEither betaTransducer (BetaActive, initialBetaRegs) decodedEvents of
Left _ -> [(prefix <> "replay succeeds", False)]
Right (replayVertex, _replayRegs) ->
[ (prefix <> "final vertex", replayVertex == forwardVertex)
]
where
prefix = "forward/replay equality: PingBeta from BetaActive -- "