|
21 | 21 | module Test.Cardano.Ledger.Conway.ImpTest ( |
22 | 22 | module Test.Cardano.Ledger.Babbage.ImpTest, |
23 | 23 | ConwayEraImp, |
| 24 | + conwayModifyImpInitProtVer, |
24 | 25 | enactConstitution, |
25 | 26 | enactTreasuryWithdrawals, |
26 | 27 | submitGovAction, |
@@ -140,9 +141,11 @@ import Cardano.Ledger.Allegra.Scripts (Timelock) |
140 | 141 | import Cardano.Ledger.BaseTypes ( |
141 | 142 | EpochInterval (..), |
142 | 143 | EpochNo (..), |
| 144 | + ProtVer (..), |
143 | 145 | ShelleyBase, |
144 | 146 | StrictMaybe (..), |
145 | 147 | UnitInterval, |
| 148 | + Version, |
146 | 149 | addEpochInterval, |
147 | 150 | binOpEpochNo, |
148 | 151 | inject, |
@@ -222,6 +225,7 @@ import Test.Cardano.Ledger.Core.Rational (IsRatio (..)) |
222 | 225 | import Test.Cardano.Ledger.Imp.Common |
223 | 226 | import Test.Cardano.Ledger.Plutus (testingCostModel) |
224 | 227 | import Test.Cardano.Ledger.Plutus.Guardrail (guardrailScript) |
| 228 | +import Test.ImpSpec |
225 | 229 |
|
226 | 230 | -- | Modify the PParams in the current state with the given function |
227 | 231 | conwayModifyPParams :: |
@@ -297,6 +301,24 @@ instance ShelleyEraImp ConwayEra where |
297 | 301 |
|
298 | 302 | fixupTx = babbageFixupTx |
299 | 303 | expectTxSuccess = impBabbageExpectTxSuccess |
| 304 | + modifyImpInitProtVer = conwayModifyImpInitProtVer |
| 305 | + |
| 306 | +conwayModifyImpInitProtVer :: |
| 307 | + forall era. |
| 308 | + ConwayEraImp era => |
| 309 | + Version -> |
| 310 | + SpecWith (ImpInit (LedgerSpec era)) -> |
| 311 | + SpecWith (ImpInit (LedgerSpec era)) |
| 312 | +conwayModifyImpInitProtVer ver = |
| 313 | + modifyImpInit $ \impInit -> |
| 314 | + impInit |
| 315 | + { impInitState = |
| 316 | + impInitState impInit |
| 317 | + & impNESL . nesEsL . curPParamsEpochStateL . ppProtocolVersionL .~ ProtVer ver 0 |
| 318 | + & impNESL . nesEsL %~ (\es -> setCompleteDRepPulsingState def (ratifyState es) es) |
| 319 | + } |
| 320 | + where |
| 321 | + ratifyState es = def & rsEnactStateL .~ mkEnactState (es ^. epochStateGovStateL) |
300 | 322 |
|
301 | 323 | instance MaryEraImp ConwayEra |
302 | 324 |
|
@@ -439,7 +461,7 @@ setupSingleDRep :: |
439 | 461 | ConwayEraImp era => |
440 | 462 | Integer -> |
441 | 463 | ImpTestM era (Credential 'DRepRole, Credential 'Staking, KeyPair 'Payment) |
442 | | -setupSingleDRep stake = do |
| 464 | +setupSingleDRep stake = impAnn "Set up a single DRep" $ do |
443 | 465 | drepKH <- registerDRep |
444 | 466 | delegatorKH <- freshKeyHash |
445 | 467 | deposit <- getsNES $ nesEsL . curPParamsEpochStateL . ppKeyDepositL |
@@ -488,7 +510,7 @@ setupPoolWithStake :: |
488 | 510 | (ShelleyEraImp era, ConwayEraTxCert era) => |
489 | 511 | Coin -> |
490 | 512 | ImpTestM era (KeyHash 'StakePool, Credential 'Payment, Credential 'Staking) |
491 | | -setupPoolWithStake delegCoin = do |
| 513 | +setupPoolWithStake delegCoin = impAnn "Set up pool with stake" $ do |
492 | 514 | khPool <- freshKeyHash |
493 | 515 | registerPool khPool |
494 | 516 | credDelegatorPayment <- KeyHashObj <$> freshKeyHash |
@@ -584,22 +606,23 @@ trySubmitVote :: |
584 | 606 | GovActionId -> |
585 | 607 | ImpTestM era (Either (NonEmpty (PredicateFailure (EraRule "LEDGER" era))) TxId) |
586 | 608 | trySubmitVote vote voter gaId = |
587 | | - fmap (bimap fst txIdTx) $ |
588 | | - trySubmitTx $ |
589 | | - mkBasicTx mkBasicTxBody |
590 | | - & bodyTxL . votingProceduresTxBodyL |
591 | | - .~ VotingProcedures |
592 | | - ( Map.singleton |
593 | | - voter |
594 | | - ( Map.singleton |
595 | | - gaId |
596 | | - ( VotingProcedure |
597 | | - { vProcVote = vote |
598 | | - , vProcAnchor = SNothing |
599 | | - } |
600 | | - ) |
601 | | - ) |
602 | | - ) |
| 609 | + impAnn ("Submitting vote (" <> show vote <> ")") $ |
| 610 | + fmap (bimap fst txIdTx) $ |
| 611 | + trySubmitTx $ |
| 612 | + mkBasicTx mkBasicTxBody |
| 613 | + & bodyTxL . votingProceduresTxBodyL |
| 614 | + .~ VotingProcedures |
| 615 | + ( Map.singleton |
| 616 | + voter |
| 617 | + ( Map.singleton |
| 618 | + gaId |
| 619 | + ( VotingProcedure |
| 620 | + { vProcVote = vote |
| 621 | + , vProcAnchor = SNothing |
| 622 | + } |
| 623 | + ) |
| 624 | + ) |
| 625 | + ) |
603 | 626 |
|
604 | 627 | submitProposal_ :: |
605 | 628 | (ShelleyEraImp era, ConwayEraTxBody era, HasCallStack) => |
@@ -1215,7 +1238,7 @@ registerCommitteeHotKey :: |
1215 | 1238 | (ShelleyEraImp era, ConwayEraTxCert era) => |
1216 | 1239 | Credential 'ColdCommitteeRole -> |
1217 | 1240 | ImpTestM era (Credential 'HotCommitteeRole) |
1218 | | -registerCommitteeHotKey coldKey = do |
| 1241 | +registerCommitteeHotKey coldKey = impAnn "Register committee hot key" $ do |
1219 | 1242 | hotKey NE.:| [] <- registerCommitteeHotKeys (KeyHashObj <$> freshKeyHash) $ pure coldKey |
1220 | 1243 | pure hotKey |
1221 | 1244 |
|
@@ -1291,33 +1314,36 @@ electBasicCommittee :: |
1291 | 1314 | , GovPurposeId 'CommitteePurpose |
1292 | 1315 | ) |
1293 | 1316 | electBasicCommittee = do |
1294 | | - logString "Setting up a DRep" |
1295 | 1317 | (drep, _, _) <- setupSingleDRep 1_000_000 |
| 1318 | + logString $ "Registered DRep: " <> showExpr drep |
| 1319 | + |
1296 | 1320 | (spoC, _, _) <- setupPoolWithStake $ Coin 1_000_000 |
| 1321 | + logString $ "Registered SPO: " <> showExpr spoC |
1297 | 1322 |
|
1298 | | - logString "Registering committee member" |
1299 | | - coldCommitteeC <- KeyHashObj <$> freshKeyHash |
1300 | | - startEpochNo <- getsNES nesELL |
1301 | | - let |
1302 | | - committeeAction = |
1303 | | - UpdateCommittee |
1304 | | - SNothing |
1305 | | - mempty |
1306 | | - (Map.singleton coldCommitteeC (addEpochInterval startEpochNo (EpochInterval 10))) |
1307 | | - (1 %! 2) |
1308 | | - (gaidCommitteeProp NE.:| _) <- |
1309 | | - submitGovActions |
1310 | | - [ committeeAction |
1311 | | - , UpdateCommittee SNothing mempty mempty (1 %! 10) |
1312 | | - ] |
1313 | | - submitYesVote_ (DRepVoter drep) gaidCommitteeProp |
1314 | | - submitYesVote_ (StakePoolVoter spoC) gaidCommitteeProp |
1315 | | - passNEpochs 2 |
1316 | | - committeeMembers <- getCommitteeMembers |
1317 | | - impAnn "The committee should be enacted" $ |
1318 | | - committeeMembers `shouldSatisfy` Set.member coldCommitteeC |
1319 | | - hotCommitteeC <- registerCommitteeHotKey coldCommitteeC |
1320 | | - pure (drep, hotCommitteeC, GovPurposeId gaidCommitteeProp) |
| 1323 | + impAnn "Registering committee member" $ do |
| 1324 | + coldCommitteeC <- KeyHashObj <$> freshKeyHash |
| 1325 | + startEpochNo <- getsNES nesELL |
| 1326 | + let |
| 1327 | + committeeAction = |
| 1328 | + UpdateCommittee |
| 1329 | + SNothing |
| 1330 | + mempty |
| 1331 | + (Map.singleton coldCommitteeC (addEpochInterval startEpochNo (EpochInterval 10))) |
| 1332 | + (1 %! 2) |
| 1333 | + (gaidCommitteeProp NE.:| _) <- |
| 1334 | + impAnn "Submitting UpdateCommittee action" $ |
| 1335 | + submitGovActions |
| 1336 | + [ committeeAction |
| 1337 | + , UpdateCommittee SNothing mempty mempty (1 %! 10) |
| 1338 | + ] |
| 1339 | + submitYesVote_ (DRepVoter drep) gaidCommitteeProp |
| 1340 | + submitYesVote_ (StakePoolVoter spoC) gaidCommitteeProp |
| 1341 | + passNEpochs 2 |
| 1342 | + committeeMembers <- getCommitteeMembers |
| 1343 | + impAnn "The committee should be enacted" $ |
| 1344 | + committeeMembers `shouldSatisfy` Set.member coldCommitteeC |
| 1345 | + hotCommitteeC <- registerCommitteeHotKey coldCommitteeC |
| 1346 | + pure (drep, hotCommitteeC, GovPurposeId gaidCommitteeProp) |
1321 | 1347 |
|
1322 | 1348 | logCurPParams :: |
1323 | 1349 | ( EraGov era |
|
0 commit comments