Skip to content

Commit

Permalink
Refactor activityChangeProposalTest so that expected is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Apr 25, 2024
1 parent 0f47eb7 commit 6bcc25b
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas

-- This proposal should pass
firstProposalInfo <- activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
"firstProposal" wallet0 Nothing [(1, "yes")] 6 6 3
"firstProposal" wallet0 Nothing [(1, "yes")] 6 (Just 6) 3

-- Now we register two new DReps
drep2 <- registerDRep execConfig epochStateView sbe work "drep2" wallet1
Expand All @@ -117,19 +117,19 @@ hprop_check_drep_activity = H.integrationWorkspace "test-activity" $ \tempAbsBas
-- We send three because DRep won't expire if there is not enough activity
-- (opportunites to participate). This is accounted for by the dormant epoch count
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
"secondProposal" wallet2 (Just firstProposalInfo) [(1, "yes")] 7 6 3
"secondProposal" wallet2 (Just firstProposalInfo) [(1, "yes")] 7 (Just 6) 3
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
"thirdProposal" wallet0 (Just firstProposalInfo) [(1, "yes")] 7 6 3
"thirdProposal" wallet0 (Just firstProposalInfo) [(1, "yes")] 7 (Just 6) 3
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
"fourthProposal" wallet1 (Just firstProposalInfo) [(1, "yes")] 7 6 3
"fourthProposal" wallet1 (Just firstProposalInfo) [(1, "yes")] 7 (Just 6) 3

(EpochNo epochAfterTimeout) <- getCurrentEpochNo epochStateView sbe
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)
-- Because 2 out of 3 DReps were inactive, prop should pass
void $ activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe gov
"lastProposal" wallet2 (Just firstProposalInfo) [(1, "yes")] 8 8 3
"lastProposal" wallet2 (Just firstProposalInfo) [(1, "yes")] 8 (Just 8) 3


activityChangeProposalTest
Expand All @@ -145,11 +145,11 @@ activityChangeProposalTest
-> Maybe (String, Word32)
-> t (Int, String)
-> Word32
-> Integer
-> Maybe Integer
-> Word64
-> m (String, Word32)
activityChangeProposalTest execConfig epochStateView configurationFile socketPath sbe work prefix
wallet previousProposalInfo votes change expected epochsToWait = do
wallet previousProposalInfo votes change mExpected epochsToWait = do

baseDir <- H.createDirectoryIfMissing $ work </> prefix

Expand All @@ -171,9 +171,10 @@ activityChangeProposalTest execConfig epochStateView configurationFile socketPat
H.note_ $ "Epoch after \"" <> prefix <> "\" prop: " <> show epochAfterProp

void $ waitUntilEpoch (File configurationFile) (File socketPath) (EpochNo (epochAfterProp + epochsToWait))
dRepActivityAfterProp <- getDRepActivityValue execConfig

dRepActivityAfterProp === expected
case mExpected of
Nothing -> return ()
Just expected -> do dRepActivityAfterProp <- getDRepActivityValue execConfig
dRepActivityAfterProp === expected

return thisProposal

Expand Down

0 comments on commit 6bcc25b

Please sign in to comment.