diff --git a/lib/bech32/src/Codec/Binary/Bech32/Internal.hs b/lib/bech32/src/Codec/Binary/Bech32/Internal.hs index 540fd768d66..2650eba6caf 100644 --- a/lib/bech32/src/Codec/Binary/Bech32/Internal.hs +++ b/lib/bech32/src/Codec/Binary/Bech32/Internal.hs @@ -48,10 +48,11 @@ module Codec.Binary.Bech32.Internal , noPadding , yesPadding - -- * Character Set Manipulation + -- * Character Manipulation + , CharPosition (..) , charset - , word5ToChar , charToWord5 + , word5ToChar ) where diff --git a/lib/bech32/test/Codec/Binary/Bech32Spec.hs b/lib/bech32/test/Codec/Binary/Bech32Spec.hs index fe245638a01..270291bedef 100644 --- a/lib/bech32/test/Codec/Binary/Bech32Spec.hs +++ b/lib/bech32/test/Codec/Binary/Bech32Spec.hs @@ -12,7 +12,12 @@ module Codec.Binary.Bech32Spec import Prelude import Codec.Binary.Bech32.Internal - ( HumanReadablePart, humanReadablePartToBytes, mkHumanReadablePart ) + ( CharPosition (..) + , DecodingError (..) + , HumanReadablePart + , humanReadablePartToBytes + , mkHumanReadablePart + ) import Control.Monad ( forM_ ) import Data.Bits @@ -42,6 +47,7 @@ import Test.QuickCheck , property , vectorOf , (.&&.) + , (.||.) , (===) , (==>) ) @@ -154,9 +160,15 @@ spec = do return $ index /= separatorIndex ==> recombinedString /= validString ==> - (BS.length recombinedString === BS.length validString) - .&&. - (Bech32.decode recombinedString `shouldSatisfy` isLeft) + BS.length recombinedString == BS.length validString ==> ( + -- error location detection is best effort: + (Bech32.decode recombinedString `shouldBe` + Left (StringToDecodeContainsInvalidChars + [CharPosition index])) + .||. + (Bech32.decode recombinedString `shouldBe` + Left (StringToDecodeContainsInvalidChars [])) + ) it "Decoding fails for an upper-case string with a lower-case \ \character." $