mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-31 05:25:49 +00:00
* agent: include server address string into BROKER errors * eol Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
29 lines
1.0 KiB
Haskell
29 lines
1.0 KiB
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
module CoreTests.ProtocolErrorTests where
|
|
|
|
import qualified Data.ByteString.Char8 as B
|
|
import qualified Data.Text as T
|
|
import Data.Text.Encoding (encodeUtf8)
|
|
import Simplex.Messaging.Agent.Protocol (AgentErrorType (..))
|
|
import Simplex.Messaging.Encoding.String
|
|
import Simplex.Messaging.Parsers (parseAll)
|
|
import Test.Hspec
|
|
import Test.Hspec.QuickCheck (modifyMaxSuccess)
|
|
import Test.QuickCheck
|
|
|
|
protocolErrorTests :: Spec
|
|
protocolErrorTests = modifyMaxSuccess (const 1000) $ do
|
|
describe "errors parsing / serializing" $ do
|
|
it "should parse SMP protocol errors" . property $ \(err :: AgentErrorType) ->
|
|
errServerHasSpaces err
|
|
|| parseAll strP (strEncode err) == Right err
|
|
it "should parse SMP agent errors" . property $ \(err :: AgentErrorType) ->
|
|
errServerHasSpaces err
|
|
|| parseAll strP (strEncode err) == Right err
|
|
where
|
|
errServerHasSpaces = \case
|
|
BROKER srv _ -> ' ' `B.elem` encodeUtf8 (T.pack srv)
|
|
_ -> False
|