This commit is contained in:
Dmitry Zuikov 2023-01-10 17:23:22 +03:00
parent 332094a605
commit f9c4464301
2 changed files with 39 additions and 5 deletions

View File

@ -8,9 +8,10 @@ import TestSimpleStorage
import HBS2.Storage
main :: IO ()
main = defaultMain $
testGroup "root" [ testCase "testSimpleStorageInit" testSimpleStorageInit
]
main =
defaultMain $
testGroup "root" [ testCase "testSimpleStorageRandomReadWrite" testSimpleStorageRandomReadWrite
]

View File

@ -17,13 +17,46 @@ import Test.QuickCheck
import Test.Tasty.HUnit
import HBS2.Hash
import HBS2.Clock
import HBS2.Prelude.Plated
import HBS2.Storage
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