include target ID in request to address individual vserver
- necessary for dispatching the request to a certain vserver - also refactored request sending to use a common `mkRequest` - contributes to #2
This commit is contained in:
parent
5e745cd035
commit
9bf7365a2c
5 changed files with 42 additions and 60 deletions
|
@ -229,14 +229,7 @@ spec = do
|
|||
, loadRemainingTarget = -1.337
|
||||
, loadSegmentLowerBound = 12
|
||||
}
|
||||
requestTemplate = Request {
|
||||
requestID = 2342
|
||||
, sender = exampleNodeState
|
||||
, part = 1
|
||||
, isFinalPart = True
|
||||
, action = undefined
|
||||
, payload = undefined
|
||||
}
|
||||
|
||||
responseTemplate = Response {
|
||||
requestID = 2342
|
||||
, senderID = nid exampleNodeState
|
||||
|
@ -245,7 +238,7 @@ spec = do
|
|||
, action = undefined
|
||||
, payload = undefined
|
||||
}
|
||||
requestWith a pa = requestTemplate {action = a, payload = Just pa}
|
||||
requestWith senderNode a pa = mkRequest senderNode 4545 a (Just pa) $ 2342
|
||||
responseWith a pa = responseTemplate {action = a, payload = Just pa}
|
||||
|
||||
encodeDecodeAndCheck msg = runParseASN1 parseMessage (encodeMessage msg) `shouldBe` pure msg
|
||||
|
@ -256,18 +249,19 @@ spec = do
|
|||
}
|
||||
|
||||
it "messages are encoded and decoded correctly from and to ASN1" $ do
|
||||
encodeDecodeAndCheck $ requestWith QueryID qidReqPayload
|
||||
encodeDecodeAndCheck $ requestWith Join jReqPayload
|
||||
encodeDecodeAndCheck $ requestWith Leave lReqPayload
|
||||
encodeDecodeAndCheck $ requestWith Stabilise stabReqPayload
|
||||
encodeDecodeAndCheck $ requestWith Ping pingReqPayload
|
||||
localNS <- exampleLocalNode
|
||||
encodeDecodeAndCheck $ requestWith localNS QueryID qidReqPayload
|
||||
encodeDecodeAndCheck $ requestWith localNS Join jReqPayload
|
||||
encodeDecodeAndCheck $ requestWith localNS Leave lReqPayload
|
||||
encodeDecodeAndCheck $ requestWith localNS Stabilise stabReqPayload
|
||||
encodeDecodeAndCheck $ requestWith localNS Ping pingReqPayload
|
||||
encodeDecodeAndCheck $ requestWith localNS QueryLoad qLoadReqPayload
|
||||
encodeDecodeAndCheck $ responseWith QueryID qidResPayload1
|
||||
encodeDecodeAndCheck $ responseWith QueryID qidResPayload2
|
||||
encodeDecodeAndCheck $ responseWith Join jResPayload
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue