Skip to content

Commit 5db560e

Browse files
committed
WIP - GovSpec
1 parent 06dd7a1 commit 5db560e

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import qualified Test.Cardano.Ledger.Conway.Imp.DelegSpec as Deleg
4747
import qualified Test.Cardano.Ledger.Conway.Imp.EnactSpec as Enact
4848
import qualified Test.Cardano.Ledger.Conway.Imp.EpochSpec as Epoch
4949
-- import qualified Test.Cardano.Ledger.Conway.Imp.GovCertSpec as GovCert
50-
-- import qualified Test.Cardano.Ledger.Conway.Imp.GovSpec as Gov
50+
import qualified Test.Cardano.Ledger.Conway.Imp.GovSpec as Gov
5151
-- import qualified Test.Cardano.Ledger.Conway.Imp.LedgerSpec as Ledger
5252
-- import qualified Test.Cardano.Ledger.Conway.Imp.RatifySpec as Ratify
5353
-- import qualified Test.Cardano.Ledger.Conway.Imp.UtxoSpec as Utxo
@@ -134,8 +134,8 @@ conwaySpec = do
134134
describe "DELEG" Deleg.spec
135135
describe "ENACT" Enact.spec
136136
describe "EPOCH" Epoch.spec
137+
describe "GOV" Gov.spec
137138

138-
-- describe "GOV" Gov.spec
139139
-- describe "GOVCERT" GovCert.spec
140140
-- describe "LEDGER" Ledger.spec
141141
-- describe "RATIFY" Ratify.spec

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

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import Test.Cardano.Ledger.Imp.Common hiding (Success)
4444
spec ::
4545
forall era.
4646
( ConwayEraImp era
47-
, ShelleyEraTxCert era
4847
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
4948
) =>
5049
SpecWith (ImpInit (LedgerSpec era))
@@ -63,9 +62,7 @@ spec = do
6362

6463
unknownCostModelsSpec ::
6564
forall era.
66-
( ConwayEraImp era
67-
, ShelleyEraTxCert era
68-
) =>
65+
ConwayEraImp era =>
6966
SpecWith (ImpInit (LedgerSpec era))
7067
unknownCostModelsSpec =
7168
describe "Unknown CostModels" $ do
@@ -87,7 +84,6 @@ unknownCostModelsSpec =
8784
predicateFailuresSpec ::
8885
forall era.
8986
( ConwayEraImp era
90-
, ShelleyEraTxCert era
9187
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
9288
) =>
9389
SpecWith (ImpInit (LedgerSpec era))
@@ -123,7 +119,7 @@ predicateFailuresSpec =
123119
}
124120

125121
it "ProposalDepositIncorrect" $ do
126-
rewardAccount <- registerRewardAccount
122+
rewardAccount <- registerRewardAccountWithDeposit
127123
actionDeposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppGovActionDepositL
128124
anchor <- arbitrary
129125
submitFailingProposal
@@ -164,7 +160,6 @@ predicateFailuresSpec =
164160
hardForkSpec ::
165161
forall era.
166162
( ConwayEraImp era
167-
, ShelleyEraTxCert era
168163
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
169164
) =>
170165
SpecWith (ImpInit (LedgerSpec era))
@@ -182,7 +177,6 @@ hardForkSpec =
182177
pparamUpdateSpec ::
183178
forall era.
184179
( ConwayEraImp era
185-
, ShelleyEraTxCert era
186180
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
187181
) =>
188182
SpecWith (ImpInit (LedgerSpec era))
@@ -248,7 +242,6 @@ pparamUpdateSpec =
248242
proposalsSpec ::
249243
forall era.
250244
( ConwayEraImp era
251-
, ShelleyEraTxCert era
252245
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
253246
) =>
254247
SpecWith (ImpInit (LedgerSpec era))
@@ -716,7 +709,7 @@ proposalsSpec = do
716709
it "Proposals are stored in the expected order" $ whenPostBootstrap $ do
717710
modifyPParams $ ppMaxValSizeL .~ 1_000_000_000
718711
ens <- getEnactState
719-
returnAddr <- registerRewardAccount
712+
returnAddr <- registerRewardAccountWithDeposit
720713
withdrawal <-
721714
(: []) . (returnAddr,) . Coin . getPositive
722715
<$> (arbitrary :: ImpTestM era (Positive Integer))
@@ -753,7 +746,6 @@ proposalsSpec = do
753746
votingSpec ::
754747
forall era.
755748
( ConwayEraImp era
756-
, ShelleyEraTxCert era
757749
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
758750
) =>
759751
SpecWith (ImpInit (LedgerSpec era))
@@ -894,7 +886,7 @@ votingSpec =
894886
conAnchor `shouldNotBe` anchor
895887
it "can submit SPO votes" $ do
896888
spoHash <- freshKeyHash
897-
registerPool spoHash
889+
registerPoolWithDeposit spoHash
898890
passNEpochs 3
899891
gaId <-
900892
submitParameterChange SNothing $
@@ -905,7 +897,6 @@ votingSpec =
905897
constitutionSpec ::
906898
forall era.
907899
( ConwayEraImp era
908-
, ShelleyEraTxCert era
909900
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
910901
) =>
911902
SpecWith (ImpInit (LedgerSpec era))
@@ -989,7 +980,6 @@ constitutionSpec =
989980
policySpec ::
990981
forall era.
991982
( ConwayEraImp era
992-
, ShelleyEraTxCert era
993983
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
994984
) =>
995985
SpecWith (ImpInit (LedgerSpec era))
@@ -1016,7 +1006,7 @@ policySpec =
10161006
mkProposal (ParameterChange SNothing pparamsUpdate (SJust scriptHash)) >>= submitProposal_
10171007

10181008
impAnn "TreasuryWithdrawals with correct policy succeeds" $ do
1019-
rewardAccount <- registerRewardAccount
1009+
rewardAccount <- registerRewardAccountWithDeposit
10201010
let withdrawals = Map.fromList [(rewardAccount, Coin 1000)]
10211011
mkProposal (TreasuryWithdrawals withdrawals (SJust scriptHash)) >>= submitProposal_
10221012

@@ -1028,7 +1018,7 @@ policySpec =
10281018
[injectFailure $ InvalidPolicyHash (SJust wrongScriptHash) (SJust scriptHash)]
10291019

10301020
impAnn "TreasuryWithdrawals with invalid policy fails" $ do
1031-
rewardAccount <- registerRewardAccount
1021+
rewardAccount <- registerRewardAccountWithDeposit
10321022
let withdrawals = Map.fromList [(rewardAccount, Coin 1000)]
10331023
mkProposal (TreasuryWithdrawals withdrawals (SJust wrongScriptHash))
10341024
>>= flip
@@ -1038,7 +1028,6 @@ policySpec =
10381028
networkIdSpec ::
10391029
forall era.
10401030
( ConwayEraImp era
1041-
, ShelleyEraTxCert era
10421031
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
10431032
) =>
10441033
SpecWith (ImpInit (LedgerSpec era))
@@ -1075,7 +1064,6 @@ networkIdSpec =
10751064
withdrawalsSpec ::
10761065
forall era.
10771066
( ConwayEraImp era
1078-
, ShelleyEraTxCert era
10791067
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
10801068
) =>
10811069
SpecWith (ImpInit (LedgerSpec era))
@@ -1084,7 +1072,7 @@ withdrawalsSpec =
10841072
it "Fails predicate when treasury withdrawal has nonexistent return address" $ do
10851073
policy <- getGovPolicy
10861074
unregisteredRewardAccount <- freshKeyHash >>= getRewardAccountFor . KeyHashObj
1087-
registeredRewardAccount <- registerRewardAccount
1075+
registeredRewardAccount <- registerRewardAccountWithDeposit
10881076
let genPositiveCoin = Coin . getPositive <$> arbitrary
10891077
withdrawals <-
10901078
sequence
@@ -1129,10 +1117,10 @@ withdrawalsSpec =
11291117
it "Fails for empty withdrawals" $ do
11301118
mkTreasuryWithdrawalsGovAction [] >>= expectZeroTreasuryFailurePostBootstrap
11311119

1132-
rwdAccount1 <- registerRewardAccount
1120+
rwdAccount1 <- registerRewardAccountWithDeposit
11331121
mkTreasuryWithdrawalsGovAction [(rwdAccount1, zero)] >>= expectZeroTreasuryFailurePostBootstrap
11341122

1135-
rwdAccount2 <- registerRewardAccount
1123+
rwdAccount2 <- registerRewardAccountWithDeposit
11361124
let withdrawals = [(rwdAccount1, zero), (rwdAccount2, zero)]
11371125

11381126
mkTreasuryWithdrawalsGovAction withdrawals >>= expectZeroTreasuryFailurePostBootstrap
@@ -1161,10 +1149,7 @@ withdrawalsSpec =
11611149
-- | Tests the first hardfork in the Conway era where the PrevGovActionID is SNothing
11621150
firstHardForkFollows ::
11631151
forall era.
1164-
( ShelleyEraImp era
1165-
, ShelleyEraTxCert era
1166-
, ConwayEraTxBody era
1167-
) =>
1152+
ConwayEraImp era =>
11681153
(ProtVer -> ProtVer) ->
11691154
ImpTestM era ()
11701155
firstHardForkFollows computeNewFromOld = do
@@ -1174,9 +1159,7 @@ firstHardForkFollows computeNewFromOld = do
11741159
-- | Negative (deliberatey failing) first hardfork in the Conway era where the PrevGovActionID is SNothing
11751160
firstHardForkCantFollow ::
11761161
forall era.
1177-
( ShelleyEraImp era
1178-
, ShelleyEraTxCert era
1179-
, ConwayEraTxBody era
1162+
( ConwayEraImp era
11801163
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
11811164
) =>
11821165
ImpTestM era ()
@@ -1198,10 +1181,7 @@ firstHardForkCantFollow = do
11981181
-- | Tests a second hardfork in the Conway era where the PrevGovActionID is SJust
11991182
secondHardForkFollows ::
12001183
forall era.
1201-
( ShelleyEraImp era
1202-
, ShelleyEraTxCert era
1203-
, ConwayEraTxBody era
1204-
) =>
1184+
ConwayEraImp era =>
12051185
(ProtVer -> ProtVer) ->
12061186
ImpTestM era ()
12071187
secondHardForkFollows computeNewFromOld = do
@@ -1214,9 +1194,7 @@ secondHardForkFollows computeNewFromOld = do
12141194
-- | Negative (deliberatey failing) first hardfork in the Conway era where the PrevGovActionID is SJust
12151195
secondHardForkCantFollow ::
12161196
forall era.
1217-
( ShelleyEraImp era
1218-
, ShelleyEraTxCert era
1219-
, ConwayEraTxBody era
1197+
( ConwayEraImp era
12201198
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
12211199
) =>
12221200
ImpTestM era ()
@@ -1239,7 +1217,6 @@ secondHardForkCantFollow = do
12391217
ccVoteOnConstitutionFailsWithMultipleVotes ::
12401218
forall era.
12411219
( ConwayEraImp era
1242-
, ShelleyEraTxCert era
12431220
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
12441221
) =>
12451222
ImpTestM era ()
@@ -1281,7 +1258,6 @@ ccVoteOnConstitutionFailsWithMultipleVotes = do
12811258
bootstrapPhaseSpec ::
12821259
forall era.
12831260
( ConwayEraImp era
1284-
, ShelleyEraTxCert era
12851261
, InjectRuleFailure "LEDGER" ConwayGovPredFailure era
12861262
) =>
12871263
SpecWith (ImpInit (LedgerSpec era))
@@ -1316,7 +1292,7 @@ bootstrapPhaseSpec =
13161292
submitYesVote_ (StakePoolVoter spo) gid
13171293
submitYesVote_ (CommitteeVoter committee) gid
13181294
it "Treasury withdrawal" $ do
1319-
rewardAccount <- registerRewardAccount
1295+
rewardAccount <- registerRewardAccountWithDeposit
13201296
action <- mkTreasuryWithdrawalsGovAction [(rewardAccount, Coin 1000)]
13211297
proposal <- mkProposalWithRewardAccount action rewardAccount
13221298
checkProposalFailure proposal

0 commit comments

Comments
 (0)