Skip to content

Commit

Permalink
fix: test plugin ledger connector besu exception handling and upgrade TS
Browse files Browse the repository at this point in the history
Fixes hyperledger#1747

Signed-off-by: Youngone Lee <youngone.lee@accenture.com>
  • Loading branch information
Leeyoungone committed Jan 11, 2022
1 parent 8dd17e9 commit 1c65e35
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { PluginRegistry } from "@hyperledger/cactus-core";

import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import axios from "axios";

const testCase = "Test sign transaction endpoint";
const logLevel: LogLevelDesc = "TRACE";
Expand Down Expand Up @@ -185,12 +186,16 @@ test(testCase, async (t: Test) => {
"0x46eac4d1d1ff81837698cbab38862a428ddf042f92855a72010de2771a7b704d",
};
await api.signTransactionV1(notFoundRequest);
} catch (error) {
t.equal(error.response.status, 404, "HTTP response status are equal");
t.equal(
error.response.statusText,
"Transaction not found",
"Response text are equal",
);
} catch (error: unknown) {
if (axios.isAxiosError(error)) {
t.equal(error.response?.status, 404, "HTTP response status are equal");
t.equal(
error.response?.statusText,
"Transaction not found",
"Response text are equal",
);
} else {
t.fail("expected an axios error, got something else");
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import { PluginRegistry } from "@hyperledger/cactus-core";

import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import axios from "axios";

const testCase = "Test sign transaction endpoint";
const logLevel: LogLevelDesc = "TRACE";
Expand Down Expand Up @@ -188,12 +189,16 @@ test(testCase, async (t: Test) => {
"0x46eac4d1d1ff81837698cbab38862a428ddf042f92855a72010de2771a7b704d",
};
await api.signTransactionV1(notFoundRequest);
} catch (error) {
t.equal(error.response.status, 404, "HTTP response status are equal");
t.equal(
error.response.statusText,
"Transaction not found",
"Response text are equal",
);
} catch (error: unknown) {
if (axios.isAxiosError(error)) {
t.equal(error.response?.status, 404, "HTTP response status are equal");
t.equal(
error.response?.statusText,
"Transaction not found",
"Response text are equal",
);
} else {
t.fail("expected an axios error, got something else");
}
}
});

0 comments on commit 1c65e35

Please sign in to comment.