UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

41 lines 2.36 kB
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 { http, HttpResponse } from "msw"; import { server } from "../../../mocks/servers"; import { LOCAL_POOL, mockStringBlockchainRid } from "../../common/mocks"; import { MERKLE_HASH_VERSIONS } from "../../../src/utils/constants"; import { getTestsClient } from "../../common/setups"; let client; describe("Blockchain client tests with mocks", function () { beforeEach(function () { return __awaiter(this, void 0, void 0, function* () { server.listen(); }); }); it("should set the merkle hash version to 1", () => __awaiter(this, void 0, void 0, function* () { server.use(http.get(`${LOCAL_POOL}/config/${mockStringBlockchainRid}/features`, () => { return HttpResponse.json({ merkle_hash_version: MERKLE_HASH_VERSIONS.ONE }); })); client = yield getTestsClient({ merkleHashVersion: undefined }); expect(client.config.merkleHashVersion).toEqual(1); })); it("should set the merkle hash version to 2", () => __awaiter(this, void 0, void 0, function* () { server.use(http.get(`${LOCAL_POOL}/config/${mockStringBlockchainRid}/features`, () => { return HttpResponse.json({ merkle_hash_version: MERKLE_HASH_VERSIONS.TWO }); })); client = yield getTestsClient({ merkleHashVersion: undefined }); expect(client.config.merkleHashVersion).toEqual(2); })); it("merkle version set during client creation", () => __awaiter(this, void 0, void 0, function* () { client = yield getTestsClient({ merkleHashVersion: 3 }); expect(client.config.merkleHashVersion).toEqual(3); })); }); //# sourceMappingURL=setMerkleVersion.test.js.map