|
| 1 | +{-# LANGUAGE NoImplicitPrelude #-} |
| 2 | +{-# LANGUAGE OverloadedStrings #-} |
| 3 | +{-# LANGUAGE TemplateHaskell #-} |
| 4 | + |
| 5 | +module Test.Pos.Ssc.Json |
| 6 | + ( tests |
| 7 | + ) where |
| 8 | +import Universum |
| 9 | + |
| 10 | +import qualified Cardano.Crypto.Wallet as CC |
| 11 | +import Hedgehog (Property) |
| 12 | +import qualified Hedgehog as H |
| 13 | +import Pos.Crypto.Hashing (abstractHash) |
| 14 | +import Pos.Crypto.Signing (PublicKey (..)) |
| 15 | +import Pos.Security.Params (AttackTarget (..)) |
| 16 | +import Test.Pos.Ssc.Gen (genAttackTarget) |
| 17 | +import Test.Pos.Util.Golden (discoverGolden, eachOf, goldenTestJSON) |
| 18 | +import Test.Pos.Util.Tripping (discoverRoundTrip, roundTripsAesonShow) |
| 19 | + |
| 20 | +------------------------------------------------------------------------------- |
| 21 | +-- AttackTarget |
| 22 | +------------------------------------------------------------------------------- |
| 23 | +golden_AttackTarget_NetworkAddressTarget :: Property |
| 24 | +golden_AttackTarget_NetworkAddressTarget = |
| 25 | + goldenTestJSON exampleAttackTarget_NetworkAddressTarget |
| 26 | + "test/golden/AttackTarget_NetworkAddressTarget" |
| 27 | + where |
| 28 | + exampleAttackTarget_NetworkAddressTarget = |
| 29 | + NetworkAddressTarget ("ggv", 32313) |
| 30 | + |
| 31 | + |
| 32 | +golden_AttackTarget_PubKeyAddressTarget :: Property |
| 33 | +golden_AttackTarget_PubKeyAddressTarget = |
| 34 | + goldenTestJSON exampleAttackTarget_PubKeyAddressTarget |
| 35 | + "test/golden/AttackTarget_PubKeyAddressTarget" |
| 36 | + |
| 37 | +exampleAttackTarget_PubKeyAddressTarget :: AttackTarget |
| 38 | +exampleAttackTarget_PubKeyAddressTarget = |
| 39 | + PubKeyAddressTarget |
| 40 | + $ abstractHash (PublicKey (CC.XPub {CC.xpubPublicKey = pubKey1 |
| 41 | + , CC.xpubChaincode = CC.ChainCode "Test"})) |
| 42 | + where |
| 43 | + pubKey1 = "\145\&3\131kUF\226\131\253M\174\157;w>\156k" |
| 44 | + |
| 45 | +roundTripAttackTarget :: Property |
| 46 | +roundTripAttackTarget = |
| 47 | + eachOf 1000 genAttackTarget roundTripsAesonShow |
| 48 | + |
| 49 | +------------------------------------------------------------------------------- |
| 50 | +-- Main test export |
| 51 | +------------------------------------------------------------------------------- |
| 52 | + |
| 53 | +tests :: IO Bool |
| 54 | +tests = (&&) <$> H.checkSequential $$discoverGolden |
| 55 | + <*> H.checkParallel $$discoverRoundTrip |
0 commit comments