Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(plugin-htlc-coordinator-besu): use Jest error assert in refund.test #3730

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
LogLevelDesc,
IListenOptions,
Servers,
LoggerProvider,
} from "@hyperledger/cactus-common";
import { PluginRegistry } from "@hyperledger/cactus-core";
import { Constants, PluginImportType } from "@hyperledger/cactus-core-api";
Expand All @@ -44,15 +43,9 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
import HashTimeLockJSON from "@hyperledger/cactus-plugin-htlc-eth-besu-erc20/src/main/solidity/contracts/HashedTimeLockContract.json";
import TestTokenJSON from "@hyperledger/cactus-test-plugin-htlc-eth-besu-erc20/src/test/solidity/token-erc20-contract/Test_Token.json";
import DemoHelperJSON from "@hyperledger/cactus-test-plugin-htlc-eth-besu-erc20/src/test/solidity/token-erc20-contract/DemoHelpers.json";
import axios from "axios";

describe("HTLC Coordinator Besu", () => {
const logLevel: LogLevelDesc = "DEBUG";
const log = LoggerProvider.getOrCreate({
label:
"plugin-htlc-coordinator-besu-plugin-htlc-coordinator/refund.test.ts",
level: logLevel,
});
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
Expand Down Expand Up @@ -312,22 +305,22 @@ describe("HTLC Coordinator Besu", () => {
gas: estimatedGas,
};
jagpreetsinghsasan marked this conversation as resolved.
Show resolved Hide resolved

try {
await htlcCoordinatorBesuApiClient.withdrawCounterpartyV1(
withdrawCounterparty,
);
} catch (exp: unknown) {
log.debug("Caught error as expected: %o", exp);
if (axios.isAxiosError(exp) && exp.response) {
log.debug("Caught response: %o", exp.response.data);
const revertReason = exp.response.data.cause.receipt.revertReason;
const regExp = new RegExp(/0e494e56414c49445f5345435245540/);
expect(revertReason).toMatch(regExp);
// t.match(revertReason, regExp, rejectMsg);
} else {
throw exp;
}
}
const withdrawCall =
htlcCoordinatorBesuApiClient.withdrawCounterpartyV1(withdrawCounterparty);

await expect(withdrawCall).rejects.toMatchObject({
response: expect.objectContaining({
data: expect.objectContaining({
cause: expect.objectContaining({
receipt: expect.objectContaining({
revertReason: expect.stringMatching(
/0e494e56414c49445f5345435245540/,
),
}),
}),
}),
}),
});

const responseFinalBalanceReceiver = await connector.invokeContract({
contractName: TestTokenJSON.contractName,
Expand Down
Loading