@@ -14,6 +14,7 @@ import Cardano.Ledger.Conway.Governance
1414import Cardano.Ledger.Conway.PParams
1515import Cardano.Ledger.Conway.State
1616import Cardano.Ledger.Shelley.LedgerState
17+ import Cardano.Ledger.Shelley.Rules (ShelleyPoolPredFailure (.. ))
1718import qualified Data.Set as Set
1819import Lens.Micro
1920import Test.Cardano.Ledger.Conway.ImpTest
@@ -22,7 +23,10 @@ import Test.Cardano.Ledger.Imp.Common
2223
2324spec ::
2425 forall era .
25- ConwayEraImp era => SpecWith (ImpInit (LedgerSpec era ))
26+ ( ConwayEraImp era
27+ , InjectRuleFailure " LEDGER" ShelleyPoolPredFailure era
28+ ) =>
29+ SpecWith (ImpInit (LedgerSpec era ))
2630spec = do
2731 it " VRF Keyhashes get populated at v11 HardFork" $ do
2832 -- Since we're testing the HardFork to 11, the test only makes sense for protocol version 10
@@ -49,6 +53,29 @@ spec = do
4953 expectVRFs [] -- VRF keyhashes in PState is not yet populated
5054 enactHardForkV11
5155 expectVRFs [vrf2, vrf3, vrf5]
56+
57+ it " Retiring a stake pool with a duplicate VRF Keyhash after v11 HardFork" $ do
58+ whenMajorVersion @ 10 $ do
59+ -- register two pools with the same vrf keyhash before the hard fork
60+ (kh1, vrf) <- (,) <$> freshKeyHash <*> freshKeyHashVRF
61+ registerStakePool kh1 vrf
62+ kh2 <- freshKeyHash
63+ registerStakePool kh2 vrf
64+
65+ enactHardForkV11
66+ expectVRFs [vrf]
67+ -- retire one of the pools after the hard fork
68+ retireStakePool kh1 (EpochInterval 1 )
69+ passEpoch
70+ -- the vrf keyhash should still be present, since another pool is registered with it
71+ expectVRFs [vrf]
72+
73+ -- registration of the same vrf should be disallowed
74+ kh3 <- freshKeyHash
75+ registerStakePoolTx kh3 vrf >>= \ tx ->
76+ submitFailingTx
77+ tx
78+ [injectFailure $ VRFKeyHashAlreadyRegistered kh3 vrf]
5279 where
5380 enactHardForkV11 = do
5481 modifyPParams $ \ pp ->
@@ -61,11 +88,13 @@ spec = do
6188 submitYesVoteCCs_ committee govActionId
6289 passNEpochs 2
6390 getProtVer `shouldReturn` pv11
64- registerStakePool kh vrf = do
91+ registerStakePoolTx kh vrf = do
6592 pps <- registerRewardAccount >>= freshPoolParams kh
66- submitTx_ $
93+ pure $
6794 mkBasicTx mkBasicTxBody
6895 & bodyTxL . certsTxBodyL .~ [RegPoolTxCert $ pps & ppVrfL .~ vrf]
96+ registerStakePool kh vrf =
97+ registerStakePoolTx kh vrf >>= submitTx_
6998 retireStakePool kh retirementInterval = do
7099 curEpochNo <- getsNES nesELL
71100 let retirement = addEpochInterval curEpochNo retirementInterval
0 commit comments