Permalink
Browse files

Fixed serialization order of sfixed64, fixes #536

  • Loading branch information...
dcodeIO committed Dec 10, 2016
1 parent 67449db commit 66be5983321dd06460382d045eb87ed72a186776

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN -3 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -324,7 +324,7 @@ WriterPrototype.fixed64 = function write_fixed64(value) {
*/
WriterPrototype.sfixed64 = function write_sfixed64(value) {
var bits = LongBits.from(value).zzEncode();
return this.push(writeFixed32, 4, bits.hi).push(writeFixed32, 4, bits.lo);
return this.push(writeFixed32, 4, bits.lo).push(writeFixed32, 4, bits.hi);
};
var writeFloat = typeof Float32Array !== 'undefined'
@@ -0,0 +1,38 @@
var tape = require("tape");
var protobuf = require("..");
tape.test("sfixed64 for grpc", function(test) {
var root = protobuf.Root.fromJSON({
nested: {
test: {
nested: {
Test: {
fields: {
int_64: {
type: 'sfixed64',
id: 1
}
}
}
}
}
}
});
var Test = root.lookup("test.Test");
var buffer = Test.encode({
int_64: '-9095674951825889465'
}).finish();
test.equal(buffer.length, 9, "should encode a total of 9 bytes");
test.equal(buffer[0], 9, "should encode id 1, wireType 1");
var decoded = Test.decode(buffer);
test.ok(decoded.int_64 == '-9095674951825889465', "should decode back the original value");
test.end();
});

0 comments on commit 66be598

Please sign in to comment.