Skip to content

Commit 1c46afa

Browse files
committed
Fix tests compilation issues
1 parent 9060669 commit 1c46afa

File tree

5 files changed

+49
-45
lines changed

5 files changed

+49
-45
lines changed

cardano-api/cardano-api.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ test-suite cardano-api-test
369369
cardano-ledger-conway,
370370
cardano-ledger-core >=1.14,
371371
cardano-ledger-mary,
372+
cardano-ledger-shelley,
372373
cardano-protocol-tpraos,
373374
cardano-slotting,
374375
cborg,
@@ -381,7 +382,6 @@ test-suite cardano-api-test
381382
microlens,
382383
mtl,
383384
ouroboros-consensus,
384-
ouroboros-consensus-cardano,
385385
ouroboros-consensus-protocol,
386386
raw-strings-qq,
387387
tasty,

cardano-api/src/Cardano/Api/Key/Internal/Praos.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,8 @@ instance SerialiseAsBech32 (SigningKey VrfKey) where
228228

229229
newtype instance Hash VrfKey
230230
= VrfKeyHash
231-
( Crypto.Hash
232-
HASH
233-
(Crypto.VerKeyVRF (VRF StandardCrypto))
234-
)
231+
{ unVrfKeyHash :: Crypto.Hash HASH (Crypto.VerKeyVRF (VRF StandardCrypto))
232+
}
235233
deriving stock (Eq, Ord)
236234
deriving (Show, Pretty) via UsingRawBytesHex (Hash VrfKey)
237235
deriving (ToCBOR, FromCBOR) via UsingRawBytes (Hash VrfKey)

cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ module Cardano.Api.Ledger.Internal.Reexport
4646
, pattern UpdateDRepTxCert
4747
-- Core
4848
, Coin (..)
49+
, Compactible (..)
50+
, partialCompactFL
51+
, toCompactPartial
4952
, EraPParams (..)
5053
, Era (..)
5154
, EraTxOut
@@ -274,6 +277,7 @@ import Cardano.Ledger.Binary
274277
)
275278
import Cardano.Ledger.Binary.Plain (Decoder, serializeAsHexText)
276279
import Cardano.Ledger.Coin (Coin (..), addDeltaCoin, toDeltaCoin)
280+
import Cardano.Ledger.Compactible
277281
import Cardano.Ledger.Conway.Core
278282
( DRepVotingThresholds (..)
279283
, PoolVotingThresholds (..)

cardano-api/src/Cardano/Api/LedgerState.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ import Cardano.Ledger.BaseTypes
165165
)
166166
import Cardano.Ledger.BaseTypes qualified as Ledger
167167
import Cardano.Ledger.Binary (DecoderError)
168-
import Cardano.Ledger.Coin qualified as SL
169168
import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..))
170169
import Cardano.Ledger.Dijkstra.PParams qualified as Ledger
171170
import Cardano.Ledger.Keys qualified as SL
@@ -209,8 +208,6 @@ import Ouroboros.Consensus.Protocol.TPraos qualified as TPraos
209208
import Ouroboros.Consensus.Shelley.HFEras qualified as Shelley
210209
import Ouroboros.Consensus.Shelley.Ledger.Block qualified as Shelley
211210
import Ouroboros.Consensus.Shelley.Ledger.Ledger qualified as Shelley
212-
import Ouroboros.Consensus.Shelley.Ledger.Query.Types qualified as Consensus
213-
import Ouroboros.Consensus.Shelley.Ledger.Query.Types qualified as Shelley
214211
import Ouroboros.Consensus.TypeFamilyWrappers (WrapLedgerEvent (WrapLedgerEvent))
215212
import Ouroboros.Network.Block (blockNo)
216213
import Ouroboros.Network.Block qualified

cardano-api/test/cardano-api-test/Test/Cardano/Api/EpochLeadership.hs

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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
910
where
1011

1112
import Cardano.Api
12-
import Cardano.Api.Ledger (KeyHash (..), StandardCrypto)
13+
import Cardano.Api.Ledger (KeyHash (..), toCompactPartial)
1314

1415
import Cardano.Binary (serialize)
1516
import Cardano.Crypto.Seed (mkSeedFromBytes)
1617
import Cardano.Ledger.Api.PParams (emptyPParams)
1718
import Cardano.Ledger.BaseTypes (Nonce (..), WithOrigin (..))
1819
import 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
1923
import Cardano.Protocol.TPraos.API qualified as API
2024
import Cardano.Slotting.EpochInfo (EpochInfo (..))
2125
import Cardano.Slotting.Time (RelativeTime (..), mkSlotLength)
2226
import Ouroboros.Consensus.Protocol.Abstract qualified as Consensus
2327
import Ouroboros.Consensus.Protocol.TPraos (TPraosState (..))
24-
import Ouroboros.Consensus.Shelley.Ledger.Query.Types
25-
( IndividualPoolStake (..)
26-
, PoolDistr (..)
27-
)
2828

2929
import Data.Map qualified as Map
3030
import Data.Ratio ((%))
3131
import Data.Time.Clock (secondsToNominalDiffTime)
3232
import GHC.Exts (IsList (..))
3333

34-
import Hedgehog qualified as H
34+
import Hedgehog
3535
import Hedgehog.Extras qualified as H
3636
import Test.Tasty (TestTree, testGroup)
3737
import 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

Comments
 (0)