This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree 2 files changed +17
-8
lines changed
test/tests/unit/wireprotocol/3_6
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,6 @@ const opcodes = require('../wireprotocol/shared').opcodes;
32
32
// Incrementing request id
33
33
let _requestId = 0 ;
34
34
35
- // Msg Flags
36
- const OPTS_CHECKSUM_PRESENT = 1 ;
37
- const OPTS_MORE_TO_COME = 2 ;
38
- const OPTS_EXHAUST_ALLOWED = 1 >> 16 ;
39
-
40
35
class Msg {
41
36
constructor ( bson , query , options ) {
42
37
// Basic options needed to be passed in
@@ -71,15 +66,15 @@ class Msg {
71
66
let flags = 0 ;
72
67
73
68
if ( this . checksumPresent ) {
74
- flags |= OPTS_CHECKSUM_PRESENT ;
69
+ flags |= Msg . flags . CHECKSUM_PRESENT ;
75
70
}
76
71
77
72
if ( this . moreToCome ) {
78
- flags |= OPTS_MORE_TO_COME ;
73
+ flags |= Msg . flags . MORE_TO_COME ;
79
74
}
80
75
81
76
if ( this . exhaustAllowed ) {
82
- flags |= OPTS_EXHAUST_ALLOWED ;
77
+ flags |= Msg . flags . EXHAUST_ALLOWED ;
83
78
}
84
79
85
80
const header = new Buffer (
@@ -169,6 +164,12 @@ Msg.getRequestId = function() {
169
164
return ++ _requestId ;
170
165
} ;
171
166
167
+ Msg . flags = {
168
+ CHECKSUM_PRESENT : 1 ,
169
+ MORE_TO_COME : 2 ,
170
+ EXHAUST_ALLOWED : 1 << 16
171
+ } ;
172
+
172
173
function writeInt32ListToUint8Buffer ( buffer , int32List , start ) {
173
174
let index = start || 0 ;
174
175
Original file line number Diff line number Diff line change @@ -156,5 +156,13 @@ describe('OP_MSG', function() {
156
156
} ) ;
157
157
} ) ;
158
158
159
+ it ( 'should properly reflect getMore flag in BSON' , function ( ) {
160
+ const msg = new Msg ( bson , { } , { moreToCome : true } ) ;
161
+ const buffers = msg . toBin ( ) ;
162
+ const parsedMessage = parseOpMsg ( buffers ) ;
163
+
164
+ expect ( parsedMessage ) . to . have . property ( 'flags' , Msg . flags . MORE_TO_COME ) ;
165
+ } ) ;
166
+
159
167
it . skip ( 'should properly serialize multiple commands' ) ;
160
168
} ) ;
You can’t perform that action at this time.
0 commit comments