Skip to content

Commit

Permalink
tx-submission: missing case in id codec
Browse files Browse the repository at this point in the history
Includes a test.
  • Loading branch information
coot committed Dec 11, 2020
1 parent daab7fc commit 5bdf2e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ tests =
, testProperty "connect 1" prop_connect1
, testProperty "connect 2" prop_connect2
, testProperty "codec" prop_codec
, testProperty "codec id" prop_codec_id
, testProperty "codec 2-splits" prop_codec_splits2
, testProperty "codec 3-splits" $ withMaxSuccess 30
prop_codec_splits3
Expand Down Expand Up @@ -324,6 +325,12 @@ prop_codec :: AnyMessageAndAgency (TxSubmission TxId Tx) -> Bool
prop_codec msg =
runST (prop_codecM codec msg)

-- | Check the codec round trip property for the id condec.
--
prop_codec_id :: AnyMessageAndAgency (TxSubmission TxId Tx) -> Bool
prop_codec_id msg =
runST (prop_codecM codecTxSubmissionId msg)

-- | Check for data chunk boundary problems in the codec using 2 chunks.
--
prop_codec_splits2 :: AnyMessageAndAgency (TxSubmission TxId Tx) -> Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ codecTxSubmissionId = Codec encode decode
decode stok = return $ DecodePartial $ \bytes -> return $ case (stok, bytes) of
(ServerAgency TokIdle, Just (AnyMessage msg@(MsgRequestTxIds {}))) -> DecodeDone (SomeMessage msg) Nothing
(ServerAgency TokIdle, Just (AnyMessage msg@(MsgRequestTxs {}))) -> DecodeDone (SomeMessage msg) Nothing
(ServerAgency TokIdle, Just (AnyMessage msg@(MsgKThxBye {}))) -> DecodeDone (SomeMessage msg) Nothing
(ClientAgency TokTxs, Just (AnyMessage msg@(MsgReplyTxs {}))) -> DecodeDone (SomeMessage msg) Nothing
(ClientAgency (TokTxIds b), Just (AnyMessage msg)) -> case (b, msg) of
(TokBlocking, MsgReplyTxIds (BlockingReply {})) -> DecodeDone (SomeMessage msg) Nothing
Expand Down

0 comments on commit 5bdf2e1

Please sign in to comment.