Skip to content

Commit

Permalink
Verify persistence of SlotInternalIndex values.
Browse files Browse the repository at this point in the history
Verify that values of type `SlotInternalIndex` can be successfully
written to and read from the database without loss of information.
  • Loading branch information
jonathanknowles committed Jul 10, 2020
1 parent 9675a8d commit 98daf5c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/core/test/unit/Cardano/Wallet/DB/Sqlite/TypesSpec.hs
Expand Up @@ -14,7 +14,7 @@ import Prelude
import Cardano.Wallet.DB.Sqlite.Types
()
import Cardano.Wallet.Primitive.Types
( EpochNo (..), SlotId (..), SlotNo (..) )
( EpochNo (..), SlotId (..), SlotInternalIndex (..), SlotNo (..) )
import Data.Proxy
( Proxy (..) )
import Data.Typeable
Expand All @@ -38,6 +38,7 @@ spec :: Spec
spec = do
describe "Values can be persisted and unpersisted successfully" $ do
persistRoundtrip $ Proxy @SlotId
persistRoundtrip $ Proxy @SlotInternalIndex

-- | Constructs a test to check that roundtrip persistence and unpersistence is
-- possible for values of the given type.
Expand All @@ -60,6 +61,10 @@ instance Arbitrary SlotId where
arbitrary = applyArbitrary2 SlotId
shrink (SlotId en sn) = uncurry SlotId <$> shrink (en, sn)

instance Arbitrary SlotInternalIndex where
arbitrary = SlotInternalIndex <$> arbitrary
shrink = fmap SlotInternalIndex . shrink . unSlotInternalIndex

instance Arbitrary EpochNo where
arbitrary = EpochNo <$> arbitrary
shrink (EpochNo n) = EpochNo <$> shrink n
Expand Down

0 comments on commit 98daf5c

Please sign in to comment.