add qc test for phashDatum
This commit is contained in:
parent
044a4d03b5
commit
530829fa65
3 changed files with 43 additions and 2 deletions
39
agora-specs/Property/Utils.hs
Normal file
39
agora-specs/Property/Utils.hs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
module Property.Utils (props) where
|
||||||
|
|
||||||
|
import Agora.Utils (phashDatum)
|
||||||
|
import Cardano.Prelude (ByteString)
|
||||||
|
import Plutarch.Api.V2 (datumHash)
|
||||||
|
import Plutarch.Test.QuickCheck (
|
||||||
|
Equality (OnPEq),
|
||||||
|
Partiality (ByComplete),
|
||||||
|
haskEquiv',
|
||||||
|
)
|
||||||
|
import Plutarch.Test.QuickCheck.Instances ()
|
||||||
|
import PlutusCore.Data (Data (B))
|
||||||
|
import PlutusLedgerApi.V1 (Datum (Datum))
|
||||||
|
import PlutusLedgerApi.V2 (BuiltinData (BuiltinData), DatumHash)
|
||||||
|
import Test.Tasty (TestTree, adjustOption)
|
||||||
|
import Test.Tasty.QuickCheck (
|
||||||
|
Property,
|
||||||
|
QuickCheckTests,
|
||||||
|
testProperty,
|
||||||
|
)
|
||||||
|
|
||||||
|
propHashDatumCorrect :: Property
|
||||||
|
propHashDatumCorrect =
|
||||||
|
haskEquiv'
|
||||||
|
@'OnPEq
|
||||||
|
@'ByComplete
|
||||||
|
hashDatum
|
||||||
|
phashDatum
|
||||||
|
where
|
||||||
|
hashDatum :: ByteString -> DatumHash
|
||||||
|
hashDatum = datumHash . Datum . BuiltinData . B
|
||||||
|
|
||||||
|
props :: [TestTree]
|
||||||
|
props =
|
||||||
|
[ adjustOption go $ testProperty "Correct 'phashDatum'" propHashDatumCorrect
|
||||||
|
]
|
||||||
|
where
|
||||||
|
go :: QuickCheckTests -> QuickCheckTests
|
||||||
|
go = max 20_000
|
||||||
|
|
@ -7,7 +7,8 @@ Tests for utility functions in 'Agora.Utils'.
|
||||||
-}
|
-}
|
||||||
module Spec.Utils (tests) where
|
module Spec.Utils (tests) where
|
||||||
|
|
||||||
import Test.Tasty (TestTree)
|
import Property.Utils qualified as Props
|
||||||
|
import Test.Tasty (TestTree, testGroup)
|
||||||
|
|
||||||
tests :: [TestTree]
|
tests :: [TestTree]
|
||||||
tests = []
|
tests = [testGroup "properties" Props.props]
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,7 @@ library agora-specs
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Property.Generator
|
Property.Generator
|
||||||
Property.Governor
|
Property.Governor
|
||||||
|
Property.Utils
|
||||||
Sample.AuthorityToken.UnauthorizedMintingExploit
|
Sample.AuthorityToken.UnauthorizedMintingExploit
|
||||||
Sample.Effect.GovernorMutation
|
Sample.Effect.GovernorMutation
|
||||||
Sample.Effect.TreasuryWithdrawal
|
Sample.Effect.TreasuryWithdrawal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue