Skip to content

Commit

Permalink
A bit of formatting in the Handshake test module
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Apr 21, 2020
1 parent d7a068a commit f13157d
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,20 +550,36 @@ prop_pipe_asymmetric_IO (ArbitraryVersions clientVersions _serverVersions) =
--

instance Eq (AnyMessage (Handshake VersionNumber CBOR.Term)) where
AnyMessage (MsgProposeVersions vs) == AnyMessage (MsgProposeVersions vs') = vs == vs'
AnyMessage (MsgProposeVersions vs) == AnyMessage (MsgProposeVersions vs')
= vs == vs'

AnyMessage (MsgAcceptVersion vNumber vParams) == AnyMessage (MsgAcceptVersion vNumber' vParams')
= vNumber == vNumber' && vParams == vParams'
AnyMessage (MsgRefuse vReason) == AnyMessage (MsgRefuse vReason') = vReason == vReason'
_ == _ = False
= vNumber == vNumber' && vParams == vParams'

AnyMessage (MsgRefuse vReason) == AnyMessage (MsgRefuse vReason')
= vReason == vReason'

_ == _ = False

instance Show (AnyMessageAndAgency (Handshake VersionNumber CBOR.Term)) where
show (AnyMessageAndAgency _ msg) = show msg

instance Arbitrary (AnyMessageAndAgency (Handshake VersionNumber CBOR.Term)) where
arbitrary = oneof
[ AnyMessageAndAgency (ClientAgency TokPropose) . MsgProposeVersions . fmap (\(Sigma vData (Version _ (DictVersion codec))) -> encodeTerm codec vData) . getVersions <$> genVersions
, AnyMessageAndAgency (ServerAgency TokConfirm) . uncurry MsgAcceptVersion <$> genValidVersion'
, AnyMessageAndAgency (ServerAgency TokConfirm) . MsgRefuse . runArbitraryRefuseReason <$> arbitrary
[ AnyMessageAndAgency (ClientAgency TokPropose)
. MsgProposeVersions
. fmap (\(Sigma vData (Version _ (DictVersion codec))) -> encodeTerm codec vData)
. getVersions
<$> genVersions

, AnyMessageAndAgency (ServerAgency TokConfirm)
. uncurry MsgAcceptVersion
<$> genValidVersion'

, AnyMessageAndAgency (ServerAgency TokConfirm)
. MsgRefuse
. runArbitraryRefuseReason
<$> arbitrary
]
where
genValidVersion' :: Gen (VersionNumber, CBOR.Term)
Expand Down

0 comments on commit f13157d

Please sign in to comment.