mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
332094a605
commit
f9c4464301
|
@ -8,8 +8,9 @@ import TestSimpleStorage
|
||||||
import HBS2.Storage
|
import HBS2.Storage
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = defaultMain $
|
main =
|
||||||
testGroup "root" [ testCase "testSimpleStorageInit" testSimpleStorageInit
|
defaultMain $
|
||||||
|
testGroup "root" [ testCase "testSimpleStorageRandomReadWrite" testSimpleStorageRandomReadWrite
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,46 @@ import Test.QuickCheck
|
||||||
import Test.Tasty.HUnit
|
import Test.Tasty.HUnit
|
||||||
|
|
||||||
import HBS2.Hash
|
import HBS2.Hash
|
||||||
|
import HBS2.Clock
|
||||||
import HBS2.Prelude.Plated
|
import HBS2.Prelude.Plated
|
||||||
import HBS2.Storage
|
import HBS2.Storage
|
||||||
import HBS2.Storage.Simple
|
import HBS2.Storage.Simple
|
||||||
|
|
||||||
|
|
||||||
testSimpleStorageInit :: IO ()
|
|
||||||
testSimpleStorageInit = do
|
testSimpleStorageNoKeys :: IO ()
|
||||||
|
testSimpleStorageNoKeys = do
|
||||||
|
withSystemTempDirectory "simpleStorageTest" $ \dir -> do
|
||||||
|
|
||||||
|
let opts = [ StoragePrefix (dir </> ".storage")
|
||||||
|
]
|
||||||
|
|
||||||
|
storage <- simpleStorageInit opts :: IO (SimpleStorage HbSync)
|
||||||
|
|
||||||
|
worker <- async (simpleStorageWorker storage)
|
||||||
|
|
||||||
|
let pieces = take 1000 $ shrink [0x00 .. 0xFF] :: [[Word8]]
|
||||||
|
|
||||||
|
results' <- forConcurrently pieces $ \p -> do
|
||||||
|
let hash = hashObject (LBS.pack p)
|
||||||
|
s <- getBlock storage hash
|
||||||
|
pure (LBS.length <$> s)
|
||||||
|
|
||||||
|
let results = catMaybes results'
|
||||||
|
|
||||||
|
print ("results", length results)
|
||||||
|
|
||||||
|
assertBool "no-results" (null results)
|
||||||
|
|
||||||
|
pause ( 0.05 :: Timeout 'Seconds )
|
||||||
|
|
||||||
|
cancel worker
|
||||||
|
|
||||||
|
pure ()
|
||||||
|
|
||||||
|
|
||||||
|
testSimpleStorageRandomReadWrite :: IO ()
|
||||||
|
testSimpleStorageRandomReadWrite = do
|
||||||
|
|
||||||
withSystemTempDirectory "simpleStorageTest" $ \dir -> do
|
withSystemTempDirectory "simpleStorageTest" $ \dir -> do
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue