Skip to content

Commit

Permalink
SqliteSpec: Skip TxHistory put+read tests for Sqlite
Browse files Browse the repository at this point in the history
The model of dbPropertyTests doesn't match how the relational database
works.
  • Loading branch information
rvl committed May 31, 2019
1 parent e4b8064 commit bb7895b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/core/test/unit/Cardano/Wallet/DB/MVarSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Cardano.Wallet.DB
import Cardano.Wallet.DB.MVar
( newDBLayer )
import Cardano.Wallet.DBSpec
( DummyTarget, dbPropertyTests, withDB )
( DummyTarget, SkipTests (..), dbPropertyTests, withDB )
import Cardano.Wallet.Primitive.AddressDiscovery
( IsOurs (..), SeqState (..) )
import Cardano.Wallet.Primitive.Model
Expand All @@ -31,7 +31,7 @@ import Test.QuickCheck

spec :: Spec
spec = withDB (newDBLayer :: IO (DBLayer IO (SeqState DummyTarget) DummyTarget)) $
describe "MVar" dbPropertyTests
describe "MVar" (dbPropertyTests RunAllTests)

newtype DummyStateMVar = DummyStateMVar Int
deriving (Show, Eq)
Expand Down
4 changes: 2 additions & 2 deletions lib/core/test/unit/Cardano/Wallet/DB/SqliteSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Cardano.Wallet.DB.Sqlite
import Cardano.Wallet.DB.StateMachine
( prop_parallel, prop_sequential )
import Cardano.Wallet.DBSpec
( DummyTarget, dbPropertyTests, withDB )
( DummyTarget, SkipTests (..), dbPropertyTests, withDB )
import Cardano.Wallet.Primitive.AddressDerivation
( Passphrase (..)
, encryptPassphrase
Expand Down Expand Up @@ -75,7 +75,7 @@ import qualified Data.Map as Map
spec :: Spec
spec = withDB newMemoryDBLayer $ do
describe "Sqlite Simple tests" simpleSpec
describe "Sqlite" dbPropertyTests
describe "Sqlite" (dbPropertyTests SkipTxHistoryReplaceTest)
describe "Sqlite State machine tests" $ do
it "Sequential" prop_sequential
xit "Parallel" prop_parallel
Expand Down
15 changes: 11 additions & 4 deletions lib/core/test/unit/Cardano/Wallet/DBSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Cardano.Wallet.DBSpec
, dbPropertyTests
, withDB
, DummyTarget
, SkipTests(..)
) where

import Prelude
Expand Down Expand Up @@ -86,7 +87,7 @@ import Control.Concurrent.Async
import Control.DeepSeq
( NFData )
import Control.Monad
( forM, forM_, void )
( forM, forM_, void, when )
import Control.Monad.IO.Class
( liftIO )
import Control.Monad.Trans.Except
Expand Down Expand Up @@ -653,10 +654,16 @@ prop_parallelPut putOp readOp resolve dbLayer (KeyValPairs pairs) =
res <- once pairs (readOp db . fst)
length res `shouldBe` resolve pairs

data SkipTests
= RunAllTests
| SkipTxHistoryReplaceTest
deriving (Show, Eq)

dbPropertyTests
:: (Arbitrary (Wallet s DummyTarget), Show s, Eq s, IsOurs s, NFData s)
=> SpecWith (DBLayer IO s DummyTarget)
dbPropertyTests = do
=> SkipTests
-> SpecWith (DBLayer IO s DummyTarget)
dbPropertyTests skip = do
describe "Extra Properties about DB initialization" $ do
it "createWallet . listWallets yields expected results"
(property . prop_createListWallet)
Expand Down Expand Up @@ -720,7 +727,7 @@ dbPropertyTests = do
(checkCoverage . (prop_sequentialPut putCheckpoint readCheckpoint lrp))
it "Wallet Metadata"
(checkCoverage . (prop_sequentialPut putWalletMeta readWalletMeta lrp))
it "Tx History"
when (skip == RunAllTests) $ it "Tx History"
(checkCoverage . (prop_sequentialPut putTxHistory readTxHistoryF unions))
it "Private Key"
(checkCoverage . (prop_sequentialPut putPrivateKey readPrivateKey lrp))
Expand Down

0 comments on commit bb7895b

Please sign in to comment.