mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-29 08:35:49 +00:00
Fix node 12 compatibility (#33)
The unit tests were comparing things of different types, which failed under the stricter checks.
This commit is contained in:
@@ -43,9 +43,6 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/ripple/ripple-binary-codec.git"
|
"url": "git://github.com/ripple/ripple-binary-codec.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0 <11.0.0"
|
|
||||||
},
|
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/ripple/ripple-binary-codec/issues"
|
"url": "https://github.com/ripple/ripple-binary-codec/issues"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ function basicApiTests() {
|
|||||||
assert(parser._buf instanceof Uint8Array);
|
assert(parser._buf instanceof Uint8Array);
|
||||||
const read1 = parser.read(1);
|
const read1 = parser.read(1);
|
||||||
assert(read1 instanceof Uint8Array);
|
assert(read1 instanceof Uint8Array);
|
||||||
assert.deepEqual(read1, [0]);
|
assert.deepEqual(read1, Uint8Array.from([0]));
|
||||||
assert.deepEqual(parser.read(4), [1, 2, 3, 4]);
|
assert.deepEqual(parser.read(4), Uint8Array.from([1, 2, 3, 4]));
|
||||||
assert.deepEqual(parser.read(2), [5, 6]);
|
assert.deepEqual(parser.read(2), Uint8Array.from([5, 6]));
|
||||||
assert.throws(() => parser.read(1));
|
assert.throws(() => parser.read(1));
|
||||||
});
|
});
|
||||||
it('can read a Uint32 at full', () => {
|
it('can read a Uint32 at full', () => {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function bytesListTest() {
|
|||||||
it('can join all arrays into one via toBytes', function() {
|
it('can join all arrays into one via toBytes', function() {
|
||||||
const joined = list.toBytes();
|
const joined = list.toBytes();
|
||||||
assert(joined.length, 5);
|
assert(joined.length, 5);
|
||||||
assert.deepEqual(joined, [0, 2, 3, 4, 5]);
|
assert.deepEqual(joined, Uint8Array.from([0, 2, 3, 4, 5]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ function UIntTest() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
serializer.writeType(type, n);
|
serializer.writeType(type, n);
|
||||||
assert.deepEqual(bl.toBytes(), expected);
|
assert.deepEqual(bl.toBytes(), Uint8Array.from(expected));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ describe('bytes-utils', function() {
|
|||||||
it('can decode hex to a Uint8Array', function() {
|
it('can decode hex to a Uint8Array', function() {
|
||||||
const result = parseBytes('0012', Uint8Array);
|
const result = parseBytes('0012', Uint8Array);
|
||||||
assert(result instanceof Uint8Array);
|
assert(result instanceof Uint8Array);
|
||||||
assert.deepEqual(result, [0x00, 0x12]);
|
assert.deepEqual(result, Uint8Array.from([0x00, 0x12]));
|
||||||
});
|
});
|
||||||
it('can convert a list to a Uint8Array', function() {
|
it('can convert a list to a Uint8Array', function() {
|
||||||
const result = parseBytes([0x00, 0x12], Uint8Array);
|
const result = parseBytes([0x00, 0x12], Uint8Array);
|
||||||
assert(result instanceof Uint8Array);
|
assert(result instanceof Uint8Array);
|
||||||
assert.deepEqual(result, [0x00, 0x12]);
|
assert.deepEqual(result, Uint8Array.from([0x00, 0x12]));
|
||||||
});
|
});
|
||||||
it('can decode hex to a Buffer', function() {
|
it('can decode hex to a Buffer', function() {
|
||||||
const result = parseBytes('0012', Buffer);
|
const result = parseBytes('0012', Buffer);
|
||||||
@@ -66,7 +66,7 @@ describe('bytes-utils', function() {
|
|||||||
});
|
});
|
||||||
it('the 4th arg is the output class type', function() {
|
it('the 4th arg is the output class type', function() {
|
||||||
assert.deepEqual(slice(val, 2, 4, Buffer).toJSON().data, [3, 4]);
|
assert.deepEqual(slice(val, 2, 4, Buffer).toJSON().data, [3, 4]);
|
||||||
assert.deepEqual(slice(val, 2, 4, Uint8Array), [3, 4]);
|
assert.deepEqual(slice(val, 2, 4, Uint8Array), Uint8Array.from([3, 4]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user