Skip to content

Commit

Permalink
Merge pull request #4720 from IntersectMBO/aniketd/imptest-cc-removal
Browse files Browse the repository at this point in the history
Add CC removal imptest with UpdateCommittee
  • Loading branch information
aniketd authored Oct 30, 2024
2 parents 9ec1e6b + e3c46b2 commit a02dc6e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import qualified Data.List.NonEmpty as NE
import qualified Data.Map.Strict as Map
import Data.Ratio ((%))
import qualified Data.Sequence as Seq
import qualified Data.Sequence.Strict as SSeq
import qualified Data.Set as Set
import Data.Typeable (cast)
import Data.Word (Word64)
import Lens.Micro
import Test.Cardano.Ledger.Conway.ImpTest
import Test.Cardano.Ledger.Core.Arbitrary (uniformSubSet)
import Test.Cardano.Ledger.Core.Rational
import Test.Cardano.Ledger.Imp.Common
import Type.Reflection (Typeable)
Expand Down Expand Up @@ -624,3 +626,51 @@ committeeSpec =
-- Confirm that after registering a hot key, they are active
_hotKey <- registerCommitteeHotKey cc
ccShouldNotBeResigned cc
describe "Removing CC with UpdateCommittee" $ do
it "Non registered" $ do
(drepCred, _, _) <- setupSingleDRep 1_000_000
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
passNEpochs 2
initialCommittee <- getCommitteeMembers
logToExpr initialCommittee
initialCommittee `shouldSatisfy` not . Set.null
proposal <-
mkUpdateCommitteeProposal Nothing initialCommittee mempty (1 %! 2)
mbRemoveCCGaid <-
submitBootstrapAwareFailingProposal proposal $
FailBootstrap [injectFailure $ DisallowedProposalDuringBootstrap proposal]
forM_ mbRemoveCCGaid $ \removeCCGaid -> do
submitYesVote_ (DRepVoter drepCred) removeCCGaid
submitYesVote_ (StakePoolVoter spoC) removeCCGaid
passNEpochs 2
finalCommittee <- getCommitteeMembers
logToExpr finalCommittee
finalCommittee `shouldSatisfy` Set.null
it "Registered" $ do
(drepCred, _, _) <- setupSingleDRep 1_000_000
(spoC, _, _) <- setupPoolWithStake $ Coin 42_000_000
passNEpochs 2
initialCommittee <- getCommitteeMembers
logToExpr initialCommittee
initialCommittee `shouldSatisfy` not . Set.null
forM_ (Set.toList initialCommittee) $ \kh -> do
ccHotCred <- KeyHashObj <$> freshKeyHash
submitTx_ $
mkBasicTx mkBasicTxBody
& bodyTxL . certsTxBodyL
.~ SSeq.singleton (AuthCommitteeHotKeyTxCert kh ccHotCred)
newCommittee <- arbitrary
initialSubCommittee <- askStatefulGen >>= uniformSubSet Nothing initialCommittee
proposal <-
mkUpdateCommitteeProposal Nothing initialSubCommittee newCommittee (1 %! 2)
mbRemoveCCGaid <-
submitBootstrapAwareFailingProposal proposal $
FailBootstrap [injectFailure $ DisallowedProposalDuringBootstrap proposal]
forM_ mbRemoveCCGaid $ \removeCCGaid -> do
submitYesVote_ (DRepVoter drepCred) removeCCGaid
submitYesVote_ (StakePoolVoter spoC) removeCCGaid
passNEpochs 2
finalCommittee <- getCommitteeMembers
logToExpr finalCommittee
finalCommittee
`shouldBe` Set.union (initialCommittee Set.\\ initialSubCommittee) (Set.fromList $ fst <$> newCommittee)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -75,6 +74,7 @@ spec = do
mkBasicTx mkBasicTxBody
& bodyTxL . certsTxBodyL
.~ SSeq.singleton (AuthCommitteeHotKeyTxCert kh ccHotCred)

describe "fails for" $ do
it "invalid deposit provided with DRep registration cert" $ do
modifyPParams $ ppDRepDepositL .~ Coin 100
Expand Down

0 comments on commit a02dc6e

Please sign in to comment.