diff --git a/eras/conway/impl/test/Test/Cardano/Ledger/Conway/SPORatifySpec.hs b/eras/conway/impl/test/Test/Cardano/Ledger/Conway/SPORatifySpec.hs index 8e970b1b0c7..25d684d9870 100644 --- a/eras/conway/impl/test/Test/Cardano/Ledger/Conway/SPORatifySpec.hs +++ b/eras/conway/impl/test/Test/Cardano/Ledger/Conway/SPORatifySpec.hs @@ -108,13 +108,10 @@ noStakeProp = prop @((RatifyEnv era, RatifyState era, GovActionState era) -> IO ()) "If there is no stake, accept iff threshold is zero" ( \(re, rs, gas) -> - spoAccepted - @era - re {reStakePoolDistr = PoolDistr Map.empty (fromJust . toCompact $ Coin 100)} - rs - gas - `shouldBe` votingStakePoolThreshold @era rs (gasAction gas) - == SJust minBound + let re' = re {reStakePoolDistr = PoolDistr Map.empty (fromJust . toCompact $ Coin 100)} + in spoAccepted @era re' rs gas + `shouldBe` + (votingStakePoolThreshold @era rs (gasAction gas) == SJust minBound) ) allAbstainProp :: @@ -282,7 +279,7 @@ genTestData Ratios {yes, no, abstain, alwaysAbstain, noConfidence} = do , stakeNoConfidence = Coin . fromIntegral $ length poolsNoConfidence , stakeNotVoted = Coin . fromIntegral $ length rest , delegatees = Map.union delegateesAA delegateesNC - , poolParams = Map.union poolParamsRest $ Map.union poolParamsAA poolParamsNC + , poolParams = Map.unions [poolParamsRest, poolParamsAA, poolParamsNC] } where splitByPct :: @@ -305,8 +302,10 @@ genTestData Ratios {yes, no, abstain, alwaysAbstain, noConfidence} = do (rs1, rs2, rs3, rs4, rs5, rest'''') genPoolParams p = do - params <- arbitrary - pure $ Map.fromList [(cred, params) | cred <- p] + let genPoolParams poolId = do + poolParams <- arbitrary + pure $ poolParams { ppId = poolId } + sequence $ fromKeys genPoolParams p -- Given a delegatee and a map of stake pool params, -- create a map of reward account delegatees. @@ -315,17 +314,14 @@ genTestData Ratios {yes, no, abstain, alwaysAbstain, noConfidence} = do Map (KeyHash 'StakePool (EraCrypto era)) (PoolParams (EraCrypto era)) -> Map (Credential 'Staking (EraCrypto era)) (DRep (EraCrypto era)) mkDelegatees drep = - Map.fromList - . map (\(_, params) -> (raCredential $ ppRewardAccount params, drep)) - . Map.toList + fromKeys (const drep) . map (raCredential . ppRewardAccount) . Map.elems -- Create a map from each pool with the given value, where the key is the pool credential -- and take the union of all these maps. unionAllFromLists :: [([KeyHash 'StakePool (EraCrypto era)], a)] -> Map (KeyHash 'StakePool (EraCrypto era)) a - unionAllFromLists = - foldr (Map.union . (\(l, v) -> Map.fromList [(cred, v) | cred <- l])) Map.empty + unionAllFromLists = foldMap (\(ks, v) -> fromKeys (const v) ks) genRatios :: Gen Ratios genRatios = do