From f0c5533dcadb74171068a244fbe1e52cd197e209 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Mon, 6 May 2024 10:29:38 -0400 Subject: [PATCH] Fix flaky test --- .../Cardano/Testnet/Test/Gov/DRepActivity.hs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs index c306a3db5b0..3cbbcbb3210 100644 --- a/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs +++ b/cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/DRepActivity.hs @@ -96,14 +96,11 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas gov <- H.createDirectoryIfMissing $ work "governance" -- This proposal should pass - let minEpochsToWaitIfChanging = 0 -- The change already provides a min bound - minEpochsToWaitIfNotChanging = 3 -- We cannot wait for change since there is no change (we wait a bit) - maxEpochsToWaitAfterProposal = 10 -- If it takes more than 10 epochs we give up in any case + let maxEpochsToWaitAfterProposal = 10 -- If it takes more than 10 epochs we give up in any case firstTargetDRepActivity = 3 void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov "firstProposal" wallet0 [(1, "yes")] firstTargetDRepActivity - minEpochsToWaitIfChanging (Just firstTargetDRepActivity) - maxEpochsToWaitAfterProposal + (Just firstTargetDRepActivity) maxEpochsToWaitAfterProposal -- Now we register two new DReps drep2 <- registerDRep execConfig epochStateView ceo work "drep2" wallet1 @@ -125,8 +122,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas let secondTargetDRepActivity = firstTargetDRepActivity + 1 void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov "failingProposal" wallet2 [(1, "yes")] secondTargetDRepActivity - minEpochsToWaitIfNotChanging (Just firstTargetDRepActivity) - maxEpochsToWaitAfterProposal + (Just firstTargetDRepActivity) maxEpochsToWaitAfterProposal -- We now send a bunch of proposals to make sure that the 2 new DReps expire. -- because DReps won't expire if there is not enough activity (opportunites to participate). @@ -136,8 +132,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas [activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov ("fillerProposalNum" ++ show proposalNum) wallet [(1, "yes")] (secondTargetDRepActivity + fromIntegral proposalNum) - minEpochsToWaitIfNotChanging Nothing - maxEpochsToWaitAfterProposal + Nothing maxEpochsToWaitAfterProposal | (proposalNum, wallet) <- zip [1..numOfFillerProposals] (cycle [wallet0, wallet1, wallet2])] (EpochNo epochAfterTimeout) <- getCurrentEpochNo epochStateView @@ -148,8 +143,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas let lastTargetDRepActivity = secondTargetDRepActivity + fromIntegral numOfFillerProposals + 1 void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo gov "lastProposal" wallet0 [(1, "yes")] lastTargetDRepActivity - minEpochsToWaitIfChanging (Just lastTargetDRepActivity) - maxEpochsToWaitAfterProposal + (Just lastTargetDRepActivity) maxEpochsToWaitAfterProposal activityChangeProposalTest :: (HasCallStack, MonadTest m, MonadIO m, H.MonadAssertion m, MonadCatch m, Foldable t) @@ -163,12 +157,11 @@ activityChangeProposalTest -> PaymentKeyInfo -> t (Int, String) -> Word32 - -> Word64 -> Maybe Word32 -> Word64 -> m (String, Word32) activityChangeProposalTest execConfig epochStateView configurationFile socketPath ceo work prefix - wallet votes change minWait mExpected maxWait = do + wallet votes change mExpected maxWait = do let sbe = conwayEraOnwardsToShelleyBasedEra ceo @@ -225,7 +218,6 @@ activityChangeProposalTest execConfig epochStateView configurationFile socketPat isSuccess :: Word64 -> EpochNo -> EpochInterval -> Bool isSuccess epochAfterProp (EpochNo epochNo) (EpochInterval epochInterval) = - (epochAfterProp + minWait <= epochNo) && (case mExpected of Nothing -> True Just expected -> epochInterval == expected) &&