UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

41 lines 2.5 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 { InvalidTxRidException } from "../../../src/blockchainClient/errors"; import { CONFIGURED_POLL_COUNT, mockAnchoringTransaction, mockBuffer, mockStringBlockchainRid, } from "../../common/mocks"; import * as utils from "../../../src/blockchainClient/utils"; import { getTestsClient } from "../../common/setups"; let client; describe("getSystemAnchoringTransactionConfirmation", () => { beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { client = yield getTestsClient({ dappStatusPolling: utils.setStatusPolling({ interval: 1000, count: CONFIGURED_POLL_COUNT, }), }); })); beforeEach(() => { jest.clearAllMocks(); }); afterEach(() => { jest.restoreAllMocks(); }); it("returns an InvalidTxRidException error with invalid anchoredTxRid", () => __awaiter(void 0, void 0, void 0, function* () { const invalidTxRid = Buffer.from("invalid"); yield expect(client.getSystemAnchoringTransactionConfirmation(invalidTxRid, client, mockStringBlockchainRid)).rejects.toBeInstanceOf(InvalidTxRidException); yield expect(client.getSystemAnchoringTransactionConfirmation(invalidTxRid, client, mockStringBlockchainRid)).rejects.toThrow("expected length 32 of txRID, but got 7"); })); it("returns a system anchoring transaction confirmation", () => __awaiter(void 0, void 0, void 0, function* () { jest.spyOn(utils, "getSystemAnchoringTransaction").mockResolvedValue(mockAnchoringTransaction); const result = yield client.getSystemAnchoringTransactionConfirmation(mockBuffer, client, mockStringBlockchainRid); expect(result).toEqual(mockAnchoringTransaction); })); }); //# sourceMappingURL=getSystemAnchoringTransactionConfirmation.test.js.map