Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
db: Add a test for upstream functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Dec 3, 2019
1 parent 025ef94 commit 1a34709
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions cardano-explorer-db/cardano-explorer-db.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ test-suite test

other-modules: Test.Property.Explorer.DB.Migration
Test.Property.Explorer.DB.Types
Test.Property.Upstream

build-depends: base >= 4.12 && < 4.13
, aeson
Expand Down
32 changes: 32 additions & 0 deletions cardano-explorer-db/test/Test/Property/Upstream.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

module Test.Property.Upstream
( tests
) where

-- Test things that come from upstream packages that have at any stage gone wrong
-- or for which

import Cardano.Chain.Common (fromCBORTextAddress, isRedeemAddress)

import Hedgehog (Property, (===), discover)
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen


prop_isRedeemAddress :: Property
prop_isRedeemAddress =
H.withTests 2 . H.property $ do
addr <- H.forAll $ Gen.element
[ "Ae2tdPwUPEYycJ77DaXcWEdM3jaSBg2HgmK9jT1HmBzeLJ94x8mRw33xpBM"
, "Ae2tdPwUPEZ5bWquLHSYARmM5qgmCg1cjAPb7C4tVkRNQXN2BoX2Han8xKj"
, "Ae2tdPwUPEZMB92JqgxAEWfXJo6Ex7wWLoS7REmh81Ue6GgsNrDNs3MeQKA"
, "Ae2tdPwUPEZ43NhMYvw1bkcGnEzdDbm9QTWiRux6Xpy8sorgfSJfazneEsP"
]
fmap isRedeemAddress (fromCBORTextAddress addr) === Right True

-- -----------------------------------------------------------------------------

tests :: IO Bool
tests = H.checkParallel $$discover
4 changes: 3 additions & 1 deletion cardano-explorer-db/test/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import Hedgehog.Main (defaultMain)

import qualified Test.Property.Explorer.DB.Migration
import qualified Test.Property.Explorer.DB.Types
import qualified Test.Property.Upstream

main :: IO ()
main =
defaultMain
[ Test.Property.Explorer.DB.Migration.tests
[ Test.Property.Upstream.tests
, Test.Property.Explorer.DB.Migration.tests
, Test.Property.Explorer.DB.Types.tests
]

0 comments on commit 1a34709

Please sign in to comment.