Skip to content

Commit

Permalink
Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed May 6, 2024
1 parent 7979ad0 commit f0c5533
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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) &&
Expand Down

0 comments on commit f0c5533

Please sign in to comment.