postchain-client
Version:
Client library for accessing a Postchain node through REST.
35 lines • 2.56 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 { ChainConfirmationLevel } from "../../src/blockchainClient/enums";
import { UnexpectedStatusError } from "../../src/blockchainClient/errors";
import { getAnchoringClientAndSystemChainRid } from "../../src/blockchainClient/utils";
import { toString } from "../../src/formatter";
import { isBlockAnchored } from "../../src/ICCF/IccfProofTxMaterialBuilder";
import { mockSignatureProvider, unsignedTx } from "../common/mocks";
import { createClientToChromiaNetwork } from "../common/setups";
describe("isBlockAnchored", () => {
let client;
let systemClients;
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
client = yield createClientToChromiaNetwork();
systemClients = yield getAnchoringClientAndSystemChainRid(client);
}));
it("returns true if transaction is anchored", () => __awaiter(void 0, void 0, void 0, function* () {
const transactionReceipt = yield client.signAndSendUniqueTransaction(unsignedTx, mockSignatureProvider, true, undefined, ChainConfirmationLevel.SystemAnchoring);
const isBlockAnchoredResult = yield isBlockAnchored(client, systemClients.anchoringClient, transactionReceipt.transactionRid);
expect(isBlockAnchoredResult).toBe(true);
}));
it("throws a UnexpectedStatusError if transaction is not anchored", () => __awaiter(void 0, void 0, void 0, function* () {
const transactionReceipt = yield client.signAndSendUniqueTransaction(unsignedTx, mockSignatureProvider, false);
const isBlockAnchoredResult = isBlockAnchored(client, systemClients.anchoringClient, transactionReceipt.transactionRid);
yield expect(isBlockAnchoredResult).rejects.toThrow(new UnexpectedStatusError(404, `{"error":"Can't find transaction with RID: ${toString(transactionReceipt.transactionRid)}"}`));
}));
});
//# sourceMappingURL=isBlockAnchored.test.js.map