packages feed

morley-1.3.0: test/Test/Integrational.hs

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

-- | Tests for integrational testing machinery.
module Test.Integrational
  ( spec_Chain_id
  ) where

import Test.Hspec (Spec, it)

import Michelson.Test
import Michelson.Typed
import Tezos.Core
import Util.Named

spec_Chain_id :: Spec
spec_Chain_id = do
  it "Chain id can be set" $
    integrationalTestExpectation $ do
      let code = DROP `Seq` CHAIN_ID `Seq` NIL `Seq` PAIR
      let contract = Contract
            { cCode = code
            , cParamNotes = starParamNotes @'TUnit
            , cStoreNotes = starNotes
            }
      let chainId = mkChainIdUnsafe "aaaa"

      contractAddr <-
        tOriginate contract "" (toVal dummyChainId) (toMutez 50)

      setChainId chainId
      tTransfer (#from .! genesisAddress) (#to .! contractAddr)
        minBound DefEpName (toVal ())

      validate . Right $
        tExpectStorageConst contractAddr (toVal chainId)