mirror of
https://github.com/ilyakooo0/secp256k1-haskell.git
synced 2024-09-11 12:25:38 +03:00
Parallel serialization test
This commit is contained in:
parent
5430374ace
commit
5c6bc5601e
@ -1,6 +1,7 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
module Crypto.Secp256k1Spec (spec) where
|
module Crypto.Secp256k1Spec (spec) where
|
||||||
|
|
||||||
|
import Control.Monad.Par
|
||||||
import qualified Control.Monad.Par as P
|
import qualified Control.Monad.Par as P
|
||||||
import Crypto.Secp256k1
|
import Crypto.Secp256k1
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
@ -27,8 +28,12 @@ spec = do
|
|||||||
describe "serialization" $ do
|
describe "serialization" $ do
|
||||||
it "serializes public key" $
|
it "serializes public key" $
|
||||||
property serializePubKeyTest
|
property serializePubKeyTest
|
||||||
|
it "serializes public keys in parallel" $
|
||||||
|
property parSerializePubKeyTest
|
||||||
it "serializes DER signature" $
|
it "serializes DER signature" $
|
||||||
property serializeSigTest
|
property serializeSigTest
|
||||||
|
it "serializes DER signatures in parallel" $
|
||||||
|
property parSerializeSigTest
|
||||||
it "serializes compact signature" $
|
it "serializes compact signature" $
|
||||||
property serializeCompactSigTest
|
property serializeCompactSigTest
|
||||||
it "serialize secret key" $
|
it "serialize secret key" $
|
||||||
@ -124,6 +129,11 @@ serializePubKeyTest (fp, b) =
|
|||||||
Just fp' -> fp == fp'
|
Just fp' -> fp == fp'
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
|
|
||||||
|
parSerializePubKeyTest :: [(PubKey, Bool)] -> Bool
|
||||||
|
parSerializePubKeyTest ps = runPar $ do
|
||||||
|
as <- mapM (spawnP . serializePubKeyTest) ps
|
||||||
|
and <$> mapM get as
|
||||||
|
|
||||||
serializeSigTest :: (Msg, SecKey) -> Bool
|
serializeSigTest :: (Msg, SecKey) -> Bool
|
||||||
serializeSigTest (fm, fk) =
|
serializeSigTest (fm, fk) =
|
||||||
case importSig $ exportSig fg of
|
case importSig $ exportSig fg of
|
||||||
@ -132,6 +142,11 @@ serializeSigTest (fm, fk) =
|
|||||||
where
|
where
|
||||||
fg = signMsg fk fm
|
fg = signMsg fk fm
|
||||||
|
|
||||||
|
parSerializeSigTest :: [(Msg, SecKey)] -> Bool
|
||||||
|
parSerializeSigTest ms = runPar $ do
|
||||||
|
as <- mapM (spawnP . serializeSigTest) ms
|
||||||
|
and <$> mapM get as
|
||||||
|
|
||||||
serializeCompactSigTest :: (Msg, SecKey) -> Bool
|
serializeCompactSigTest :: (Msg, SecKey) -> Bool
|
||||||
serializeCompactSigTest (fm, fk) =
|
serializeCompactSigTest (fm, fk) =
|
||||||
case importCompactSig $ exportCompactSig fg of
|
case importCompactSig $ exportCompactSig fg of
|
||||||
|
Loading…
Reference in New Issue
Block a user