postchain-client
Version:
Client library for accessing a Postchain node through REST.
42 lines • 2.6 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 { AnchoringStatus, ChainConfirmationLevel } from "../../src/blockchainClient/enums";
import { getAnchoringClientAndSystemChainRid } from "../../src/blockchainClient/utils";
import { mockSignatureProvider, unsignedTx } from "../common/mocks";
import { createClientToChromiaNetwork } from "../common/setups";
describe("getTransactionConfirmationLevel", () => {
let client;
let systemClients;
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {
client = yield createClientToChromiaNetwork();
systemClients = yield getAnchoringClientAndSystemChainRid(client);
}));
it("should get system anchoring chain 'systemAnchored' status and system anchored transaction", () => __awaiter(void 0, void 0, void 0, function* () {
const result = yield client.signAndSendUniqueTransaction(unsignedTx, mockSignatureProvider, true, undefined, ChainConfirmationLevel.SystemAnchoring);
let systemAnchoringConfirmation = null;
if (result.systemAnchoredTx !== undefined) {
systemAnchoringConfirmation = yield client.getTransactionConfirmationLevel(result.transactionRid);
}
else {
throw new Error("Expected systemAnchoredTx to be defined but it was undefined.");
}
const expectedResponse = {
status: AnchoringStatus.SystemAnchored,
statusCode: 200,
transactionRid: result.transactionRid,
clusterAnchoredTx: systemAnchoringConfirmation.clusterAnchoredTx,
clusterAnchoringClientBrid: systemClients.anchoringClient.config.blockchainRid,
systemAnchoredTx: systemAnchoringConfirmation.systemAnchoredTx,
systemAnchoringClientBrid: systemClients.systemAnchoringChainBridString,
};
expect(systemAnchoringConfirmation).toEqual(expectedResponse);
}));
});
//# sourceMappingURL=getTransactionConfirmationLevel.test.js.map