Skip to content

Commit

Permalink
shelley-ma-tests have been transitioned
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Nov 30, 2022
1 parent 80a3022 commit 0978a49
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 159 deletions.
Expand Up @@ -10,7 +10,7 @@ where

import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core
import Cardano.Ledger.Mary (MaryEra)
import Cardano.Ledger.Mary (Mary)
import Cardano.Ledger.Shelley.API (LedgerEnv (..), ShelleyLEDGER)
import Cardano.Ledger.Shelley.LedgerState (LedgerState (..), UTxOState (..), smartUTxOState)
import Cardano.Ledger.Shelley.PParams (ShelleyPParamsHKD (..))
Expand All @@ -21,33 +21,30 @@ import Control.State.Transition.Trace (checkTrace, (.-), (.->))
import Data.Default.Class (def)
import GHC.Stack
import Lens.Micro
import Test.Cardano.Ledger.EraBuffet (TestCrypto)
import Test.Cardano.Ledger.Shelley.Utils (applySTSTest, runShelleyBase)
import Test.Tasty.HUnit (Assertion, (@?=))

type MaryTest = MaryEra TestCrypto

ignoreAllButUTxO ::
Either [PredicateFailure (ShelleyLEDGER MaryTest)] (LedgerState MaryTest) ->
Either [PredicateFailure (ShelleyLEDGER MaryTest)] (UTxO MaryTest)
Either [PredicateFailure (ShelleyLEDGER Mary)] (LedgerState Mary) ->
Either [PredicateFailure (ShelleyLEDGER Mary)] (UTxO Mary)
ignoreAllButUTxO = fmap (\(LedgerState (UTxOState utxo _ _ _ _) _) -> utxo)

testMaryNoDelegLEDGER ::
HasCallStack =>
UTxO MaryTest ->
ShelleyTx MaryTest ->
LedgerEnv MaryTest ->
Either [PredicateFailure (ShelleyLEDGER MaryTest)] (UTxO MaryTest) ->
UTxO Mary ->
ShelleyTx Mary ->
LedgerEnv Mary ->
Either [PredicateFailure (ShelleyLEDGER Mary)] (UTxO Mary) ->
Assertion
testMaryNoDelegLEDGER utxo tx env (Right expectedUTxO) = do
checkTrace @(ShelleyLEDGER MaryTest) runShelleyBase env $
checkTrace @(ShelleyLEDGER Mary) runShelleyBase env $
pure (LedgerState (smartUTxOState utxo (Coin 0) (Coin 0) def) def) .- tx .-> expectedSt'
where
txFee = tx ^. bodyTxL . feeTxBodyL
expectedSt' = LedgerState (smartUTxOState expectedUTxO (Coin 0) txFee def) def
testMaryNoDelegLEDGER utxo tx env predicateFailure@(Left _) = do
let st =
runShelleyBase $
applySTSTest @(ShelleyLEDGER MaryTest)
applySTSTest @(ShelleyLEDGER Mary)
(TRC (env, LedgerState (smartUTxOState utxo (Coin 0) (Coin 0) def) def, tx))
ignoreAllButUTxO st @?= predicateFailure
Expand Up @@ -22,73 +22,73 @@ module Test.Cardano.Ledger.Mary.Examples.Cast
where

import Cardano.Ledger.Address (Addr (..))
import Cardano.Ledger.Crypto (StandardCrypto)
import Cardano.Ledger.Keys
( KeyPair (..),
KeyRole (..),
)
import Test.Cardano.Ledger.EraBuffet (TestCrypto)
import Test.Cardano.Ledger.Shelley.Utils (RawSeed (..), mkAddr, mkKeyPair)

-- | Alice's payment key pair
alicePay :: KeyPair 'Payment TestCrypto
alicePay :: KeyPair 'Payment StandardCrypto
alicePay = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 0 0 0 0 0)

-- | Alice's stake key pair
aliceStake :: KeyPair 'Staking TestCrypto
aliceStake :: KeyPair 'Staking StandardCrypto
aliceStake = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 1 1 1 1 1)

-- | Alice's base address
aliceAddr :: Addr TestCrypto
aliceAddr :: Addr StandardCrypto
aliceAddr = mkAddr (alicePay, aliceStake)

-- | Bob's payment key pair
bobPay :: KeyPair 'Payment TestCrypto
bobPay :: KeyPair 'Payment StandardCrypto
bobPay = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 2 2 2 2 2)

-- | Bob's stake key pair
bobStake :: KeyPair 'Staking TestCrypto
bobStake :: KeyPair 'Staking StandardCrypto
bobStake = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 3 3 3 3 3)

-- | Bob's address
bobAddr :: Addr TestCrypto
bobAddr :: Addr StandardCrypto
bobAddr = mkAddr (bobPay, bobStake)

-- Carl's payment key pair
carlPay :: KeyPair 'Payment TestCrypto
carlPay :: KeyPair 'Payment StandardCrypto
carlPay = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 4 4 4 4 4)

-- | Carl's stake key pair
carlStake :: KeyPair 'Staking TestCrypto
carlStake :: KeyPair 'Staking StandardCrypto
carlStake = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 5 5 5 5 5)

-- | Carl's address
carlAddr :: Addr TestCrypto
carlAddr :: Addr StandardCrypto
carlAddr = mkAddr (carlPay, carlStake)

-- | Daria's payment key pair
dariaPay :: KeyPair 'Payment TestCrypto
dariaPay :: KeyPair 'Payment StandardCrypto
dariaPay = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 6 6 6 6 6)

-- | Daria's stake key pair
dariaStake :: KeyPair 'Staking TestCrypto
dariaStake :: KeyPair 'Staking StandardCrypto
dariaStake = KeyPair vk sk
where
(sk, vk) = mkKeyPair (RawSeed 7 7 7 7 7)

-- | Daria's address
dariaAddr :: Addr TestCrypto
dariaAddr :: Addr StandardCrypto
dariaAddr = mkAddr (dariaPay, dariaStake)

0 comments on commit 0978a49

Please sign in to comment.