packages feed

cleveland-0.1.1: test/TestSuite/Cleveland/InitialState.hs

-- SPDX-FileCopyrightText: 2021 Oxhead Alpha
-- SPDX-License-Identifier: LicenseRef-MIT-OA

-- | Tests for the initial state configuration of emulated scenarios

module TestSuite.Cleveland.InitialState
  ( test_init
  ) where

import Hedgehog (property, withTests)
import Test.Tasty (TestTree)
import Test.Tasty.Hedgehog (testProperty)

import Morley.Tezos.Core (Timestamp(..))
import Test.Cleveland

test_init :: IO [TestTree]
test_init = do
  let expectedNow = Timestamp 1000_000
  let expectedLevel = 2255
  pure
    [ testProperty "Sets initial configuration and check it works as expected in emulator" $
        withTests 10 $ property $ testScenarioProps $
          withInitialLevel expectedLevel $
          withInitialNow expectedNow $ scenario $ do
            (getNow @@== expectedNow)
            (getLevel @@== expectedLevel)

    , testScenarioOnEmulator "Sets initial configuration and check the envirionment is as expected in emulated unit tests"
        $ withInitialNow expectedNow
        $ withInitialLevel expectedLevel
        $ scenario $ do
            getLevel @@== expectedLevel
            getNow @@== expectedNow

    , testScenarioOnEmulator "Sets initial configuration and check the envirionment is as expected in emulated unit tests"
        $ withInitialNow expectedNow
        $ withInitialLevel expectedLevel
        $ scenarioEmulated $ do
            getLevel @@== expectedLevel
            getNow @@== expectedNow
    ]