mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Fix a couple of issues with the use of the Protobuf.js API
This commit is contained in:
parent
2ecbbe055c
commit
6924a20d4d
@ -77,11 +77,11 @@ exports.serializeCls = function serializeCls(cls) {
|
||||
* @return {Buffer} The serialized object
|
||||
*/
|
||||
return function serialize(arg) {
|
||||
var message = cls.fromObject(arg);
|
||||
var errMsg = cls.verify(message);
|
||||
var errMsg = cls.verify(arg);
|
||||
if (errMsg) {
|
||||
throw Error(errMsg);
|
||||
}
|
||||
var message = cls.create(arg);
|
||||
return cls.encode(message).finish();
|
||||
};
|
||||
};
|
||||
|
||||
@ -176,7 +176,7 @@ describe('Proto message oneof serialize and deserialize', function() {
|
||||
var test_message2 = {oneof_choice: 'string_choice', string_choice: 'abc'};
|
||||
var serialized2 = oneofSerialize(test_message2);
|
||||
var deserialized2 = oneofDeserialize(serialized2);
|
||||
assert.equal(deserialized2.oneof_choice, 'int_choice');
|
||||
assert.equal(deserialized2.oneof_choice, 'string_choice');
|
||||
});
|
||||
});
|
||||
describe('Proto message enum serialize and deserialize', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user