parse ASN.1 representation of load querying

includes tests
contributes to #71
This commit is contained in:
Trolli Schmittlauch 2020-09-18 01:33:31 +02:00
parent ddea599022
commit 41aaa8ff70
3 changed files with 59 additions and 0 deletions

View file

@ -221,6 +221,14 @@ spec = do
, exampleNodeState {nid = fromInteger (-5)}
]
}
qLoadReqPayload = LoadRequestPayload
{ loadLowerBound = fromInteger 12
, loadUpperBound = fromInteger 1025
}
qLoadResPayload = LoadResponsePayload
{ loadSum = 3.141
, loadRemainingTarget = -1.337
}
requestTemplate = Request {
requestID = 2342
, sender = exampleNodeState
@ -259,6 +267,8 @@ spec = do
encodeDecodeAndCheck $ responseWith Leave lResPayload
encodeDecodeAndCheck $ responseWith Stabilise stabResPayload
encodeDecodeAndCheck $ responseWith Ping pingResPayload
encodeDecodeAndCheck $ requestWith QueryLoad qLoadReqPayload
encodeDecodeAndCheck $ responseWith QueryLoad qLoadResPayload
it "messages are encoded and decoded to ASN.1 DER properly" $
deserialiseMessage (fromJust $ Map.lookup 1 (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