Compare commits
No commits in common. "db5a694e7d15e1e423864aad8240f6ef61684cae" and "47e3cf71cbace77b592906f086174af176b09191" have entirely different histories.
db5a694e7d
...
47e3cf71cb
3 changed files with 12 additions and 51 deletions
|
@ -81,7 +81,6 @@ data CoinType
|
|||
= MainNetCoin
|
||||
| TestNetCoin
|
||||
| RegTestNetCoin
|
||||
deriving (Eq, Prelude.Show, Ord)
|
||||
|
||||
getValue :: CoinType -> Word32
|
||||
getValue c =
|
||||
|
|
60
test/Spec.hs
60
test/Spec.hs
|
@ -17,7 +17,6 @@
|
|||
|
||||
-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TypeSynonymInstances #-}
|
||||
|
||||
import C.Zcash (rustWrapperUADecode)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
|
@ -35,8 +34,6 @@ import qualified Data.Text.Lazy.IO as LTIO
|
|||
import Data.Word
|
||||
import GHC.Float.RealFracMethods (properFractionDoubleInteger)
|
||||
import Test.Hspec
|
||||
import Test.Hspec.QuickCheck
|
||||
import Test.QuickCheck
|
||||
import ZcashHaskell.Keys (generateWalletSeedPhrase, getWalletSeed)
|
||||
import ZcashHaskell.Orchard
|
||||
import ZcashHaskell.Sapling
|
||||
|
@ -52,7 +49,6 @@ import ZcashHaskell.Types
|
|||
, CoinType(..)
|
||||
, DecodedNote(..)
|
||||
, OrchardAction(..)
|
||||
, Phrase(..)
|
||||
, RawData(..)
|
||||
, RawTxResponse(..)
|
||||
, ShieldedOutput(..)
|
||||
|
@ -452,12 +448,18 @@ main = do
|
|||
msg `shouldBe`
|
||||
"Hello World!\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NU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L\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL"
|
||||
describe "Wallet seed phrase" $ do
|
||||
prop "Generated phrases are valid" prop_PhraseLength
|
||||
prop "Derived seeds are valid" prop_SeedLength
|
||||
prop "Orchard spending keys are valid" $
|
||||
forAll genOrcArgs $ \(c, i, _) -> prop_OrchardSpendingKey c i
|
||||
prop "Orchard receivers are valid" $
|
||||
forAll genOrcArgs $ \(c, i, j) -> prop_OrchardReceiver c i j
|
||||
it "Generate phrase" $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
BS.length p `shouldNotBe` 0
|
||||
it "Derive seed" $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
let s = getWalletSeed p
|
||||
maybe 0 BS.length s `shouldBe` 64
|
||||
it "Generate Orchard spending key" $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
let s = getWalletSeed p
|
||||
genOrchardSpendingKey (fromMaybe "" s) MainNetCoin 1 `shouldNotBe`
|
||||
Nothing
|
||||
describe "Address tests" $ do
|
||||
it "Encode transparent" $ do
|
||||
let ua =
|
||||
|
@ -467,41 +469,3 @@ main = do
|
|||
Nothing -> "Bad UA"
|
||||
Just u -> maybe "No transparent" encodeTransparent $ t_rec u
|
||||
msg `shouldBe` "t1LPWuQnjCRH7JAeEErSXKixcUteLJRJjKD"
|
||||
|
||||
-- | Properties
|
||||
prop_PhraseLength :: Int -> Property
|
||||
prop_PhraseLength i =
|
||||
ioProperty $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
return $ BS.length p >= 95
|
||||
|
||||
prop_SeedLength :: Int -> Property
|
||||
prop_SeedLength i =
|
||||
ioProperty $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
let s = getWalletSeed p
|
||||
return $ maybe 0 BS.length s === 64
|
||||
|
||||
prop_OrchardSpendingKey :: CoinType -> Int -> Property
|
||||
prop_OrchardSpendingKey c i =
|
||||
ioProperty $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
let s = getWalletSeed p
|
||||
return $ genOrchardSpendingKey (fromMaybe "" s) c i =/= Nothing
|
||||
|
||||
prop_OrchardReceiver :: CoinType -> Int -> Int -> Property
|
||||
prop_OrchardReceiver c i j =
|
||||
ioProperty $ do
|
||||
p <- generateWalletSeedPhrase
|
||||
let s = getWalletSeed p
|
||||
let sk = genOrchardSpendingKey (fromMaybe "" s) c i
|
||||
return $ genOrchardReceiver j (fromMaybe "" sk) =/= Nothing
|
||||
|
||||
-- | Generators
|
||||
genOrcArgs :: Gen (CoinType, Int, Int)
|
||||
genOrcArgs = do
|
||||
i <- arbitrarySizedNatural
|
||||
j <- arbitrarySizedNatural
|
||||
c <- elements [MainNetCoin, TestNetCoin, RegTestNetCoin]
|
||||
return (c, i, j)
|
||||
-- | Arbitrary instances
|
||||
|
|
|
@ -72,8 +72,6 @@ test-suite zcash-haskell-test
|
|||
, haskoin-core
|
||||
, hexstring
|
||||
, hspec
|
||||
, QuickCheck
|
||||
, quickcheck-transformer
|
||||
, text
|
||||
, zcash-haskell
|
||||
pkgconfig-depends: rustzcash_wrapper
|
||||
|
|
Loading…
Reference in a new issue