|
@@ -1,23 +1,24 @@
|
|
-const Helpers = require("../../gramjs/Helpers");
|
|
|
|
|
|
+import bigInt from 'big-integer'
|
|
|
|
+import * as Helpers from '../../gramjs/Helpers';
|
|
|
|
|
|
describe("readBufferFromBigInt 8 bytes function", () => {
|
|
describe("readBufferFromBigInt 8 bytes function", () => {
|
|
test("it should return 0x20a13b25e1726bfc", () => {
|
|
test("it should return 0x20a13b25e1726bfc", () => {
|
|
- const input = BigInt("-257986242325798624");
|
|
|
|
|
|
+ const input = bigInt("-257986242325798624");
|
|
const output = Buffer.from("20a13b25e1726bfc", "hex");
|
|
const output = Buffer.from("20a13b25e1726bfc", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 8, true, true)).toEqual(output);
|
|
expect(Helpers.readBufferFromBigInt(input, 8, true, true)).toEqual(output);
|
|
});
|
|
});
|
|
test("it should return 0xe05ec4da1e8d9403", () => {
|
|
test("it should return 0xe05ec4da1e8d9403", () => {
|
|
- const input = BigInt("257986242325798624");
|
|
|
|
|
|
+ const input = bigInt("257986242325798624");
|
|
const output = Buffer.from("e05ec4da1e8d9403", "hex");
|
|
const output = Buffer.from("e05ec4da1e8d9403", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 8, true, false)).toEqual(output);
|
|
expect(Helpers.readBufferFromBigInt(input, 8, true, false)).toEqual(output);
|
|
});
|
|
});
|
|
test("it should return 0xfc6b72e1253ba120", () => {
|
|
test("it should return 0xfc6b72e1253ba120", () => {
|
|
- const input = BigInt("-257986242325798624");
|
|
|
|
|
|
+ const input = bigInt("-257986242325798624");
|
|
const output = Buffer.from("fc6b72e1253ba120", "hex");
|
|
const output = Buffer.from("fc6b72e1253ba120", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 8, false, true)).toEqual(output);
|
|
expect(Helpers.readBufferFromBigInt(input, 8, false, true)).toEqual(output);
|
|
});
|
|
});
|
|
test("it should return 0x03948d1edac45ee0", () => {
|
|
test("it should return 0x03948d1edac45ee0", () => {
|
|
- const input = BigInt("257986242325798624");
|
|
|
|
|
|
+ const input = bigInt("257986242325798624");
|
|
const output = Buffer.from("03948d1edac45ee0", "hex");
|
|
const output = Buffer.from("03948d1edac45ee0", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 8, false, false)).toEqual(
|
|
expect(Helpers.readBufferFromBigInt(input, 8, false, false)).toEqual(
|
|
output
|
|
output
|
|
@@ -27,26 +28,26 @@ describe("readBufferFromBigInt 8 bytes function", () => {
|
|
|
|
|
|
describe("readBufferFromBigInt 16 bytes function", () => {
|
|
describe("readBufferFromBigInt 16 bytes function", () => {
|
|
test("it should return 0x8416c07962dac053b4346df39e5d97ec", () => {
|
|
test("it should return 0x8416c07962dac053b4346df39e5d97ec", () => {
|
|
- const input = BigInt("-25798624232579862436622316998984984956");
|
|
|
|
|
|
+ const input = bigInt("-25798624232579862436622316998984984956");
|
|
const output = Buffer.from("8416c07962dac053b4346df39e5d97ec", "hex");
|
|
const output = Buffer.from("8416c07962dac053b4346df39e5d97ec", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 16, true, true)).toEqual(output);
|
|
expect(Helpers.readBufferFromBigInt(input, 16, true, true)).toEqual(output);
|
|
});
|
|
});
|
|
test("it should return 0x7ce93f869d253fac4bcb920c61a26813", () => {
|
|
test("it should return 0x7ce93f869d253fac4bcb920c61a26813", () => {
|
|
- const input = BigInt("25798624232579862436622316998984984956");
|
|
|
|
|
|
+ const input = bigInt("25798624232579862436622316998984984956");
|
|
const output = Buffer.from("7ce93f869d253fac4bcb920c61a26813", "hex");
|
|
const output = Buffer.from("7ce93f869d253fac4bcb920c61a26813", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 16, true, false)).toEqual(
|
|
expect(Helpers.readBufferFromBigInt(input, 16, true, false)).toEqual(
|
|
output
|
|
output
|
|
);
|
|
);
|
|
});
|
|
});
|
|
test("it should return 0xec975d9ef36d34b453c0da6279c01684", () => {
|
|
test("it should return 0xec975d9ef36d34b453c0da6279c01684", () => {
|
|
- const input = BigInt("-25798624232579862436622316998984984956");
|
|
|
|
|
|
+ const input = bigInt("-25798624232579862436622316998984984956");
|
|
const output = Buffer.from("ec975d9ef36d34b453c0da6279c01684", "hex");
|
|
const output = Buffer.from("ec975d9ef36d34b453c0da6279c01684", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 16, false, true)).toEqual(
|
|
expect(Helpers.readBufferFromBigInt(input, 16, false, true)).toEqual(
|
|
output
|
|
output
|
|
);
|
|
);
|
|
});
|
|
});
|
|
test("it should return 0x1368a2610c92cb4bac3f259d863fe97c", () => {
|
|
test("it should return 0x1368a2610c92cb4bac3f259d863fe97c", () => {
|
|
- const input = BigInt("25798624232579862436622316998984984956");
|
|
|
|
|
|
+ const input = bigInt("25798624232579862436622316998984984956");
|
|
const output = Buffer.from("1368a2610c92cb4bac3f259d863fe97c", "hex");
|
|
const output = Buffer.from("1368a2610c92cb4bac3f259d863fe97c", "hex");
|
|
expect(Helpers.readBufferFromBigInt(input, 16, false, false)).toEqual(
|
|
expect(Helpers.readBufferFromBigInt(input, 16, false, false)).toEqual(
|
|
output
|
|
output
|
|
@@ -56,7 +57,7 @@ describe("readBufferFromBigInt 16 bytes function", () => {
|
|
|
|
|
|
describe("readBufferFromBigInt 32 bytes function", () => {
|
|
describe("readBufferFromBigInt 32 bytes function", () => {
|
|
test("it should return 0x7f113f5e2096936ec90cc4c73cc7bd3c96d20c115bf9ceb05c34232c037ff6c6", () => {
|
|
test("it should return 0x7f113f5e2096936ec90cc4c73cc7bd3c96d20c115bf9ceb05c34232c037ff6c6", () => {
|
|
- const input = BigInt(
|
|
|
|
|
|
+ const input = bigInt(
|
|
"-25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
"-25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
);
|
|
);
|
|
const output = Buffer.from(
|
|
const output = Buffer.from(
|
|
@@ -66,7 +67,7 @@ describe("readBufferFromBigInt 32 bytes function", () => {
|
|
expect(Helpers.readBufferFromBigInt(input, 32, true, true)).toEqual(output);
|
|
expect(Helpers.readBufferFromBigInt(input, 32, true, true)).toEqual(output);
|
|
});
|
|
});
|
|
test("it should return 0x81eec0a1df696c9136f33b38c33842c3692df3eea406314fa3cbdcd3fc800939", () => {
|
|
test("it should return 0x81eec0a1df696c9136f33b38c33842c3692df3eea406314fa3cbdcd3fc800939", () => {
|
|
- const input = BigInt(
|
|
|
|
|
|
+ const input = bigInt(
|
|
"25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
"25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
);
|
|
);
|
|
const output = Buffer.from(
|
|
const output = Buffer.from(
|
|
@@ -78,7 +79,7 @@ describe("readBufferFromBigInt 32 bytes function", () => {
|
|
);
|
|
);
|
|
});
|
|
});
|
|
test("it should return 0xc6f67f032c23345cb0cef95b110cd2963cbdc73cc7c40cc96e9396205e3f117f", () => {
|
|
test("it should return 0xc6f67f032c23345cb0cef95b110cd2963cbdc73cc7c40cc96e9396205e3f117f", () => {
|
|
- const input = BigInt(
|
|
|
|
|
|
+ const input = bigInt(
|
|
"-25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
"-25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
);
|
|
);
|
|
const output = Buffer.from(
|
|
const output = Buffer.from(
|
|
@@ -90,7 +91,7 @@ describe("readBufferFromBigInt 32 bytes function", () => {
|
|
);
|
|
);
|
|
});
|
|
});
|
|
test("it should return 0x390980fcd3dccba34f3106a4eef32d69c34238c3383bf336916c69dfa1c0ee81", () => {
|
|
test("it should return 0x390980fcd3dccba34f3106a4eef32d69c34238c3383bf336916c69dfa1c0ee81", () => {
|
|
- const input = BigInt(
|
|
|
|
|
|
+ const input = bigInt(
|
|
"25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
"25798624232579862436622316998984984912345482145214526587420145210501554564737"
|
|
);
|
|
);
|
|
const output = Buffer.from(
|
|
const output = Buffer.from(
|