Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add properties for submissions store
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
lib/wallet/test/unit/Cardano/Wallet/DB/Store/Submissions/New/StoreSpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE StandaloneDeriving #-} | ||
|
||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
|
||
module Cardano.Wallet.DB.Store.Submissions.New.StoreSpec ( spec ) where | ||
|
||
import Prelude | ||
|
||
import Cardano.DB.Sqlite | ||
( ForeignKeysSetting (ForeignKeysDisabled) ) | ||
import Cardano.Wallet.Api.TypesSpec | ||
() | ||
import Cardano.Wallet.DB.Fixtures | ||
( WalletProperty, logScale, withDBInMemory, withInitializedWalletProp ) | ||
import Cardano.Wallet.DB.Store.Submissions.New.Primitives | ||
( Primitive', mkStorePrimitivesSubmissions ) | ||
import Cardano.Wallet.Primitive.Types | ||
( SlotNo (..) ) | ||
import Cardano.Wallet.Submissions.PrimitivesSpec | ||
( primitiveDeltaG ) | ||
import Cardano.Wallet.Submissions.Submissions | ||
( Submissions (..) ) | ||
import Control.Monad | ||
( void ) | ||
import Fmt | ||
( Buildable (..) ) | ||
import System.Random | ||
( Random ) | ||
import Test.DBVar | ||
( prop_StoreUpdates ) | ||
import Test.Hspec | ||
( Spec, around, describe, it ) | ||
import Test.QuickCheck | ||
( property ) | ||
|
||
spec :: Spec | ||
spec = do | ||
around (withDBInMemory ForeignKeysDisabled) $ do | ||
describe "submissions for a single wallet store" $ do | ||
it "respects store laws" $ property . prop_SingleWalletStoreLaws | ||
|
||
instance Buildable Primitive' where | ||
build = build . show | ||
|
||
prop_SingleWalletStoreLaws :: WalletProperty | ||
prop_SingleWalletStoreLaws = withInitializedWalletProp $ \wid runQ -> do | ||
void $ prop_StoreUpdates | ||
runQ | ||
(mkStorePrimitivesSubmissions wid) | ||
(pure $ Submissions mempty 0 0) | ||
(logScale . primitiveDeltaG) | ||
|
||
deriving instance Random SlotNo |