Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Write a property to check that SIP's are approved. [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadales committed Jul 10, 2020
1 parent 831400b commit 9a4abf1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions executable-spec/test/Test/Cardano/Ledger/Update/Properties.hs
Expand Up @@ -51,7 +51,11 @@ import Test.Cardano.Ledger.Update.TestCase ()


runTests :: [TestTree]
runTests = [ testProperty "Update" $ traceProp prop_approvedSIPsHaveEnoughVotes ]
runTests = [ testProperty "SIP's are approved"
$ traceProp prop_sipsAreNotApproved -- TODO: expect failure
-- , testProperty "Approved SIP's meet the adoption threshold"
-- $ traceProp prop_approvedSIPsHaveEnoughVotes
]

--------------------------------------------------------------------------------
-- Definition of the system under test interface
Expand Down Expand Up @@ -82,6 +86,9 @@ instance SUT UpdateSUT where
UpdateAct payload -> applyUpdate payload st
-- TODO: here we need a case for applying a stake change.

instance Update.HasIdeationState (SUTSt UpdateSUT) MockSIP where
getIdeationState (UpdateSt st) = Update.getIdeationState st

instance Update.HasActivationState (SUTSt UpdateSUT) MockSIP MockImpl where
getActivationState (UpdateSt st) = Update.getActivationState st

Expand Down Expand Up @@ -342,7 +349,7 @@ instance Arbitrary (TestSetup UpdateTestGen) where
allUnique $ fmap (_id . getProtocol . spec) scenarios
++ [mpProtocolId gp]

shrink = undefined
shrink testSetup = []

-- | Generate an initial stake distribution.
genInitialStake :: Gen (Map Participant Stake)
Expand Down Expand Up @@ -412,3 +419,11 @@ genProposalScenarios genesisProtocol participants = do
-- @stableAfter@ slots after the voting period ends.
prop_approvedSIPsHaveEnoughVotes :: Trace UpdateSUT UpdateTestGen -> Bool
prop_approvedSIPsHaveEnoughVotes trace = undefined

prop_sipsAreNotApproved :: Trace UpdateSUT UpdateTestGen -> Bool
prop_sipsAreNotApproved trace = not $ any hasAnApprovedSIP (validStates trace)
where
sipIds = fmap (getSIPId . spec) $ tsUpdateProposals $ testSetup trace
hasAnApprovedSIP st = any isSIPApproved sipIds
where
isSIPApproved sipId = Update.isSIP sipId Approved st

0 comments on commit 9a4abf1

Please sign in to comment.