Skip to content

Commit

Permalink
refactoring #40 | use Millisecond instead of Second for shorter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Mar 11, 2019
1 parent ab904ec commit 66f24a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Cardano/Wallet/BlockSyncer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Cardano.Wallet.Primitive
import Control.Concurrent
( threadDelay )
import Data.Time.Units
( Second, toMicroseconds )
( Millisecond, toMicroseconds )

import qualified Data.List as L

Expand All @@ -37,7 +37,7 @@ tickingFunction
-- ^ a way to get a new block
-> (Block -> IO ())
-- ^ action taken on a new block
-> Second
-> Millisecond
-- ^ tick time
-> BlockHeadersConsumed
-> IO ()
Expand Down
7 changes: 4 additions & 3 deletions test/unit/Cardano/Wallet/BlockSyncerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Data.ByteString
import Data.Map.Strict
( Map )
import Data.Time.Units
( Second, fromMicroseconds )
( Millisecond, fromMicroseconds )
import Data.Tuple
( swap )
import Test.Hspec
Expand Down Expand Up @@ -68,6 +68,7 @@ tickingFunctionTest
:: (TickingTime, Blocks)
-> Property
tickingFunctionTest (TickingTime tickTime, Blocks blocks) = monadicIO $ liftIO $ do
print blocks
(readerChan, reader) <- mkReader
(writerChan, writer) <- mkWriter blocks
waitFor writerChan $ tickingFunction writer reader tickTime (BlockHeadersConsumed [])
Expand Down Expand Up @@ -118,13 +119,13 @@ mkReader = do
-------------------------------------------------------------------------------}


newtype TickingTime = TickingTime Second
newtype TickingTime = TickingTime Millisecond
deriving (Show)

instance Arbitrary TickingTime where
-- No shrinking
arbitrary = do
tickTime <- fromMicroseconds . (* (1000 * 1000)) <$> choose (1, 3)
tickTime <- fromMicroseconds . (* 1000) <$> choose (50, 100)
return $ TickingTime tickTime


Expand Down

0 comments on commit 66f24a6

Please sign in to comment.