Fix binary serialization of Vector256

This commit is contained in:
Nicholas Dudfield
2014-02-01 11:02:10 +07:00
parent 23528293e0
commit b01c15847c
2 changed files with 7 additions and 1 deletions

View File

@@ -562,7 +562,7 @@ STPathSet.id = 18;
var STVector256 = exports.Vector256 = new SerializedType({
serialize: function (so, val) { //Assume val is an array of STHash256 objects.
var length_as_varint = SerializedType.serialize_varint(so, val.length);
var length_as_varint = SerializedType.serialize_varint(so, val.length * 32);
for (var i=0, l=val.length; i<l; i++) {
STHash256.serialize(so, val[i]);
}

View File

@@ -807,6 +807,12 @@ describe('Serialized types', function() {
"RootIndex": "000360186E008422E06B72D5B275E29EE3BE9D87A370F424E0E7BF613C465909"
}
assert.deepEqual(as_json, expected_json);
assert.throws(function () {
// This is an encoded reminder/TODO:
// Serializing ledger entries isn't currently supported, but when it
// is, this should no longer throw, and the test will fail
assert.strictEqual(SerializedObject.from_json(expected_json).to_hex(), hex);
})
});
it('Serialize empty object {}', function () {
var so = new SerializedObject();