Serialisation test now also checks lazy bytestrings

This commit is contained in:
JP Rupp 2022-04-13 14:23:17 +01:00
parent 3129682e4d
commit 2a13ee8be2
No known key found for this signature in database
GPG Key ID: 93391726EAFA0C5D
6 changed files with 16 additions and 8 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.21.2
### Changed
- Serialisation test now works for both strict and lazy bytestrings.
## 0.21.1
### Changed
- Make Base58 faster.

View File

@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: haskoin-core
version: 0.21.1
version: 0.21.2
synopsis: Bitcoin & Bitcoin Cash library for Haskell
description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-core#readme>
category: Bitcoin, Finance, Network

View File

@ -1,5 +1,5 @@
name: haskoin-core
version: 0.21.1
version: 0.21.2
synopsis: Bitcoin & Bitcoin Cash library for Haskell
description: Please see the README on GitHub at <https://github.com/haskoin/haskoin-core#readme>
category: Bitcoin, Finance, Network

View File

@ -38,6 +38,7 @@ import qualified Data.Aeson.Encoding as A
import qualified Data.Aeson.Types as A
import Data.ByteString (ByteString, pack)
import qualified Data.ByteString.Short as BSS
import Data.ByteString.Lazy (fromStrict, toStrict)
import Data.Bytes.Get
import Data.Bytes.Put
import Data.Bytes.Serial
@ -138,8 +139,11 @@ testSerial ::
(Eq a, Show a, T.Typeable a, Serial a) => Gen a -> Spec
testSerial gen =
prop ("Binary encoding/decoding identity for " <> name) $
forAll gen $ \x ->
forAll gen $ \x -> do
(runGetL deserialize . runPutL . serialize) x `shouldBe` x
(runGetL deserialize . fromStrict . runPutS . serialize) x `shouldBe` x
(runGetS deserialize . runPutS . serialize) x `shouldBe` Right x
(runGetS deserialize . toStrict . runPutL . serialize) x `shouldBe` Right x
where
name = show $ T.typeRep $ proxy gen
proxy :: Gen a -> Proxy a

View File

@ -1,4 +1,4 @@
resolver: lts-18.18
resolver: lts-19.3
nix:
packages:
- secp256k1

View File

@ -6,7 +6,7 @@
packages: []
snapshots:
- completed:
size: 586296
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/18.yaml
sha256: 63539429076b7ebbab6daa7656cfb079393bf644971156dc349d7c0453694ac2
original: lts-18.18
size: 617368
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/3.yaml
sha256: a209d3455279ee76eb45f01f73bbb960ceaaa8dfad8891435384689df4dcb653
original: lts-19.3