-
Notifications
You must be signed in to change notification settings - Fork 11
/
core-014-incoming-con-request.js
54 lines (46 loc) · 1.69 KB
/
core-014-incoming-con-request.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
Handle an unexpected CON request:
1. Client receives a request:
==============================================================================
Version | Type | Token Length | Code | Message ID
0 1 | 0 0 | 0 0 0 0 | 0 0 0 0 0 0 0 1 | 0x4321
1 | CON | 0 bytes | GET | 17185
------------------------------------------------------------------------------
Remote Endpoint: 127.0.0.1
------------------------------------------------------------------------------
Uri-Path: temperature
==============================================================================
2. Client sends a matching RST message:
==============================================================================
Version | Type | Token Length | Code | Message ID
0 1 | 1 1 | 0 0 0 0 | 0 0 0 0 0 0 0 0 | 0x4321
1 | RST | 0 bytes | Empty | 17185
------------------------------------------------------------------------------
Remote Endpoint: 127.0.0.1
==============================================================================
*/
'use strict';
var helpers = require('../helpers');
var Message = require(helpers.LIB_DIR).Message;
helpers.test(__filename, function(ctx)
{
var unexpectedRequest = {
type: Message.Type.CON,
code: Message.Code.GET,
id: 0x7d38,
token: new Buffer([]),
uri: '/temperature'
};
var expectedRstRequest = {
type: Message.Type.RST,
code: Message.Code.EMPTY,
id: unexpectedRequest.id
};
ctx.socket.scheduleResponse(50, unexpectedRequest);
ctx.socket.expectRequest(50, expectedRstRequest);
ctx.clock.tick(3600000);
return function assert()
{
ctx.socket.assert();
};
});