Skip to content
Permalink
Browse files

Sqlite: fix dummy state for tests

  • Loading branch information...
rvl committed May 16, 2019
1 parent d367791 commit 4c1b866932af034270d349bf941255175a709e5b
Showing with 11 additions and 3 deletions.
  1. +9 −1 lib/core/test/unit/Cardano/Wallet/DB/SqliteSpec.hs
  2. +2 −2 lib/core/test/unit/Cardano/Wallet/DBSpec.hs
@@ -14,7 +14,9 @@ import Prelude
import Cardano.Wallet.DB
( DBLayer (..) )
import Cardano.Wallet.DB.Sqlite
( newDBLayer )
( PersistState (..), newDBLayer )
import Cardano.Wallet.DB.SqliteTypes
( AddressScheme (..) )
import Cardano.Wallet.DBSpec
( DummyStateSqlite (..)
, DummyTarget
@@ -41,6 +43,12 @@ import Test.Hspec
import Test.QuickCheck
( checkCoverage, property )

instance PersistState (DummyStateSqlite) where
insertState (_wid, _sl) _st = pure ()
selectState (_wid, _sl) = pure (Just (DummyStateSqlite 42))
deleteState _ wid = pure ()
addressScheme _ = Any

spec :: Spec
spec = do
before (newDBLayer Nothing :: IO (DBLayer IO DummyStateSqlite DummyTarget)) $
@@ -191,12 +191,12 @@ instance Arbitrary PendingTx where
<*> vectorOf k arbitrary
return $ PendingTx pending

newtype DummyStateSqlite = DummyStateSqlite (UTxO, PendingTx)
newtype DummyStateSqlite = DummyStateSqlite Int
deriving (Show, Eq, NFData)

instance Arbitrary DummyStateSqlite where
shrink _ = []
arbitrary = DummyStateSqlite <$> arbitrary
arbitrary = DummyStateSqlite <$> pure 42

instance IsOurs DummyStateSqlite where
isOurs _ wm = (True, wm)

0 comments on commit 4c1b866

Please sign in to comment.
You can’t perform that action at this time.