Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase test coverage #98

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Cardano/Wallet/Binary/Packfile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ decodePackfile pf = case runGetOrFail getHeader pf of
Left e -> Left e
Right () -> case runGetOrFail getBlobs rest of
Left (_, _, msg) -> Left (BlobDecodeError msg)
Right ("", _, res) -> Right res
Right (_, _, _) -> Left (BlobDecodeError "Unconsumed data")
Right (_, _, res) -> Right res
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unreachable code.


data Header = Header !BS.ByteString !Int

Expand Down
6 changes: 5 additions & 1 deletion test/unit/Cardano/Wallet/Binary/PackfileSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ spec = do
let decoded = decodePackfile "\254CARDANOYOLO\NUL\NUL\NUL\SOH"
decoded `shouldBe` Left WrongFileTypeError

it "should ensure pack file version" $ do
it "should ensure pack file version is lesser" $ do
let decoded = decodePackfile "\254CARDANOPACK\NUL\NUL\NUL\2"
decoded `shouldBe` Left VersionTooNewError

it "should ensure pack file version is greater" $ do
let decoded = decodePackfile "\254CARDANOPACK\NUL\NUL\NUL\0"
decoded `shouldBe` Left VersionTooOldError

it "should decode an empty pack file" $ do
decodePackfile packFileHeader `shouldBe` Right []

Expand Down