{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Test.Cardano.Ledger.Shelley.Examples.GenesisDelegation (
genesisDelegExample,
) where
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
import Cardano.Ledger.Block (Block (blockHeader))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Keys (GenDelegPair (..), asWitness)
import Cardano.Ledger.Shelley (ShelleyEra, Tx (..), TxBody (..))
import Cardano.Ledger.Shelley.Core
import Cardano.Ledger.Shelley.LedgerState
import Cardano.Ledger.Shelley.State
import Cardano.Ledger.Shelley.Tx (ShelleyTx (..))
import Cardano.Ledger.Shelley.TxOut (ShelleyTxOut (..))
import Cardano.Ledger.Shelley.TxWits (ShelleyTxWits, addrWits)
import Cardano.Ledger.Slot (BlockNo (..), SlotNo (..))
import Cardano.Ledger.TxIn (TxIn (..))
import Cardano.Ledger.Val ((<->))
import qualified Cardano.Ledger.Val as Val
import Cardano.Protocol.Crypto (hashVerKeyVRF)
import Cardano.Protocol.TPraos.BHeader (BHeader, bhHash)
import Cardano.Protocol.TPraos.OCert (KESPeriod (..))
import Data.Default (Default)
import qualified Data.Map.Strict as Map
import qualified Data.Sequence.Strict as StrictSeq
import qualified Data.Set as Set
import Test.Cardano.Ledger.Core.KeyPair (KeyPair (..), mkWitnessesVKey)
import Test.Cardano.Ledger.Shelley.ConcreteCryptoTypes (MockCrypto)
import qualified Test.Cardano.Ledger.Shelley.Examples.Cast as Cast
import Test.Cardano.Ledger.Shelley.Examples.Chain (CHAINExample (..), testCHAINExample)
import qualified Test.Cardano.Ledger.Shelley.Examples.Combinators as C
import Test.Cardano.Ledger.Shelley.Examples.Federation (
coreNodeKeysBySchedule,
coreNodeSK,
coreNodeVK,
)
import Test.Cardano.Ledger.Shelley.Examples.Init (
initSt,
lastByronHeaderHash,
nonce0,
ppEx,
)
import Test.Cardano.Ledger.Shelley.Examples.PoolLifetime (makePulser')
import Test.Cardano.Ledger.Shelley.Generator.Core (
NatNonce (..),
VRFKeyPair (..),
genesisCoins,
mkBlockFakeVRF,
mkOCert,
)
import Test.Cardano.Ledger.Shelley.Generator.EraGen (genesisId)
import Test.Cardano.Ledger.Shelley.Generator.ShelleyEraGen ()
import Test.Cardano.Ledger.Shelley.Rules.Chain (ChainState (..))
import Test.Cardano.Ledger.Shelley.Utils (
RawSeed (..),
getBlockNonce,
mkKeyPair,
mkVRFKeyPair,
)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (testCase)
initUTxO :: EraTxOut era => UTxO era
initUTxO :: forall era. EraTxOut era => UTxO era
initUTxO =
TxId -> [TxOut era] -> UTxO era
forall era. TxId -> [TxOut era] -> UTxO era
genesisCoins
TxId
genesisId
[ Addr -> Value era -> TxOut era
forall era.
(EraTxOut era, HasCallStack) =>
Addr -> Value era -> TxOut era
mkBasicTxOut Addr
Cast.aliceAddr Value era
aliceInitCoin
, Addr -> Value era -> TxOut era
forall era.
(EraTxOut era, HasCallStack) =>
Addr -> Value era -> TxOut era
mkBasicTxOut Addr
Cast.bobAddr Value era
bobInitCoin
]
where
aliceInitCoin :: Value era
aliceInitCoin = Coin -> Value era
forall t s. Inject t s => t -> s
Val.inject (Coin -> Value era) -> Coin -> Value era
forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin (Integer -> Coin) -> Integer -> Coin
forall a b. (a -> b) -> a -> b
$ Integer
10 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000
bobInitCoin :: Value era
bobInitCoin = Coin -> Value era
forall t s. Inject t s => t -> s
Val.inject (Coin -> Value era) -> Coin -> Value era
forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin (Integer -> Coin) -> Integer -> Coin
forall a b. (a -> b) -> a -> b
$ Integer
1 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000
initStGenesisDeleg ::
( EraTxOut era
, EraGov era
, EraStake era
, EraCertState era
, AtMostEra "Mary" era
, AtMostEra "Alonzo" era
, Default (StashedAVVMAddresses era)
) =>
ChainState era
initStGenesisDeleg :: forall era.
(EraTxOut era, EraGov era, EraStake era, EraCertState era,
AtMostEra "Mary" era, AtMostEra "Alonzo" era,
Default (StashedAVVMAddresses era)) =>
ChainState era
initStGenesisDeleg = UTxO era -> ChainState era
forall era.
(EraTxOut era, EraGov era, EraStake era, EraCertState era,
AtMostEra "Mary" era, AtMostEra "Alonzo" era,
Default (StashedAVVMAddresses era)) =>
UTxO era -> ChainState era
initSt UTxO era
forall era. EraTxOut era => UTxO era
initUTxO
newGenDelegate :: KeyPair GenesisDelegate
newGenDelegate :: KeyPair GenesisDelegate
newGenDelegate = VKey GenesisDelegate
-> SignKeyDSIGN DSIGN -> KeyPair GenesisDelegate
forall (kd :: KeyRole). VKey kd -> SignKeyDSIGN DSIGN -> KeyPair kd
KeyPair VKey GenesisDelegate
forall {kd :: KeyRole}. VKey kd
vkCold SignKeyDSIGN DSIGN
skCold
where
(SignKeyDSIGN DSIGN
skCold, VKey kd
vkCold) = RawSeed -> (SignKeyDSIGN DSIGN, VKey kd)
forall (kd :: KeyRole). RawSeed -> (SignKeyDSIGN DSIGN, VKey kd)
mkKeyPair (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
108 Word64
0 Word64
0 Word64
0 Word64
1)
newGenesisVrfKH :: VRFVerKeyHash GenDelegVRF
newGenesisVrfKH :: VRFVerKeyHash GenDelegVRF
newGenesisVrfKH = forall c (r :: KeyRoleVRF).
Crypto c =>
VerKeyVRF (VRF c) -> VRFVerKeyHash r
hashVerKeyVRF @MockCrypto (VRFKeyPair MockCrypto -> VerKeyVRF (VRF MockCrypto)
forall c. VRFKeyPair c -> VerKeyVRF (VRF c)
vrfVerKey (forall c. Crypto c => RawSeed -> VRFKeyPair c
mkVRFKeyPair @MockCrypto (Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RawSeed
RawSeed Word64
9 Word64
8 Word64
7 Word64
6 Word64
5)))
feeTx1 :: Coin
feeTx1 :: Coin
feeTx1 = Integer -> Coin
Coin Integer
1
txbodyEx1 :: TxBody TopTx ShelleyEra
txbodyEx1 :: TxBody TopTx ShelleyEra
txbodyEx1 =
Set TxIn
-> StrictSeq (TxOut ShelleyEra)
-> StrictSeq (TxCert ShelleyEra)
-> Withdrawals
-> Coin
-> SlotNo
-> StrictMaybe (Update ShelleyEra)
-> StrictMaybe TxAuxDataHash
-> TxBody TopTx ShelleyEra
ShelleyTxBody
([TxIn] -> Set TxIn
forall a. Ord a => [a] -> Set a
Set.fromList [TxId -> TxIx -> TxIn
TxIn TxId
genesisId TxIx
forall a. Bounded a => a
minBound])
(TxOut ShelleyEra -> StrictSeq (TxOut ShelleyEra)
forall a. a -> StrictSeq a
StrictSeq.singleton (TxOut ShelleyEra -> StrictSeq (TxOut ShelleyEra))
-> TxOut ShelleyEra -> StrictSeq (TxOut ShelleyEra)
forall a b. (a -> b) -> a -> b
$ Addr -> Value ShelleyEra -> ShelleyTxOut ShelleyEra
forall era.
(HasCallStack, Era era, Val (Value era)) =>
Addr -> Value era -> ShelleyTxOut era
ShelleyTxOut Addr
Cast.aliceAddr Value ShelleyEra
Coin
aliceCoinEx1)
( [ShelleyTxCert ShelleyEra] -> StrictSeq (ShelleyTxCert ShelleyEra)
forall a. [a] -> StrictSeq a
StrictSeq.fromList
[ KeyHash GenesisRole
-> KeyHash GenesisDelegate
-> VRFVerKeyHash GenDelegVRF
-> TxCert ShelleyEra
forall era.
(ShelleyEraTxCert era, AtMostEra "Babbage" era) =>
KeyHash GenesisRole
-> KeyHash GenesisDelegate
-> VRFVerKeyHash GenDelegVRF
-> TxCert era
GenesisDelegTxCert
(VKey GenesisRole -> KeyHash GenesisRole
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (Int -> VKey GenesisRole
coreNodeVK Int
0))
(VKey GenesisDelegate -> KeyHash GenesisDelegate
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (KeyPair GenesisDelegate -> VKey GenesisDelegate
forall (kd :: KeyRole). KeyPair kd -> VKey kd
vKey KeyPair GenesisDelegate
newGenDelegate))
VRFVerKeyHash GenDelegVRF
newGenesisVrfKH
]
)
(Map RewardAccount Coin -> Withdrawals
Withdrawals Map RewardAccount Coin
forall k a. Map k a
Map.empty)
(Integer -> Coin
Coin Integer
1)
(Word64 -> SlotNo
SlotNo Word64
10)
StrictMaybe (Update ShelleyEra)
forall a. StrictMaybe a
SNothing
StrictMaybe TxAuxDataHash
forall a. StrictMaybe a
SNothing
where
aliceCoinEx1 :: Coin
aliceCoinEx1 = Coin
aliceInitCoin Coin -> Coin -> Coin
forall t. Val t => t -> t -> t
<-> Coin -> Coin
forall t s. Inject t s => t -> s
Val.inject Coin
feeTx1
aliceInitCoin :: Coin
aliceInitCoin = Coin -> Coin
forall t s. Inject t s => t -> s
Val.inject (Coin -> Coin) -> Coin -> Coin
forall a b. (a -> b) -> a -> b
$ Integer -> Coin
Coin (Integer -> Coin) -> Integer -> Coin
forall a b. (a -> b) -> a -> b
$ Integer
10 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1000
txEx1 :: ShelleyTx TopTx ShelleyEra
txEx1 :: ShelleyTx TopTx ShelleyEra
txEx1 = TxBody TopTx ShelleyEra
-> TxWits ShelleyEra
-> StrictMaybe (TxAuxData ShelleyEra)
-> ShelleyTx TopTx ShelleyEra
forall era.
TxBody TopTx era
-> TxWits era -> StrictMaybe (TxAuxData era) -> ShelleyTx TopTx era
ShelleyTx TxBody TopTx ShelleyEra
txbodyEx1 TxWits ShelleyEra
ShelleyTxWits ShelleyEra
txwits StrictMaybe (TxAuxData ShelleyEra)
StrictMaybe (ShelleyTxAuxData ShelleyEra)
forall a. StrictMaybe a
SNothing
where
txwits :: ShelleyTxWits ShelleyEra
txwits :: ShelleyTxWits ShelleyEra
txwits =
ShelleyTxWits ShelleyEra
forall a. Monoid a => a
mempty
{ addrWits =
mkWitnessesVKey
(hashAnnotated txbodyEx1)
( [asWitness Cast.alicePay]
<> [ asWitness $
KeyPair @GenesisRole
(coreNodeVK 0)
(coreNodeSK 0)
]
)
}
blockEx1 :: Block (BHeader MockCrypto) ShelleyEra
blockEx1 :: Block (BHeader MockCrypto) ShelleyEra
blockEx1 =
forall era (r :: KeyRole) c.
(Crypto c, EraBlockBody era, Signable (VRF c) (WithResult Seed),
Signable (KES c) (BHBody c)) =>
HashHeader
-> AllIssuerKeys c r
-> [Tx TopTx era]
-> SlotNo
-> BlockNo
-> Nonce
-> NatNonce
-> UnitInterval
-> Word
-> Word
-> OCert c
-> Block (BHeader c) era
mkBlockFakeVRF @ShelleyEra
HashHeader
lastByronHeaderHash
(forall era.
(HasCallStack, EraPParams era) =>
PParams era -> Word64 -> AllIssuerKeys MockCrypto GenesisDelegate
coreNodeKeysBySchedule @ShelleyEra PParams ShelleyEra
forall era.
(EraPParams era, AtMostEra "Mary" era, AtMostEra "Alonzo" era) =>
PParams era
ppEx Word64
10)
[ShelleyTx TopTx ShelleyEra -> Tx TopTx ShelleyEra
forall (l :: TxLevel). ShelleyTx l ShelleyEra -> Tx l ShelleyEra
MkShelleyTx ShelleyTx TopTx ShelleyEra
txEx1]
(Word64 -> SlotNo
SlotNo Word64
10)
(Word64 -> BlockNo
BlockNo Word64
1)
Nonce
nonce0
(Natural -> NatNonce
NatNonce Natural
1)
UnitInterval
forall a. Bounded a => a
minBound
Word
0
Word
0
(forall c (r :: KeyRole).
Crypto c =>
AllIssuerKeys c r -> Word64 -> KESPeriod -> OCert c
mkOCert @MockCrypto (forall era.
(HasCallStack, EraPParams era) =>
PParams era -> Word64 -> AllIssuerKeys MockCrypto GenesisDelegate
coreNodeKeysBySchedule @ShelleyEra PParams ShelleyEra
forall era.
(EraPParams era, AtMostEra "Mary" era, AtMostEra "Alonzo" era) =>
PParams era
ppEx Word64
10) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
newGenDeleg :: (FutureGenDeleg, GenDelegPair)
newGenDeleg :: (FutureGenDeleg, GenDelegPair)
newGenDeleg =
( SlotNo -> KeyHash GenesisRole -> FutureGenDeleg
FutureGenDeleg (Word64 -> SlotNo
SlotNo Word64
43) (VKey GenesisRole -> KeyHash GenesisRole
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (VKey GenesisRole -> KeyHash GenesisRole)
-> VKey GenesisRole -> KeyHash GenesisRole
forall a b. (a -> b) -> a -> b
$ Int -> VKey GenesisRole
coreNodeVK Int
0)
, KeyHash GenesisDelegate
-> VRFVerKeyHash GenDelegVRF -> GenDelegPair
GenDelegPair (VKey GenesisDelegate -> KeyHash GenesisDelegate
forall (kd :: KeyRole). VKey kd -> KeyHash kd
hashKey (VKey GenesisDelegate -> KeyHash GenesisDelegate)
-> VKey GenesisDelegate -> KeyHash GenesisDelegate
forall a b. (a -> b) -> a -> b
$ KeyPair GenesisDelegate -> VKey GenesisDelegate
forall (kd :: KeyRole). KeyPair kd -> VKey kd
vKey KeyPair GenesisDelegate
newGenDelegate) VRFVerKeyHash GenDelegVRF
newGenesisVrfKH
)
expectedStEx1 :: ChainState ShelleyEra
expectedStEx1 :: ChainState ShelleyEra
expectedStEx1 =
Nonce -> ChainState ShelleyEra -> ChainState ShelleyEra
forall era. Nonce -> ChainState era -> ChainState era
C.evolveNonceUnfrozen (forall era. Block (BHeader MockCrypto) era -> Nonce
getBlockNonce @ShelleyEra Block (BHeader MockCrypto) ShelleyEra
blockEx1)
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Block (BHeader MockCrypto) ShelleyEra
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall era.
Block (BHeader MockCrypto) era -> ChainState era -> ChainState era
C.newLab Block (BHeader MockCrypto) ShelleyEra
blockEx1
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Coin -> ChainState ShelleyEra -> ChainState ShelleyEra
forall era. Coin -> ChainState era -> ChainState era
C.addFees Coin
feeTx1
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxBody TopTx ShelleyEra
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall era.
(EraTx era, EraStake era) =>
TxBody TopTx era -> ChainState era -> ChainState era
C.newUTxO TxBody TopTx ShelleyEra
txbodyEx1
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FutureGenDeleg, GenDelegPair)
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall era.
EraCertState era =>
(FutureGenDeleg, GenDelegPair) -> ChainState era -> ChainState era
C.setFutureGenDeleg (FutureGenDeleg, GenDelegPair)
newGenDeleg
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall a b. (a -> b) -> a -> b
$ ChainState ShelleyEra
forall era.
(EraTxOut era, EraGov era, EraStake era, EraCertState era,
AtMostEra "Mary" era, AtMostEra "Alonzo" era,
Default (StashedAVVMAddresses era)) =>
ChainState era
initStGenesisDeleg
genesisDelegation1 :: CHAINExample ShelleyEra
genesisDelegation1 :: CHAINExample ShelleyEra
genesisDelegation1 = ChainState ShelleyEra
-> Block (BHeader MockCrypto) ShelleyEra
-> Either
(NonEmpty (PredicateFailure (CHAIN ShelleyEra)))
(ChainState ShelleyEra)
-> CHAINExample ShelleyEra
forall era.
ChainState era
-> Block (BHeader MockCrypto) era
-> Either
(NonEmpty (PredicateFailure (CHAIN era))) (ChainState era)
-> CHAINExample era
CHAINExample ChainState ShelleyEra
forall era.
(EraTxOut era, EraGov era, EraStake era, EraCertState era,
AtMostEra "Mary" era, AtMostEra "Alonzo" era,
Default (StashedAVVMAddresses era)) =>
ChainState era
initStGenesisDeleg Block (BHeader MockCrypto) ShelleyEra
blockEx1 (ChainState ShelleyEra
-> Either
(NonEmpty (TestChainPredicateFailure ShelleyEra))
(ChainState ShelleyEra)
forall a b. b -> Either a b
Right ChainState ShelleyEra
expectedStEx1)
blockEx2 :: Block (BHeader MockCrypto) ShelleyEra
blockEx2 :: Block (BHeader MockCrypto) ShelleyEra
blockEx2 =
forall era (r :: KeyRole) c.
(Crypto c, EraBlockBody era, Signable (VRF c) (WithResult Seed),
Signable (KES c) (BHBody c)) =>
HashHeader
-> AllIssuerKeys c r
-> [Tx TopTx era]
-> SlotNo
-> BlockNo
-> Nonce
-> NatNonce
-> UnitInterval
-> Word
-> Word
-> OCert c
-> Block (BHeader c) era
mkBlockFakeVRF @ShelleyEra
(BHeader MockCrypto -> HashHeader
forall c. BHeader c -> HashHeader
bhHash (BHeader MockCrypto -> HashHeader)
-> BHeader MockCrypto -> HashHeader
forall a b. (a -> b) -> a -> b
$ Block (BHeader MockCrypto) ShelleyEra -> BHeader MockCrypto
forall h era. Block h era -> h
blockHeader Block (BHeader MockCrypto) ShelleyEra
blockEx1)
(forall era.
(HasCallStack, EraPParams era) =>
PParams era -> Word64 -> AllIssuerKeys MockCrypto GenesisDelegate
coreNodeKeysBySchedule @ShelleyEra PParams ShelleyEra
forall era.
(EraPParams era, AtMostEra "Mary" era, AtMostEra "Alonzo" era) =>
PParams era
ppEx Word64
50)
[]
(Word64 -> SlotNo
SlotNo Word64
50)
(Word64 -> BlockNo
BlockNo Word64
2)
Nonce
nonce0
(Natural -> NatNonce
NatNonce Natural
2)
UnitInterval
forall a. Bounded a => a
minBound
Word
2
Word
0
(forall c (r :: KeyRole).
Crypto c =>
AllIssuerKeys c r -> Word64 -> KESPeriod -> OCert c
mkOCert @MockCrypto (forall era.
(HasCallStack, EraPParams era) =>
PParams era -> Word64 -> AllIssuerKeys MockCrypto GenesisDelegate
coreNodeKeysBySchedule @ShelleyEra PParams ShelleyEra
forall era.
(EraPParams era, AtMostEra "Mary" era, AtMostEra "Alonzo" era) =>
PParams era
ppEx Word64
50) Word64
0 (Word -> KESPeriod
KESPeriod Word
0))
pulserEx2 :: PulsingRewUpdate
pulserEx2 :: PulsingRewUpdate
pulserEx2 = ChainState ShelleyEra -> PulsingRewUpdate
forall era.
(EraGov era, EraCertState era) =>
ChainState era -> PulsingRewUpdate
makePulser' ChainState ShelleyEra
expectedStEx1
expectedStEx2 :: ChainState ShelleyEra
expectedStEx2 :: ChainState ShelleyEra
expectedStEx2 =
Nonce -> ChainState ShelleyEra -> ChainState ShelleyEra
forall era. Nonce -> ChainState era -> ChainState era
C.evolveNonceUnfrozen (forall era. Block (BHeader MockCrypto) era -> Nonce
getBlockNonce @ShelleyEra Block (BHeader MockCrypto) ShelleyEra
blockEx2)
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Block (BHeader MockCrypto) ShelleyEra
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall era.
Block (BHeader MockCrypto) era -> ChainState era -> ChainState era
C.newLab Block (BHeader MockCrypto) ShelleyEra
blockEx2
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FutureGenDeleg, GenDelegPair)
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall era.
EraCertState era =>
(FutureGenDeleg, GenDelegPair) -> ChainState era -> ChainState era
C.adoptFutureGenDeleg (FutureGenDeleg, GenDelegPair)
newGenDeleg
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PulsingRewUpdate -> ChainState ShelleyEra -> ChainState ShelleyEra
forall era. PulsingRewUpdate -> ChainState era -> ChainState era
C.pulserUpdate PulsingRewUpdate
pulserEx2
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> (ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra
-> ChainState ShelleyEra
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChainState ShelleyEra -> ChainState ShelleyEra
forall era. EraGov era => ChainState era -> ChainState era
C.solidifyProposals
(ChainState ShelleyEra -> ChainState ShelleyEra)
-> ChainState ShelleyEra -> ChainState ShelleyEra
forall a b. (a -> b) -> a -> b
$ ChainState ShelleyEra
expectedStEx1
genesisDelegation2 :: CHAINExample ShelleyEra
genesisDelegation2 :: CHAINExample ShelleyEra
genesisDelegation2 = ChainState ShelleyEra
-> Block (BHeader MockCrypto) ShelleyEra
-> Either
(NonEmpty (PredicateFailure (CHAIN ShelleyEra)))
(ChainState ShelleyEra)
-> CHAINExample ShelleyEra
forall era.
ChainState era
-> Block (BHeader MockCrypto) era
-> Either
(NonEmpty (PredicateFailure (CHAIN era))) (ChainState era)
-> CHAINExample era
CHAINExample ChainState ShelleyEra
expectedStEx1 Block (BHeader MockCrypto) ShelleyEra
blockEx2 (ChainState ShelleyEra
-> Either
(NonEmpty (TestChainPredicateFailure ShelleyEra))
(ChainState ShelleyEra)
forall a b. b -> Either a b
Right ChainState ShelleyEra
expectedStEx2)
genesisDelegExample :: TestTree
genesisDelegExample :: TestTree
genesisDelegExample =
String -> [TestTree] -> TestTree
forall a. HasCallStack => String -> [SpecWith a] -> SpecWith a
testGroup
String
"genesis delegation"
[ HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"stage genesis key delegation" (Expectation -> TestTree) -> Expectation -> TestTree
forall a b. (a -> b) -> a -> b
$ HasCallStack => CHAINExample ShelleyEra -> Expectation
CHAINExample ShelleyEra -> Expectation
testCHAINExample CHAINExample ShelleyEra
genesisDelegation1
, HasCallStack => String -> Expectation -> TestTree
String -> Expectation -> TestTree
testCase String
"adopt genesis key delegation" (Expectation -> TestTree) -> Expectation -> TestTree
forall a b. (a -> b) -> a -> b
$ HasCallStack => CHAINExample ShelleyEra -> Expectation
CHAINExample ShelleyEra -> Expectation
testCHAINExample CHAINExample ShelleyEra
genesisDelegation2
]