Skip to content

Commit

Permalink
Refactor getCurrentEpochNo so that it doesn't depend on era
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Apr 25, 2024
1 parent 11607fd commit e684792
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cardano-testnet/src/Testnet/Components/DReps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ delegateToDRep execConfig epochStateView configurationFile socketPath sbe work p
submitTx execConfig cEra repRegSignedRegTx1

-- Wait two epochs
(EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView sbe
(EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView
void $ waitUntilEpoch (File configurationFile) (File socketPath) (EpochNo (epochAfterProp + 2))

-- | This function obtains the identifier for the last enacted parameter update proposal
Expand Down
11 changes: 3 additions & 8 deletions cardano-testnet/src/Testnet/Components/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,7 @@ getMinDRepDeposit execConfig ceo = withFrozenCallStack $ do
-- | Obtain current epoch number using 'getEpochState'
getCurrentEpochNo :: (MonadTest m, MonadAssertion m, MonadIO m)
=> EpochStateView
-> ShelleyBasedEra ConwayEra
-> m EpochNo
getCurrentEpochNo epochStateView sbe = do
AnyNewEpochState actualEra newEpochState <- getEpochState epochStateView
case testEquality sbe actualEra of
Just Refl -> return $ shelleyBasedEraConstraints sbe newEpochState
^. L.nesELL
Nothing ->
error $ "Eras mismatch! expected: " <> show sbe <> ", actual: " <> show actualEra
getCurrentEpochNo epochStateView = do
AnyNewEpochState _ newEpochState <- getEpochState epochStateView
return $ newEpochState ^. L.nesELL
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas
(fromIntegral $ 4 + proposalNum) Nothing 3
| (proposalNum, wallet) <- zip [1..(4 :: Int)] (cycle [wallet0, wallet1, wallet2])]

(EpochNo epochAfterTimeout) <- getCurrentEpochNo epochStateView sbe
(EpochNo epochAfterTimeout) <- getCurrentEpochNo epochStateView
H.note_ $ "Epoch after which we are going to test timeout: " <> show epochAfterTimeout

-- Last proposal (set activity to something else again and it should pass, because of inactivity)
Expand Down Expand Up @@ -160,7 +160,7 @@ activityChangeProposalTest execConfig epochStateView configurationFile socketPat
propVotes = zip (concatMap (uncurry replicate) votes) [1..]
annotateShow propVotes

(EpochNo epochBeforeProp) <- getCurrentEpochNo epochStateView sbe
(EpochNo epochBeforeProp) <- getCurrentEpochNo epochStateView
H.note_ $ "Epoch before \"" <> prefix <> "\" prop: " <> show epochBeforeProp

thisProposal@(governanceActionTxId, governanceActionIndex) <-
Expand All @@ -170,7 +170,7 @@ activityChangeProposalTest execConfig epochStateView configurationFile socketPat
voteChangeProposal execConfig epochStateView sbe baseDir "vote"
governanceActionTxId governanceActionIndex propVotes wallet

(EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView sbe
(EpochNo epochAfterProp) <- getCurrentEpochNo epochStateView
H.note_ $ "Epoch after \"" <> prefix <> "\" prop: " <> show epochAfterProp

void $ waitUntilEpoch (File configurationFile) (File socketPath) (EpochNo (epochAfterProp + epochsToWait))
Expand Down

0 comments on commit e684792

Please sign in to comment.