11{-# LANGUAGE DataKinds #-}
22{-# LANGUAGE FlexibleContexts #-}
3+ {-# LANGUAGE OverloadedLists #-}
34{-# LANGUAGE ScopedTypeVariables #-}
45{-# LANGUAGE TypeFamilies #-}
56
@@ -9,29 +10,28 @@ module Test.Cardano.Api.EpochLeadership
910where
1011
1112import Cardano.Api
12- import Cardano.Api.Ledger (KeyHash (.. ), StandardCrypto )
13+ import Cardano.Api.Ledger (KeyHash (.. ), toCompactPartial )
1314
1415import Cardano.Binary (serialize )
1516import Cardano.Crypto.Seed (mkSeedFromBytes )
1617import Cardano.Ledger.Api.PParams (emptyPParams )
1718import Cardano.Ledger.BaseTypes (Nonce (.. ), WithOrigin (.. ))
1819import Cardano.Ledger.Binary.Encoding (toByronCBOR )
20+ import Cardano.Ledger.Hashes qualified as L
21+ import Cardano.Ledger.Shelley.API qualified as L
22+ import Cardano.Ledger.State qualified as L
1923import Cardano.Protocol.TPraos.API qualified as API
2024import Cardano.Slotting.EpochInfo (EpochInfo (.. ))
2125import Cardano.Slotting.Time (RelativeTime (.. ), mkSlotLength )
2226import Ouroboros.Consensus.Protocol.Abstract qualified as Consensus
2327import Ouroboros.Consensus.Protocol.TPraos (TPraosState (.. ))
24- import Ouroboros.Consensus.Shelley.Ledger.Query.Types
25- ( IndividualPoolStake (.. )
26- , PoolDistr (.. )
27- )
2828
2929import Data.Map qualified as Map
3030import Data.Ratio ((%) )
3131import Data.Time.Clock (secondsToNominalDiffTime )
3232import GHC.Exts (IsList (.. ))
3333
34- import Hedgehog qualified as H
34+ import Hedgehog
3535import Hedgehog.Extras qualified as H
3636import Test.Tasty (TestTree , testGroup )
3737import Test.Tasty.Hedgehog (testProperty )
@@ -71,43 +71,48 @@ test_currentEpochEligibleLeadershipSlots =
7171 deterministicSigningKey
7272 (proxyToAsType (Proxy :: Proxy VrfKey ))
7373 (mkSeedFromBytes " V5UlALekTHL9bIbe3Yb0Kk4T49gn9smf" )
74- VrfKeyHash hash1 = verificationKeyHash $ getVerificationKey vrskey1
74+ hash1 = L. toVRFVerKeyHash . unVrfKeyHash . verificationKeyHash $ getVerificationKey vrskey1
7575 vrskey2 =
7676 deterministicSigningKey
7777 (proxyToAsType (Proxy :: Proxy VrfKey ))
7878 (mkSeedFromBytes " OLjPbWC6JCjSwO4lqUms0EgkinoLoIhz" )
79- VrfKeyHash hash2 = verificationKeyHash $ getVerificationKey vrskey2
79+ hash2 = L. toVRFVerKeyHash . unVrfKeyHash . verificationKeyHash $ getVerificationKey vrskey2
8080 vrskey3 =
8181 deterministicSigningKey
8282 (proxyToAsType (Proxy :: Proxy VrfKey ))
8383 (mkSeedFromBytes " eF0R2dENRrHM8iyb9q7puTw4y2l8e2z4" )
84- VrfKeyHash hash3 = verificationKeyHash $ getVerificationKey vrskey3
85- poolDistr :: PoolDistr StandardCrypto =
86- PoolDistr $
87- fromList
88- [
89- ( KeyHash " a2927c1e43974b036d8e6838d410279266946e8a094895cfc748c91d"
90- , IndividualPoolStake
91- { individualPoolStake = 1 % 3
92- , individualPoolStakeVrf = hash1
93- }
94- )
95- ,
96- ( KeyHash " 83c5da842d7437e411d3c4db8aaa7a7d2c1642aee932108c9857282d"
97- , IndividualPoolStake
98- { individualPoolStake = 1 % 3
99- , individualPoolStakeVrf = hash2
100- }
101- )
102- ,
103- ( KeyHash " 362c2c2128ee75ca39690c27b42e809301231098003443669e2b03f3"
104- , IndividualPoolStake
105- { individualPoolStake = 1 % 3
106- , individualPoolStakeVrf = hash3
107- }
108- )
109- ]
110- serPoolDistr = SerialisedPoolDistribution (Serialised (serialize (toByronCBOR poolDistr)))
84+ hash3 = L. toVRFVerKeyHash . unVrfKeyHash . verificationKeyHash $ getVerificationKey vrskey3
85+ poolDistr :: L. PoolDistr =
86+ L. PoolDistr
87+ { L. unPoolDistr =
88+ [
89+ ( KeyHash " a2927c1e43974b036d8e6838d410279266946e8a094895cfc748c91d"
90+ , L. IndividualPoolStake
91+ { L. individualPoolStake = 1 % 3
92+ , L. individualTotalPoolStake = toCompactPartial 0
93+ , L. individualPoolStakeVrf = hash1
94+ }
95+ )
96+ ,
97+ ( KeyHash " 83c5da842d7437e411d3c4db8aaa7a7d2c1642aee932108c9857282d"
98+ , L. IndividualPoolStake
99+ { L. individualPoolStake = 1 % 3
100+ , L. individualTotalPoolStake = toCompactPartial 0
101+ , L. individualPoolStakeVrf = hash2
102+ }
103+ )
104+ ,
105+ ( KeyHash " 362c2c2128ee75ca39690c27b42e809301231098003443669e2b03f3"
106+ , L. IndividualPoolStake
107+ { L. individualPoolStake = 1 % 3
108+ , L. individualTotalPoolStake = toCompactPartial 0
109+ , L. individualPoolStakeVrf = hash3
110+ }
111+ )
112+ ]
113+ , L. pdTotalActiveStake = toCompactPartial 0
114+ }
115+ serPoolDistr = Serialised (serialize (toByronCBOR poolDistr))
111116 currentEpoch = EpochNo 4
112117 eEligibleSlots =
113118 currentEpochEligibleLeadershipSlots
@@ -121,8 +126,8 @@ test_currentEpochEligibleLeadershipSlots =
121126 serPoolDistr
122127 currentEpoch
123128 expectedEligibleSlots = [SlotNo 406 , SlotNo 432 , SlotNo 437 , SlotNo 443 , SlotNo 484 ]
124- eligibleSlots <- H. evalEither eEligibleSlots
125- eligibleSlots H. === fromList expectedEligibleSlots
129+ eligibleSlots <- evalEither eEligibleSlots
130+ eligibleSlots === fromList expectedEligibleSlots
126131 where
127132 encodeProtocolState
128133 :: ToCBOR (Consensus. ChainDepState (ConsensusProtocol era ))
0 commit comments