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ual = view eventTime <$> workIndex id logEntries
in actual `shouldBe` expected
it "computes correct work shares" $ do
[u0, u1, u2] <- fmap CreditToUser . take 3 <$> sample' (UserId <$> genUUID)
let initTime = toThyme . fromJust $ parseISO8601 "2014-01-01T00:08:00Z"
len = fromInteger @NominalDiffTime 360
timestamps = iterate (addUTCTime len) initTime
intervals =
fmap (uncurry I.Interval . snd)
. filter (\i -> fst i `mod` 2 == 0)
$ ([(0 :: Int)..] `zip` (timestamps `zip` tail timestamps))
widx = WorkIndex $ M.fromList
[ (u0, L.fromList $ take 10 intervals)
, (u1, L.fromList $ take 30 intervals)
, (u2, L.fromList $ take 120 intervals)
]
-- for this test we'll be entirely within undepreciated period
depf = toDepF $ LinearDepreciation 180 1800
evalTime = I._start . head $ drop 120 intervals
shares = payouts depf evalTime widx
(shares ^. loggedTotal `shouldBe` (fromInteger @NominalDiffTime (360 * 160)))
(shares ^. creditToShares . to (fromJust . M.lookup u0) . wsShare) `shouldBe` (10 % 160)
(shares ^. creditToShares . to (fromJust . M.lookup u1) . wsShare) `shouldBe` (30 % 160)
(shares ^. creditToShares . to (fromJust . M.lookup u2) . wsShare) `shouldBe` (120 % 160)