Skip to content

Commit

Permalink
Added a conformance ImpTest to try to catch the ccminsize bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Soupstraw committed Aug 30, 2024
1 parent 27d8346 commit b7aa411
Showing 1 changed file with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

module Test.Cardano.Ledger.Conformance.Imp.Ratify (spec) where

import Cardano.Ledger.BaseTypes (StrictMaybe (..), natVersion)
import qualified Data.List.NonEmpty as NE
import Cardano.Ledger.BaseTypes (StrictMaybe (..), natVersion, addEpochInterval, EpochInterval (..))
import Cardano.Ledger.Conway (Conway)
import Cardano.Ledger.Conway.Governance (
GovAction (..),
Expand All @@ -16,13 +17,14 @@ import Cardano.Ledger.Conway.PParams (
dvtMotionNoConfidenceL,
ppDRepVotingThresholdsL,
ppPoolVotingThresholdsL,
pvtMotionNoConfidenceL,
pvtMotionNoConfidenceL, ppCommitteeMaxTermLengthL,
)
import Cardano.Ledger.Shelley.LedgerState (
asTreasuryL,
epochStateGovStateL,
esAccountStateL,
nesEsL,
nesELL,
)
import qualified Data.Sequence.Strict as SSeq
import Lens.Micro ((&), (.~))
Expand All @@ -34,9 +36,11 @@ import Test.Cardano.Ledger.Constrained.Conway (ConwayFn)
import Test.Cardano.Ledger.Conway.ImpTest
import Test.Cardano.Ledger.Core.Rational (IsRatio (..))
import Test.Cardano.Ledger.Imp.Common
import Cardano.Ledger.Credential (Credential(..))
import qualified Data.Map as Map

spec :: Spec
spec = describe "RATIFY" . withImpStateWithProtVer (natVersion @10) $
spec = describe "RATIFY" . withImpStateWithProtVer @Conway (natVersion @10) $ do
it "NoConfidence accepted conforms" $ do
modifyPParams $ \pp ->
pp
Expand Down Expand Up @@ -64,3 +68,51 @@ spec = describe "RATIFY" . withImpStateWithProtVer (natVersion @10) $
ratEnv
ratSt
(RatifySignal (noConfidenceGAS SSeq.:<| SSeq.Empty))
it "Duplicate CC hot keys count as separate votes" $ do
let maxTermLength = EpochInterval 10
modifyPParams $ \pp ->
pp
& ppCommitteeMaxTermLengthL .~ maxTermLength
(credDRep, _, _) <- setupSingleDRep 100
ccCold0 <- KeyHashObj <$> freshKeyHash
ccCold1 <- KeyHashObj <$> freshKeyHash
hotKey <- KeyHashObj <$> freshKeyHash
curEpoch <- getsNES nesELL
let
ccExpiry = curEpoch `addEpochInterval` maxTermLength
committee = Map.fromList
[ (ccCold0, ccExpiry)
, (ccCold1, ccExpiry)
]

logEntry "Electing the committee"
committeeId <- submitGovAction $ UpdateCommittee SNothing mempty committee maxBound
submitYesVote_ (DRepVoter credDRep) committeeId
logAcceptedRatio committeeId
passNEpochs 2
getLastEnactedCommittee `shouldReturn` SJust (GovPurposeId committeeId)

logEntry "Registering hotkeys"
_ <- registerCommitteeHotKeys (pure hotKey) (ccCold0 NE.:| [ccCold1])

logEntry "Proposing a new constitution"
newConstitution <- arbitrary
constitutionId <- submitGovAction $ NewConstitution SNothing newConstitution
submitYesVote_ (CommitteeVoter hotKey) constitutionId
submitYesVote_ (DRepVoter credDRep) constitutionId
constitutionGAS <- getGovActionState constitutionId

logEntry "Testing conformance"
treasury <- getsNES $ nesEsL . esAccountStateL . asTreasuryL
let execCtx = ConwayRatifyExecContext treasury [constitutionGAS]
ratEnv <- getRatifyEnv
govSt <- getsNES $ nesEsL . epochStateGovStateL
let
ratSt = getRatifyState govSt
result =
testConformance @ConwayFn @"RATIFY" @Conway
execCtx
ratEnv
ratSt
(RatifySignal (constitutionGAS SSeq.:<| mempty))
pure result

0 comments on commit b7aa411

Please sign in to comment.