diff --git a/test/unit/Cardano/Wallet/BinarySpec.hs b/test/unit/Cardano/Wallet/BinarySpec.hs index 22f9267ff07..d07860c03cc 100644 --- a/test/unit/Cardano/Wallet/BinarySpec.hs +++ b/test/unit/Cardano/Wallet/BinarySpec.hs @@ -27,8 +27,10 @@ import Data.ByteString ( ByteString ) import Data.ByteString.Base58 ( bitcoinAlphabet, decodeBase58 ) +import Data.Either + ( isLeft ) import Test.Hspec - ( Spec, describe, it, shouldBe ) + ( Spec, describe, it, shouldBe, shouldSatisfy ) import qualified Codec.CBOR.Decoding as CBOR import qualified Codec.CBOR.Read as CBOR @@ -61,6 +63,17 @@ spec = do let decoded = unsafeDeserialiseFromBytes decodeBlock bs decoded `shouldBe` block3 + it "should fail to decode a junk block" $ do + let junk = mconcat (replicate 100 "junk") + decoded = CBOR.deserialiseFromBytes decodeBlock junk + decoded `shouldSatisfy` isLeft + + it "should fail to decode a block with block header data" $ do + bs <- L8.readFile "test/data/Cardano/Wallet/BinarySpec-block-header-1" + let decoded = CBOR.deserialiseFromBytes decodeBlock bs + decoded `shouldBe` + Left (CBOR.DeserialiseFailure 3 "expected list of length 3") + describe "Encoding Tx" $ do let txs = Set.toList (transactions block2 <> transactions block3) let roundTripTx tx = do