Skip to content

Commit

Permalink
Added comments to the new waitAndCheckNewEpochState function
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed May 3, 2024
1 parent 6f9b240 commit 23730fa
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cardano-testnet/src/Testnet/Components/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,22 @@ getCurrentEpochNo epochStateView = withFrozenCallStack $ do
AnyNewEpochState _ newEpochState <- getEpochState epochStateView
pure $ newEpochState ^. L.nesELL

waitAndCheckNewEpochState :: forall m era value. (MonadAssertion m, MonadTest m, MonadIO m, Eq value)
=> EpochStateView -> FilePath -> FilePath -> ConwayEraOnwards era -> Word64 -> Maybe value -> Word64
-> Lens' (L.NewEpochState (ShelleyLedgerEra era)) value -> m ()
-- | Waits for a minimum of @minWait@ epochs and a maximum of @maxWait@ epochs for
-- the value pointed by the @lens@ to become the same as the @mExpected@ (if it is not 'Nothing').
-- If the value is not reached within the time frame, the test fails. If @mExpected@ is 'Nothing',
-- the value is not checked, but the function will sitll wait for @minWait@ epochs.
waitAndCheckNewEpochState
:: forall m era value.
(MonadAssertion m, MonadTest m, MonadIO m, Eq value)
=> EpochStateView -- ^ Current epoch state view. It can be obtained using the 'getEpochStateView' function.
-> FilePath -- ^ The file path to the configuration file.
-> FilePath -- ^ The file path to the unix socket file to connect to the @cardano-node@.
-> ConwayEraOnwards era -- ^ Witness for the current era that shows it is Conway or onwards.
-> Word64 -- ^ The minimum wait time in epochs.
-> Maybe value -- ^ The expected value to check in the epoch state.
-> Word64 -- ^ The maximum wait time in epochs.
-> Lens' (L.NewEpochState (ShelleyLedgerEra era)) value -- ^ The lens to access the specific value in the epoch state.
-> m ()
waitAndCheckNewEpochState epochStateView configurationFile socketPath ceo minWait mExpected maxWait lens = do
let sbe = conwayEraOnwardsToShelleyBasedEra ceo
(EpochNo curEpoch) <- getCurrentEpochNo epochStateView
Expand Down

0 comments on commit 23730fa

Please sign in to comment.