UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

39 lines 2.85 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 { AnchoringStatus, ChainConfirmationLevel } from "../../src/blockchainClient/enums"; import { getAnchoringClientAndSystemChainRid } from "../../src/blockchainClient/utils"; import { calculateBlockRID } from "../../src/ICCF/utils"; import { mockBuffer, mockSignatureProvider, unsignedTx } from "../common/mocks"; import { createClientToChromiaNetwork } from "../common/setups"; describe("getAnchoringStatusForBlockRid", () => { let client; let systemClients; beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { client = yield createClientToChromiaNetwork(); systemClients = yield getAnchoringClientAndSystemChainRid(client); })); it("returns AnchoringStatus NotAnchored with invalid blockRid", () => __awaiter(void 0, void 0, void 0, function* () { yield client.signAndSendUniqueTransaction(unsignedTx, mockSignatureProvider, false, undefined, ChainConfirmationLevel.None); const anchoringStatus = yield client.getAnchoringStatusForBlockRid(mockBuffer, systemClients.anchoringClient, systemClients.systemAnchoringChainBridString); expect(anchoringStatus).toEqual({ status: AnchoringStatus.NotAnchored }); }), 15000); it("returns AnchoringStatus SystemAnchored, clusterAnchoredTx and systemAnchoredTx", () => __awaiter(void 0, void 0, void 0, function* () { const transactionReceipt = yield client.signAndSendUniqueTransaction(unsignedTx, mockSignatureProvider, true, undefined, ChainConfirmationLevel.SystemAnchoring); const confirmationProof = yield client.getConfirmationProof(transactionReceipt.transactionRid); const blockRid = calculateBlockRID(confirmationProof, 1); const anchoringStatus = yield client.getAnchoringStatusForBlockRid(blockRid, systemClients.anchoringClient, systemClients.systemAnchoringChainBridString); expect(anchoringStatus).toEqual({ status: AnchoringStatus.SystemAnchored, clusterAnchoredTx: transactionReceipt.clusterAnchoredTx, systemAnchoredTx: transactionReceipt.systemAnchoredTx, }); })); }); //# sourceMappingURL=getAnchoringStatusForBlockRid.test.js.map