Skip to content

Commit

Permalink
refactoring #8 | define single block generator from previous block
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Mar 11, 2019
1 parent 842775d commit 2ac72be
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/unit/Cardano/Wallet/BlockSyncerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,28 @@ mkConsecutiveTestBlocks blockNum =
loop blockNum []
where
bytelistGenerator = pack <$> vector 10 :: Gen ByteString

fromPreviousBlock
:: (Hash "BlockHeader", Block)
-> Gen (Hash "BlockHeader", Block)
fromPreviousBlock (h, b) = do
h' <- Hash <$> bytelistGenerator
return
( h'
, Block
{ header = BlockHeader
{ epochIndex = epochIndex (header b)
, slotNumber = slotNumber (header b) + 1
, prevBlockHash = h
}
, transactions = mempty
}
)

loop
:: Int
-> [((Hash "BlockHeader"),Block)]
-> IO [((Hash "BlockHeader"),Block)]
-> [(Hash "BlockHeader", Block)]
-> IO [(Hash "BlockHeader", Block)]
loop n res
| n <= 0 = return $ reverse res
| res == mempty = do
Expand Down

0 comments on commit 2ac72be

Please sign in to comment.