Fix a couple of issues with the use of the Protobuf.js API

pull/10204/head
murgatroid99 8 years ago
parent c84d67e85b
commit f712ae76f4
  1. 4
      src/node/src/protobuf_js_6_common.js
  2. 2
      src/node/test/common_test.js

@ -77,11 +77,11 @@ exports.serializeCls = function serializeCls(cls) {
* @return {Buffer} The serialized object * @return {Buffer} The serialized object
*/ */
return function serialize(arg) { return function serialize(arg) {
var message = cls.fromObject(arg); var errMsg = cls.verify(arg);
var errMsg = cls.verify(message);
if (errMsg) { if (errMsg) {
throw Error(errMsg); throw Error(errMsg);
} }
var message = cls.create(arg);
return cls.encode(message).finish(); 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 test_message2 = {oneof_choice: 'string_choice', string_choice: 'abc'};
var serialized2 = oneofSerialize(test_message2); var serialized2 = oneofSerialize(test_message2);
var deserialized2 = oneofDeserialize(serialized2); 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() { describe('Proto message enum serialize and deserialize', function() {

Loading…
Cancel
Save