Skip to content

Commit

Permalink
Add property prop_poolRetirement.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanknowles committed Jul 6, 2020
1 parent 6d4bfda commit 48c5eda
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/core/test/unit/Cardano/Pool/DB/Properties.hs
Expand Up @@ -153,6 +153,8 @@ properties = do
(property . prop_putStakeReadStake)
it "putPoolRegistration then readPoolRegistration yields expected result"
(property . prop_poolRegistration)
it "putPoolRetirement then readPoolRetirement yields expected result"
(property . prop_poolRetirement)
it "rollback of PoolRegistration"
(property . prop_rollbackRegistration)
it "readStake . putStake a1 . putStake s0 == pure a1"
Expand Down Expand Up @@ -442,6 +444,29 @@ prop_poolRegistration DBLayer {..} entries =
]
assert (entriesIn == entriesOut)

-- | Heavily relies upon the fact that generated values of 'PoolId' are unique.
prop_poolRetirement
:: DBLayer IO
-> [(CertificatePublicationTime, PoolRetirementCertificate)]
-> Property
prop_poolRetirement DBLayer {..} entries =
monadicIO (setup >> prop)
where
setup = run $ atomically cleanDB
entriesIn = L.sort entries
prop = do
run $ atomically $
mapM_ (uncurry putPoolRetirement) entriesIn
entriesOut <- run . atomically $ L.sort . catMaybes
<$> mapM (readPoolRetirement . view #poolId . snd) entries
monitor $ counterexample $ unlines
[ "Written into DB: "
, show entriesIn
, "Read from DB: "
, show entriesOut
]
assert (entriesIn == entriesOut)

prop_rollbackRegistration
:: DBLayer IO
-> SlotId
Expand Down

0 comments on commit 48c5eda

Please sign in to comment.