Skip to content

Commit

Permalink
Make empty PoolDistr constructively
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Jul 1, 2024
1 parent 5af4c62 commit 3e2dc23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ test-suite cardano-api-golden
, cardano-ledger-alonzo
, cardano-ledger-api ^>= 1.9
, cardano-ledger-babbage >= 1.6.0
, cardano-ledger-binary
, cardano-ledger-core:{cardano-ledger-core, testlib} >= 1.8
, cardano-ledger-shelley
, cardano-ledger-shelley-test >= 1.2.0.1
Expand All @@ -379,6 +380,7 @@ test-suite cardano-api-golden
, hedgehog >= 1.1
, hedgehog-extras ^>= 0.6.1.0
, microlens
, ouroboros-consensus-cardano
, ouroboros-network-api
, parsec
, plutus-core ^>= 1.30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ import Cardano.Api.Block (EpochNo (..), Hash (StakePoolKeyHash), SlotN
import Cardano.Api.Eon.ShelleyBasedEra (ShelleyBasedEra (..))
import Cardano.Api.Genesis (shelleyGenesisDefaults)
import Cardano.Api.GenesisParameters (EpochSize (..))
import Cardano.Api.Ledger (KeyHash (KeyHash))
import Cardano.Api.Ledger (KeyHash (..), StandardCrypto)
import Cardano.Api.LedgerState (currentEpochEligibleLeadershipSlots)
import Cardano.Api.Query (ProtocolState (..),
SerialisedPoolDistribution (SerialisedPoolDistribution))
import Cardano.Api.Shelley (VrfKey, proxyToAsType, unStakePoolKeyHash)

import Cardano.Binary (serialize)
import Cardano.Crypto.Seed (mkSeedFromBytes)
import Cardano.Ledger.Api.PParams (emptyPParams)
import Cardano.Ledger.Binary.Encoding (toByronCBOR)
import Cardano.Slotting.EpochInfo (EpochInfo (..))
import Cardano.Slotting.Time (RelativeTime (..), mkSlotLength)
import Ouroboros.Consensus.Shelley.Ledger.Query.Types (PoolDistr (..))
import Ouroboros.Network.Block (Serialised (..))

import qualified Data.Map as Map
import Data.Proxy (Proxy (..))
import qualified Data.Set as Set
import Data.Time.Clock (secondsToNominalDiffTime)
Expand All @@ -44,7 +48,8 @@ test_golden_currentEpochEligibleLeadershipSlots = testProperty "golden EpochLead
ptclState = ProtocolState (Serialised "dummyProtocolState")
poolid = StakePoolKeyHash { unStakePoolKeyHash = KeyHash "58eef2925db2789f76ea057c51069e52c5e0a44550f853c6cdf620f8" }
vrskey = deterministicSigningKey (proxyToAsType (Proxy :: Proxy VrfKey)) (mkSeedFromBytes "")
serPoolDistr = SerialisedPoolDistribution (Serialised "dummyPoolDistr")
poolDistr :: PoolDistr StandardCrypto = PoolDistr Map.empty
serPoolDistr = SerialisedPoolDistribution (Serialised (serialize (toByronCBOR poolDistr)))
currentEpoch = EpochNo 4
eEligibileSlots = currentEpochEligibleLeadershipSlots sbe sGen eInfo pp ptclState poolid vrskey serPoolDistr currentEpoch
expectedEligibleSlots = [SlotNo 2, SlotNo 6]
Expand Down

0 comments on commit 3e2dc23

Please sign in to comment.