Skip to content

Commit 9990534

Browse files
committed
Fixed ImpTest committee expiry
1 parent 2e67d13 commit 9990534

File tree

8 files changed

+37
-10
lines changed

8 files changed

+37
-10
lines changed

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/EnactSpec.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ noConfidenceSpec =
315315
& ppPoolVotingThresholdsL . pvtCommitteeNoConfidenceL .~ 1 %! 2
316316
& ppCommitteeMaxTermLengthL .~ EpochInterval 200
317317
let
318-
getCommittee =
319-
getsNES $
320-
nesEsL . esLStateL . lsUTxOStateL . utxosGovStateL . committeeGovStateL
321318
assertNoCommittee :: HasCallStack => ImpTestM era ()
322319
assertNoCommittee =
323320
do

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/RatifySpec.hs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE FlexibleContexts #-}
3+
{-# LANGUAGE NamedFieldPuns #-}
34
{-# LANGUAGE NumericUnderscores #-}
45
{-# LANGUAGE OverloadedLists #-}
56
{-# LANGUAGE RankNTypes #-}
@@ -529,15 +530,24 @@ spoVotesForHardForkInitiation =
529530
modifyPParams $ ppPoolVotingThresholdsL . pvtHardForkInitiationL .~ 1 %! 2
530531
protVer <- getProtVer
531532
gai <- submitGovAction $ HardForkInitiation SNothing (majorFollow protVer)
532-
submitYesVoteCCs_ hotCCs gai
533+
impAnn "Submit CC yes vote" $ submitYesVoteCCs_ hotCCs gai
534+
logString $ "Committee: " <> showExpr hotCCs
535+
GovActionState {gasCommitteeVotes} <- getGovActionState gai
536+
logString $ "CC Votes: " <> showExpr gasCommitteeVotes
537+
minSize <- getsPParams ppCommitteeMinSizeL
538+
committee <- getCommittee
539+
logString $ "Min committee size: " <> show minSize
540+
logString $ "Committee: " <> showExpr committee
541+
logString . show =<< getsNES nesELL
542+
impAnn "Accepted by committee" $ isCommitteeAccepted gai `shouldReturn` True
533543
-- 1 % 4 stake yes; 3 % 4 stake no; yes / stake - abstain < 1 % 2
534-
submitYesVote_ (StakePoolVoter spoK1) gai
544+
impAnn "Submit SPO1 yes vote" $ submitYesVote_ (StakePoolVoter spoK1) gai
535545
passNEpochs 2
536546
logRatificationChecks gai
537547
isSpoAccepted gai `shouldReturn` False
538548
getLastEnactedHardForkInitiation `shouldReturn` SNothing
539549
-- 1 % 2 stake yes; 1 % 2 stake no; yes / stake - abstain = 1 % 2
540-
submitYesVote_ (StakePoolVoter spoK2) gai
550+
impAnn "Submit SPO2 yes vote" $ submitYesVote_ (StakePoolVoter spoK2) gai
541551
isSpoAccepted gai `shouldReturn` True
542552
passNEpochs 2
543553
getLastEnactedHardForkInitiation `shouldReturn` SJust (GovPurposeId gai)

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/ImpTest.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ module Test.Cardano.Ledger.Conway.ImpTest (
132132
SubmitFailureExpectation (..),
133133
FailBoth (..),
134134
delegateSPORewardAddressToDRep_,
135+
getCommittee,
135136
) where
136137

137138
import Cardano.Ledger.Address (RewardAccount (..))
@@ -1798,3 +1799,6 @@ instance InjectRuleFailure "DELEG" ShelleyDelegPredFailure ConwayEra where
17981799
injectFailure (Shelley.StakeKeyNotRegisteredDELEG c) = StakeKeyNotRegisteredDELEG c
17991800
injectFailure (Shelley.StakeKeyNonZeroAccountBalanceDELEG c) = StakeKeyHasNonZeroRewardAccountBalanceDELEG c
18001801
injectFailure _ = error "Cannot inject ShelleyDelegPredFailure into ConwayEra"
1802+
1803+
getCommittee :: ConwayEraGov era => ImpTestM era (StrictMaybe (Committee era))
1804+
getCommittee = getsNES $ nesEsL . epochStateGovStateL . committeeGovStateL

eras/dijkstra/cardano-ledger-dijkstra.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ library testlib
123123
cardano-ledger-core:{cardano-ledger-core, testlib},
124124
cardano-ledger-dijkstra,
125125
cardano-ledger-shelley,
126+
microlens,
126127

127128
test-suite tests
128129
type: exitcode-stdio-1.0

eras/dijkstra/src/Cardano/Ledger/Dijkstra/Genesis.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Cardano.Ledger.Dijkstra.Genesis () where
55

66
import Cardano.Ledger.Dijkstra.Era (DijkstraEra)
7-
import Cardano.Ledger.Genesis (EraGenesis (..))
7+
import Cardano.Ledger.Genesis (EraGenesis (..), NoGenesis)
88

99
instance EraGenesis DijkstraEra where
10-
type Genesis DijkstraEra = ()
10+
type Genesis DijkstraEra = NoGenesis DijkstraEra

eras/dijkstra/src/Cardano/Ledger/Dijkstra/Translation.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import Cardano.Ledger.Dijkstra.Tx ()
5252
import Cardano.Ledger.Dijkstra.TxAuxData ()
5353
import Cardano.Ledger.Dijkstra.TxBody (upgradeGovAction, upgradeProposals)
5454
import Cardano.Ledger.Dijkstra.TxWits ()
55+
import Cardano.Ledger.Genesis (NoGenesis)
5556
import qualified Cardano.Ledger.Shelley.API as API
5657
import Cardano.Ledger.Shelley.LedgerState (
5758
DState (..),
@@ -69,7 +70,7 @@ import Data.Default (Default (..))
6970
import qualified Data.Map.Strict as Map
7071
import Lens.Micro ((&), (.~), (^.))
7172

72-
type instance TranslationContext DijkstraEra = ()
73+
type instance TranslationContext DijkstraEra = NoGenesis DijkstraEra
7374

7475
newtype Tx era = Tx (Core.Tx era)
7576

eras/dijkstra/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE MultiParamTypeClasses #-}
3+
{-# LANGUAGE TypeApplications #-}
34
{-# LANGUAGE TypeFamilies #-}
45
{-# OPTIONS_GHC -Wno-orphans #-}
56

67
module Test.Cardano.Ledger.Dijkstra.ImpTest () where
78

9+
import Cardano.Ledger.BaseTypes (EpochInterval (..), addEpochInterval)
10+
import Cardano.Ledger.Conway.Governance (ConwayEraGov (..), committeeMembersL)
811
import Cardano.Ledger.Conway.Rules (
912
ConwayCertPredFailure (..),
1013
ConwayCertsPredFailure (..),
@@ -13,14 +16,25 @@ import Cardano.Ledger.Conway.Rules (
1316
)
1417
import Cardano.Ledger.Dijkstra (DijkstraEra)
1518
import Cardano.Ledger.Dijkstra.Core
19+
import Cardano.Ledger.Genesis (NoGenesis (..))
1620
import Cardano.Ledger.Plutus (SLanguage (..))
21+
import Cardano.Ledger.Shelley.LedgerState (epochStateGovStateL, nesEsL)
1722
import Cardano.Ledger.Shelley.Rules (ShelleyDelegPredFailure)
1823
import qualified Cardano.Ledger.Shelley.Rules as Shelley
24+
import Lens.Micro ((%~), (&))
1925
import Test.Cardano.Ledger.Conway.ImpTest
2026
import Test.Cardano.Ledger.Dijkstra.Era ()
2127

2228
instance ShelleyEraImp DijkstraEra where
23-
initGenesis = pure ()
29+
initGenesis = pure NoGenesis
30+
31+
initNewEpochState = defaultInitNewEpochState $ \nes ->
32+
nes
33+
& nesEsL . epochStateGovStateL . committeeGovStateL %~ fmap updateCommitteeExpiry
34+
where
35+
updateCommitteeExpiry =
36+
committeeMembersL
37+
%~ fmap (const $ addEpochInterval (impEraStartEpochNo @DijkstraEra) (EpochInterval 15))
2438

2539
impSatisfyNativeScript = impAllegraSatisfyNativeScript
2640

test.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)