packages feed

cleveland-0.1.0: test/TestSuite/Cleveland/UsedFramework.hs

-- SPDX-FileCopyrightText: 2021 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

module TestSuite.Cleveland.UsedFramework
  ( test_usedFramework
  , test_whenEmulation
  ) where

import Test.Tasty (TestTree, testGroup)

import Test.Cleveland

test_usedFramework :: TestTree
test_usedFramework = testGroup "getRunMode"
  [ testScenarioOnNetwork "On chain" $ scenario do
      getRunMode >>= \case
        NetworkMode -> pass
        EmulationMode -> failure "Returned wrong mode"

  , testScenarioOnEmulator "Emulated" $ scenarioEmulated do
      getRunMode >>= \case
        EmulationMode -> pass
        NetworkMode -> failure "Returned wrong mode"
  ]

test_whenEmulation :: TestTree
test_whenEmulation = testGroup "whenEmulation"
  [ testScenarioOnEmulator "Allows using emulation-only actions within" $ scenario do
      whenEmulation $ setVotingPowers (mkVotingPowers [])

  , testScenarioOnNetwork "Is skipped during on-chain run" $ scenario do
      whenEmulation $ failure "Sad"
  ]