postchain-client
Version:
Client library for accessing a Postchain node through REST.
34 lines • 2.36 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { toBuffer } from "../../../src/formatter";
import { gtvHash } from "../../../src/gtv";
describe("gtvHash", function () {
it("should return buffer when called with array containing a string and a buffer", () => __awaiter(this, void 0, void 0, function* () {
const result = gtvHash(["string", toBuffer("fghjkl")], 2);
expect(result).toBeInstanceOf(Buffer);
}));
it("test merkle hash version 2 on an array of an array of one", () => __awaiter(this, void 0, void 0, function* () {
const result = gtvHash([[1]], 2);
expect(result.toString("hex")).toEqual("082e13545dd8a1d4003143d17f781c9346bc500800592cd9b2d5d39dedf05415");
}));
it("test merkle hash version 1 on an array of an array of one", () => __awaiter(this, void 0, void 0, function* () {
const result = gtvHash([[1]], 1);
expect(result.toString("hex")).toEqual("67bb8d38054db41a4b401f5971ff7560e48a730693e46371191ecea9d7bd1e32");
}));
it("test merkle hash version 1 on an array of array with more than one element", () => __awaiter(this, void 0, void 0, function* () {
const result = gtvHash([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], 1);
expect(result.toString("hex")).toEqual("1591ba94eb98e3d60663c875aa6b566c2f57b6e818fc625eb654b2155d5c4374");
}));
it("test merkle hash version 2 on an array of array with more than one element", () => __awaiter(this, void 0, void 0, function* () {
const result = gtvHash([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], 2);
expect(result.toString("hex")).toEqual("d58d60705deb5ad92fe707c4e8131526dbcd8b7fb36827f8ce88da8ce3e566c0");
}));
});
//# sourceMappingURL=gtvHash.test.js.map