HBULCDN6E75FAPILFVLTQIKABDEWL3HZTBLICLCWOIKDRYM6UIBQC M4KM76DGO77VC4O6N5FFA5MTZH5GI5AJ3OUJU7INLAOY2M3LRLLAC F2XLL7XWGUV4TJD4X2MJADYAQHCSB4HD2TPPEYVHEKHOQIOOFISAC GLFF5ZDKWI7WKPZSAEE3IUM27LL6DFOPIL4VPODXYXV3BCSCJ6GQC NEDDHXUK3GNFMOFO3KLU7NRIHCTYNWBT3D6HTKZAOXFDE6HMDZ6AC LAROLAYUGJ4Q5AEFV5EJMIA2ZKBNCBWHHHPCJ3CKCNIUIYUKRFVQC TLQ72DSJD7GGPWN6HGBHAVPBRQFKEQ6KSK43U7JWWID4ZWAF47JAC WO2MINIF4TXOHWSE7JWXRZYN64XRVLYIRFMF4SMPSOXKA2V77KMQC 75N3UJ4JK56KXF56GASGPAWLFYGJDETVJNYTF4KXFCQM767JUU5AC 2XQD6KKKD6QVHFHAEMVE3XXY7X2T7BLTLL7XIILZAXNJJH2YONUQC ZP62WC472OTQETO2HTHIQIPO57XZIWVKPA4KL62GYU4OZDMB6NSAC KEP5WUFJXTMKRRNZLYTGYYWA4VLFCMHTKTJYF5EA5IWBYFMU6WYQC 7HPY3QPFPN35PSPUBVNW2GTFB3CBQZBST4J2BAVJ7QMXLIUN52JAC IZEVQF627FA7VV25KJAWYWGGC35LZUUBBQRPN5ZAINTQLPEDRTEAC UUR6SMCAJMA7O3ZFUCQMPZFDDIPUVQ5IHUAC5F252YVD6H3JIKPQC | total + (x ^. bidAmount) < raiseAmount' =x : takeWinningBids (total + (x ^. bidAmount)) xs
| total + (bid ^. bidAmount) < raiseAmount' =bid : takeWinningBids (total + (bid ^. bidAmount)) xs
winFraction = toRational remainder / toRational (x ^. bidAmount)remainderSeconds = Seconds . round $ winFraction * toRational (x ^. bidSeconds)
winFraction = toRational remainder / toRational (bid ^. bidAmount)remainderSeconds = Seconds . round $ winFraction * toRational (bid ^. bidSeconds)
spec = dodescribe "bid ordering" $it "ensures that bids with lowest seconds/btc ratio are first" $let testB1 = Bid (UserId nil) (Seconds 60) (Satoshi 1000) undefinedtestB2 = Bid (UserId nil) (Seconds 60) (Satoshi 100) undefinedtestB3 = Bid (UserId nil) (Seconds 90) (Satoshi 100) undefinedin do
spec =let testB0 = Bid (UserId nil) (Seconds 3) (Satoshi 100) (read "2016-03-05 15:59:26.033176 UTC")testB1 = Bid (UserId nil) (Seconds 60) (Satoshi 1000)(read "2016-03-05 15:59:26.033177 UTC")testB2 = Bid (UserId nil) (Seconds 60) (Satoshi 100) (read "2016-03-05 15:59:26.033178 UTC")testB3 = Bid (UserId nil) (Seconds 90) (Satoshi 100) (read "2016-03-05 15:59:26.033179 UTC")testB4 = Bid (UserId nil) (Seconds 60) (Satoshi 100) (read "2016-03-05 15:59:26.033180 UTC")in dodescribe "bid ordering" $ doit "ensures that bids with lowest seconds/btc ratio are first" $ dobidOrder testB0 testB1 `shouldBe` LT
describe "winning bids" $it "determines a sufficient number of winners to fulfill the raise amount" $True `shouldBe` True
describe "winning bids" $ doit "determines a sufficient number of winners to fulfill the raise amount" $let winners = winningBids' (Satoshi 1250) [testB0, testB1, testB2, testB3, testB4]split = Bid (UserId nil) (Seconds 30) (Satoshi 50) (testB4 ^. bidTime)in sortBy bidOrder winners `shouldBe` sortBy bidOrder [testB0, testB1, testB2, split]