Skip to content

Commit 2510f22

Browse files
committed
Add golden test for queryStakeSnapshots
1 parent 495be29 commit 2510f22

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

119 Bytes
Binary file not shown.
Binary file not shown.

libs/cardano-ledger-api/test/Test/Cardano/Ledger/Api/State/QuerySpec.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import Test.Cardano.Ledger.Api.State.Query.Examples (
6464
queryStakePoolDefaultVoteExamples,
6565
queryStakePoolDelegsAndRewardsExamples,
6666
queryStakePoolRelaysExamples,
67+
queryStakeSnapshotsExamples,
6768
)
6869
import Test.Cardano.Ledger.Binary.Golden (cborGoldenSpec)
6970
import Test.Cardano.Ledger.Binary.Random
@@ -162,6 +163,7 @@ latestErasSpec =
162163
"queryStakePoolDelegsAndRewards"
163164
queryStakePoolDelegsAndRewardsExamples
164165
eraLedgerStateQueryGoldenSpec @era "queryStakePoolRelays" queryStakePoolRelaysExamples
166+
eraLedgerStateQueryCBORGoldenSpec @era "queryStakeSnapshots" queryStakeSnapshotsExamples
165167
describe "Roundtrip" $ do
166168
prop "QueryPoolStateResult" $ roundTripEraExpectation @era @QueryPoolStateResult
167169
prop "StakeSnapshots" $ roundTripEraExpectation @era @StakeSnapshots

libs/cardano-ledger-api/testlib/Test/Cardano/Ledger/Api/State/Query/Examples.hs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ module Test.Cardano.Ledger.Api.State.Query.Examples (
2121
queryStakePoolDefaultVoteExamples,
2222
queryStakePoolDelegsAndRewardsExamples,
2323
queryStakePoolRelaysExamples,
24+
queryStakeSnapshotsExamples,
2425
) where
2526

2627
import Cardano.Base.IP (toIPv4, toIPv6)
2728
import Cardano.Ledger.Api.Governance (Constitution (..))
28-
import Cardano.Ledger.Api.State.Query (DefaultVote (..), QueryPoolStateResult (..))
29+
import Cardano.Ledger.Api.State.Query (
30+
DefaultVote (..),
31+
QueryPoolStateResult (..),
32+
StakeSnapshot (..),
33+
StakeSnapshots (..),
34+
)
2935
import Cardano.Ledger.BaseTypes (AnchorData, EpochNo (..), Port (..), StrictMaybe (..), textToDns)
3036
import Cardano.Ledger.Coin (Coin (..), CompactForm (..), knownNonZeroCoin)
3137
import Cardano.Ledger.Credential (Credential (..))
@@ -304,3 +310,36 @@ queryPoolStateExamples =
304310
]
305311
}
306312
]
313+
314+
queryStakeSnapshotsExamples :: [StakeSnapshots]
315+
queryStakeSnapshotsExamples =
316+
[ StakeSnapshots
317+
Map.empty
318+
(knownNonZeroCoin @1)
319+
(knownNonZeroCoin @1)
320+
(knownNonZeroCoin @1)
321+
, StakeSnapshots
322+
{ ssStakeSnapshots =
323+
Map.fromList
324+
[
325+
( mkKeyHash 1
326+
, StakeSnapshot
327+
{ ssMarkPool = Coin 1_000_000_000
328+
, ssSetPool = Coin 900_000_000
329+
, ssGoPool = Coin 800_000_000
330+
}
331+
)
332+
,
333+
( mkKeyHash 2
334+
, StakeSnapshot
335+
{ ssMarkPool = Coin 0
336+
, ssSetPool = Coin 500_000_000
337+
, ssGoPool = Coin 250_000_000
338+
}
339+
)
340+
]
341+
, ssMarkTotal = knownNonZeroCoin @5_000_000_000
342+
, ssSetTotal = knownNonZeroCoin @4_500_000_000
343+
, ssGoTotal = knownNonZeroCoin @4_000_000_000
344+
}
345+
]

0 commit comments

Comments
 (0)