This commit is contained in:
Evgeny Poberezkin
2024-01-08 18:52:55 +00:00
parent 58a188376b
commit cc2c1e0dae
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -924,7 +924,7 @@ pad msg paddedLen
pad' :: Builder -> Int -> Either CryptoError Builder
pad' msg paddedLen
| len <= maxMsgLen && padLen >= 0 = Right $ word16BE (fromIntegral len) <> msg <> byteString (B.replicate padLen '#')
| len <= maxMsgLen && padLen >= 0 = Right $ byteString (encodeWord16 $ fromIntegral len) <> msg <> byteString (B.replicate padLen '#')
| otherwise = Left CryptoLargeMsgError
where
len = fromIntegral $ LB.length $ toLazyByteString msg
+2 -2
View File
@@ -22,7 +22,7 @@ where
import Data.Attoparsec.ByteString.Char8 (Parser)
import qualified Data.Attoparsec.ByteString.Char8 as A
import Data.Bits (shiftL, shiftR, (.|.))
import Data.ByteString.Builder (Builder, lazyByteString, word16BE)
import Data.ByteString.Builder (Builder, byteString, lazyByteString, word16BE)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB
@@ -142,7 +142,7 @@ instance Encoding Large where
{-# INLINE smpP #-}
encodeLarge :: LB.ByteString -> Builder
encodeLarge s = word16BE (fromIntegral $ LB.length s) <> lazyByteString s
encodeLarge s = byteString (encodeWord16 $ fromIntegral $ LB.length s) <> lazyByteString s
{-# INLINE encodeLarge #-}
instance Encoding SystemTime where
+2 -1
View File
@@ -503,13 +503,14 @@ testNotificationsSMPRestartBatch :: Int -> ATransport -> APNSMockServer -> IO ()
testNotificationsSMPRestartBatch n t APNSMockServer {apnsQ} = do
a <- getSMPAgentClient' agentCfg initAgentServers2 testDB
b <- getSMPAgentClient' agentCfg initAgentServers2 testDB2
threadDelay 3000000
conns <- runServers $ do
liftIO $ print 1
conns <- replicateM (n :: Int) $ makeConnection a b
liftIO $ print 2
_ <- registerTestToken a "abcd" NMInstant apnsQ
liftIO $ print 3
liftIO $ threadDelay 1500000
liftIO $ threadDelay 3000000
liftIO $ print 4
forM_ (zip [0..] conns) $ \(i, (aliceId, bobId)) -> do
liftIO $ putStrLn $ "*** msg " <> show i