Skip to content

Commit

Permalink
build(deps): upgrade to typescript v4.4
Browse files Browse the repository at this point in the history
Fixes #1129

Signed-off-by: Youngone Lee <youngone.lee@accenture.com>
  • Loading branch information
Leeyoungone committed Nov 16, 2021
1 parent 3d63b14 commit f674796
Show file tree
Hide file tree
Showing 163 changed files with 3,900 additions and 27,709 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
CarbonAccountingApp,
} from "./carbon-accounting-app";

import axios from "axios";
import { RuntimeError } from "run-time-error";

export async function launchApp(): Promise<void> {
const configService = new ConfigService();
const config = configService.getOrCreate();
Expand All @@ -19,10 +22,19 @@ export async function launchApp(): Promise<void> {
const carbonAccountingApp = new CarbonAccountingApp(appOptions);
try {
await carbonAccountingApp.start();
} catch (ex) {
console.error(`CarbonAccountingApp crashed. Existing...`, ex);
await carbonAccountingApp?.stop();
process.exit(-1);
} catch (ex: unknown) {
if (axios.isAxiosError(ex)) {
console.error(`CarbonAccountingApp crashed. Existing...`, ex);
await carbonAccountingApp?.stop();
process.exit(-1);
} else if (ex instanceof Error) {
throw new RuntimeError("unexpected exception", ex);
} else {
throw new RuntimeError(
"unexpected exception with incorrect type",
JSON.stringify(ex),
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
ICarbonAccountingFabricContractDeploymentInfo,
ICarbonAccountingXdaiContractDeploymentInfo,
} from "@hyperledger/cactus-example-carbon-accounting-business-logic-plugin";
import { RuntimeError } from "run-time-error";
import axios from "axios";

export interface ICarbonAccountingAppDummyInfrastructureOptions {
logLevel?: LogLevelDesc;
Expand Down Expand Up @@ -140,9 +142,18 @@ export class CarbonAccountingAppDummyInfrastructure {
this.fabric.stop().then(() => this.fabric.destroy()),
]);
this.log.info(`Stopped OK`);
} catch (ex) {
this.log.error(`Stopping crashed: `, ex);
throw ex;
} catch (ex: unknown) {
if (axios.isAxiosError(ex)) {
this.log.error(`Stopping crashed: `, ex);
throw ex;
} else if (ex instanceof Error) {
throw new RuntimeError("unexpected exception", ex);
} else {
throw new RuntimeError(
"unexpected exception with incorrect type",
JSON.stringify(ex),
);
}
}
}

Expand All @@ -151,9 +162,18 @@ export class CarbonAccountingAppDummyInfrastructure {
this.log.info(`Starting dummy infrastructure...`);
await Promise.all([this.xdai.start(), this.fabric.start()]);
this.log.info(`Started dummy infrastructure OK`);
} catch (ex) {
this.log.error(`Starting of dummy infrastructure crashed: `, ex);
throw ex;
} catch (ex: unknown) {
if (axios.isAxiosError(ex)) {
this.log.error(`Starting of dummy infrastructure crashed: `, ex);
throw ex;
} else if (ex instanceof Error) {
throw new RuntimeError("unexpected exception", ex);
} else {
throw new RuntimeError(
"unexpected exception with incorrect type",
JSON.stringify(ex),
);
}
}
}

Expand Down Expand Up @@ -360,9 +380,18 @@ export class CarbonAccountingAppDummyInfrastructure {
channelName: channelId,
},
};
} catch (ex) {
this.log.error(`Deployment of smart contracts crashed: `, ex);
throw ex;
} catch (ex: unknown) {
if (axios.isAxiosError(ex)) {
this.log.error(`Deployment of smart contracts crashed: `, ex);
throw ex;
} else if (ex instanceof Error) {
throw new RuntimeError("unexpected exception", ex);
} else {
throw new RuntimeError(
"unexpected exception with incorrect type",
JSON.stringify(ex),
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import expressJwt from "express-jwt";
import { v4 as uuidv4 } from "uuid";
import { JWK, JWT } from "jose";
import { StatusCodes } from "http-status-codes";
import axios from "axios";

import {
AuthorizationProtocol,
Expand All @@ -30,6 +31,7 @@ import {
CarbonAccountingApp,
ICarbonAccountingAppOptions,
} from "../../../main/typescript/carbon-accounting-app";
import { RuntimeError } from "run-time-error";

const testCase = "can enroll new admin users onto the Fabric org";
const logLevel: LogLevelDesc = "TRACE";
Expand Down Expand Up @@ -157,17 +159,24 @@ test.skip(testCase, async (t: Test) => {
try {
await apiClientBad.enrollAdminV1({ orgName: "does-not-matter" });
t.fail("enroll admin response status === 403 FAIL");
} catch (out) {
t.ok(out, "error thrown for forbidden endpoint truthy OK");
t.ok(out.response, "enroll admin response truthy OK");
t.equal(
out.response.status,
StatusCodes.FORBIDDEN,
"enroll admin response status === 403 OK",
);
t.notok(out.response.data.data, "out.response.data.data falsy OK");
t.notok(out.response.data.success, "out.response.data.success falsy OK");
} catch (out: unknown) {
if (!out) {
const errorMessage = `out is falsy`;
throw new RuntimeError(errorMessage);
}
if (axios.isAxiosError(out)) {
t.ok(out, "error thrown for forbidden endpoint truthy OK");
t.ok(out.response, "enroll admin response truthy OK");
t.equal(
out.response?.status,
StatusCodes.FORBIDDEN,
"enroll admin response status === 403 OK",
);
t.notok(out.response?.data.data, "out.response.data.data falsy OK");
t.notok(out.response?.data.success, "out.response.data.success falsy OK");
} else {
t.fail("expected an axios error, got something else");
}
}

t.end();
});
Loading

0 comments on commit f674796

Please sign in to comment.