basic test for whether message splitting works
This commit is contained in:
parent
ca383420a6
commit
6ed441403d
|
@ -22,7 +22,7 @@ import Hash2Pub.DHTProtocol
|
||||||
|
|
||||||
import Debug.Trace
|
import Debug.Trace
|
||||||
|
|
||||||
-- TODO: make this splitting function more intelligent, currently it creates many parts that are smaller than they could be
|
-- TODO: make this splitting function more intelligent, currently it creates many parts that are smaller than they could be, see #18
|
||||||
-- | Try splitting a payload into multiple parts to be able to reduce size of
|
-- | Try splitting a payload into multiple parts to be able to reduce size of
|
||||||
-- individual messages.
|
-- individual messages.
|
||||||
-- Only some kinds of payloads can be split, and only to a limited number of parts.
|
-- Only some kinds of payloads can be split, and only to a limited number of parts.
|
||||||
|
|
|
@ -228,8 +228,17 @@ spec = do
|
||||||
encodeDecodeAndCheck $ responseWith Leave lResPayload
|
encodeDecodeAndCheck $ responseWith Leave lResPayload
|
||||||
encodeDecodeAndCheck $ responseWith Stabilise stabResPayload
|
encodeDecodeAndCheck $ responseWith Stabilise stabResPayload
|
||||||
encodeDecodeAndCheck $ responseWith Ping pingResPayload
|
encodeDecodeAndCheck $ responseWith Ping pingResPayload
|
||||||
it "messages are encoded and decoded to ASN.1 DER properly" $ do
|
it "messages are encoded and decoded to ASN.1 DER properly" $
|
||||||
deserialiseMessage (head $ serialiseMessage 652 $ responseWith Ping pingResPayload) `shouldBe` Right (responseWith Ping pingResPayload)
|
deserialiseMessage (head $ serialiseMessage 652 $ responseWith Ping pingResPayload) `shouldBe` Right (responseWith Ping pingResPayload)
|
||||||
|
it "messages too large for a single packet can (often) be split into multiple parts" $ do
|
||||||
|
let largeMessage = responseWith Join $ JoinResponsePayload {
|
||||||
|
joinSuccessors = fromInteger <$> [-20..150]
|
||||||
|
, joinPredecessors = fromInteger <$> [5..11]
|
||||||
|
, joinCache = [ RemoteCacheEntry (exampleNodeState {nid = node}) 290001 | node <- [50602,506011..60000]]
|
||||||
|
}
|
||||||
|
-- TODO: once splitting works more efficient, test for exact number or payload, see #18
|
||||||
|
length (serialiseMessage 600 largeMessage) > 1 `shouldBe` True
|
||||||
|
length (serialiseMessage 6000 largeMessage) `shouldBe` 1
|
||||||
|
|
||||||
|
|
||||||
-- some example data
|
-- some example data
|
||||||
|
|
Loading…
Reference in a new issue