@@ -21,6 +21,7 @@ import Database.LSMTree.Internal.BlobRef
2121import Database.LSMTree.Internal.Config
2222import Database.LSMTree.Internal.Entry
2323import Database.LSMTree.Internal.Serialise
24+ import Database.LSMTree.Internal.Types (Salt )
2425import Database.LSMTree.Internal.Unsafe
2526import qualified System.FS.API as FS
2627import Test.QuickCheck
@@ -44,6 +45,10 @@ tests = testGroup "Test.Database.LSMTree.Internal" [
4445 ]
4546 ]
4647
48+
49+ testSalt :: Salt
50+ testSalt = 6
51+
4752testTableConfig :: TableConfig
4853testTableConfig = defaultTableConfig {
4954 -- Write buffer size is small on purpose, so that the test actually
@@ -58,7 +63,7 @@ newSession ::
5863newSession (Positive (Small bufferSize)) es =
5964 ioProperty $
6065 withTempIOHasBlockIO " newSession" $ \ hfs hbio ->
61- withSession nullTracer hfs hbio (FS. mkFsPath [] ) $ \ session ->
66+ withSession nullTracer hfs hbio testSalt (FS. mkFsPath [] ) $ \ session ->
6267 withTable session conf (updates const es')
6368 where
6469 conf = testTableConfig {
@@ -73,9 +78,9 @@ restoreSession ::
7378restoreSession (Positive (Small bufferSize)) es =
7479 ioProperty $
7580 withTempIOHasBlockIO " restoreSession" $ \ hfs hbio -> do
76- withSession nullTracer hfs hbio (FS. mkFsPath [] ) $ \ session1 ->
81+ withSession nullTracer hfs hbio testSalt (FS. mkFsPath [] ) $ \ session1 ->
7782 withTable session1 conf (updates const es')
78- withSession nullTracer hfs hbio (FS. mkFsPath [] ) $ \ session2 ->
83+ withSession nullTracer hfs hbio testSalt (FS. mkFsPath [] ) $ \ session2 ->
7984 withTable session2 conf (updates const es')
8085 where
8186 conf = testTableConfig {
@@ -86,8 +91,8 @@ restoreSession (Positive (Small bufferSize)) es =
8691sessionDirLocked :: Property
8792sessionDirLocked = ioProperty $
8893 withTempIOHasBlockIO " sessionDirLocked" $ \ hfs hbio -> do
89- bracket (openSession nullTracer hfs hbio (FS. mkFsPath [] )) closeSession $ \ _sesh1 ->
90- bracket (try @ SessionDirLockedError $ openSession nullTracer hfs hbio (FS. mkFsPath [] )) tryCloseSession $ \ case
94+ bracket (openSession nullTracer hfs hbio testSalt (FS. mkFsPath [] )) closeSession $ \ _sesh1 ->
95+ bracket (try @ SessionDirLockedError $ openSession nullTracer hfs hbio testSalt (FS. mkFsPath [] )) tryCloseSession $ \ case
9196 Left (ErrSessionDirLocked _dir) -> pure ()
9297 x -> assertFailure $ " Opening a session twice in the same directory \
9398 \should fail with an ErrSessionDirLocked error, but \
@@ -97,15 +102,15 @@ sessionDirCorrupted :: Assertion
97102sessionDirCorrupted =
98103 withTempIOHasBlockIO " sessionDirCorrupted" $ \ hfs hbio -> do
99104 FS. createDirectory hfs (FS. mkFsPath [" unexpected-directory" ])
100- bracket (try @ SessionDirCorruptedError (openSession nullTracer hfs hbio (FS. mkFsPath [] ))) tryCloseSession $ \ case
105+ bracket (try @ SessionDirCorruptedError (openSession nullTracer hfs hbio testSalt (FS. mkFsPath [] ))) tryCloseSession $ \ case
101106 Left (ErrSessionDirCorrupted _dir) -> pure ()
102107 x -> assertFailure $ " Restoring a session in a directory with a wrong \
103108 \layout should fail with a ErrSessionDirCorrupted, but \
104109 \it returned this instead: " <> showLeft " Session" x
105110
106111sessionDirDoesNotExist :: Assertion
107112sessionDirDoesNotExist = withTempIOHasBlockIO " sessionDirDoesNotExist" $ \ hfs hbio -> do
108- bracket (try @ SessionDirDoesNotExistError (openSession nullTracer hfs hbio (FS. mkFsPath [" missing-dir" ]))) tryCloseSession $ \ case
113+ bracket (try @ SessionDirDoesNotExistError (openSession nullTracer hfs hbio testSalt (FS. mkFsPath [" missing-dir" ]))) tryCloseSession $ \ case
109114 Left (ErrSessionDirDoesNotExist _dir) -> pure ()
110115 x -> assertFailure $ " Opening a session in a non-existent directory should \
111116 \fail with a ErrSessionDirDoesNotExist error, but it \
@@ -140,7 +145,7 @@ prop_roundtripCursor ::
140145 -> Property
141146prop_roundtripCursor lb ub kops = ioProperty $
142147 withTempIOHasBlockIO " prop_roundtripCursor" $ \ hfs hbio -> do
143- withSession nullTracer hfs hbio (FS. mkFsPath [] ) $ \ sesh -> do
148+ withSession nullTracer hfs hbio testSalt (FS. mkFsPath [] ) $ \ sesh -> do
144149 withTable sesh conf $ \ t -> do
145150 updates resolve (coerce kops) t
146151 fromCursor <- withCursor resolve (toOffsetKey lb) t $ \ c ->
0 commit comments