File tree Expand file tree Collapse file tree 2 files changed +69
-52
lines changed Expand file tree Collapse file tree 2 files changed +69
-52
lines changed Original file line number Diff line number Diff line change @@ -65,5 +65,72 @@ module.exports = [
65
65
receiveTimestamp : new Date ( "2017-08-31T06:17:32.066Z" ) ,
66
66
transmitTimestamp : new Date ( "2017-08-31T06:17:32.066Z" )
67
67
}
68
+ } ,
69
+ {
70
+ buffer : [
71
+ 28 ,
72
+ 1 ,
73
+ 48 ,
74
+ 234 ,
75
+ 0 ,
76
+ 0 ,
77
+ 0 ,
78
+ 0 ,
79
+ 0 ,
80
+ 0 ,
81
+ 0 ,
82
+ 70 ,
83
+ 80 ,
84
+ 84 ,
85
+ 66 ,
86
+ 0 ,
87
+ 221 ,
88
+ 81 ,
89
+ 98 ,
90
+ 144 ,
91
+ 122 ,
92
+ 240 ,
93
+ 131 ,
94
+ 160 ,
95
+ 48 ,
96
+ 48 ,
97
+ 48 ,
98
+ 48 ,
99
+ 48 ,
100
+ 48 ,
101
+ 48 ,
102
+ 10 ,
103
+ 221 ,
104
+ 81 ,
105
+ 98 ,
106
+ 150 ,
107
+ 72 ,
108
+ 91 ,
109
+ 119 ,
110
+ 135 ,
111
+ 221 ,
112
+ 81 ,
113
+ 98 ,
114
+ 150 ,
115
+ 72 ,
116
+ 95 ,
117
+ 235 ,
118
+ 26
119
+ ] ,
120
+ expected : {
121
+ leapIndicator : 0 ,
122
+ version : 3 ,
123
+ mode : 4 ,
124
+ stratum : 1 ,
125
+ poll : 48 ,
126
+ precision : 234 ,
127
+ rootDelay : new Date ( "1900-01-01T00:00:00.000Z" ) ,
128
+ rootDispersion : new Date ( "1900-01-01T00:00:00.001Z" ) ,
129
+ referenceId : "PTB" ,
130
+ referenceTimestamp : new Date ( "2017-08-30T16:13:04.480Z" ) ,
131
+ originTimestamp : new Date ( "1925-08-15T05:27:12.188Z" ) ,
132
+ receiveTimestamp : new Date ( "2017-08-30T16:13:10.282Z" ) ,
133
+ transmitTimestamp : new Date ( "2017-08-30T16:13:10.282Z" )
134
+ }
68
135
}
69
136
] ;
Original file line number Diff line number Diff line change @@ -4,56 +4,7 @@ import NtpPacketParser from "../index";
4
4
5
5
describe ( "NTP packet parser" , function ( ) {
6
6
describe ( "Structure" , function ( ) {
7
- const validPacket = new Buffer ( [
8
- 28 ,
9
- 1 ,
10
- 48 ,
11
- 234 ,
12
- 0 ,
13
- 0 ,
14
- 0 ,
15
- 0 ,
16
- 0 ,
17
- 0 ,
18
- 0 ,
19
- 70 ,
20
- 80 ,
21
- 84 ,
22
- 66 ,
23
- 0 ,
24
- 221 ,
25
- 81 ,
26
- 98 ,
27
- 144 ,
28
- 122 ,
29
- 240 ,
30
- 131 ,
31
- 160 ,
32
- 48 ,
33
- 48 ,
34
- 48 ,
35
- 48 ,
36
- 48 ,
37
- 48 ,
38
- 48 ,
39
- 10 ,
40
- 221 ,
41
- 81 ,
42
- 98 ,
43
- 150 ,
44
- 72 ,
45
- 91 ,
46
- 119 ,
47
- 135 ,
48
- 221 ,
49
- 81 ,
50
- 98 ,
51
- 150 ,
52
- 72 ,
53
- 95 ,
54
- 235 ,
55
- 26
56
- ] ) ;
7
+ const validPacket = require ( "./packets.valid" ) [ 0 ] . buffer ;
57
8
58
9
it ( "should parse without errors" , function ( ) {
59
10
NtpPacketParser . parse ( validPacket ) ;
@@ -153,15 +104,14 @@ describe("NTP packet parser", function() {
153
104
const validPackets = require ( "./packets.valid.js" ) ;
154
105
validPackets . forEach ( function ( packet ) {
155
106
describe ( "Parsing" , function ( ) {
156
- // generisch Buffer und Struct ableichen
157
107
const struct = NtpPacketParser . parse ( packet . buffer ) ;
158
108
159
109
for ( let key in packet . expected ) {
160
110
if ( ! packet . expected . hasOwnProperty ( key ) ) {
161
111
continue ;
162
112
}
163
113
164
- it ( "should have the propety " + key , function ( ) {
114
+ it ( "should have the property " + key , function ( ) {
165
115
assert . ok ( key in struct ) ;
166
116
} ) ;
167
117
You can’t perform that action at this time.
0 commit comments