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

refactor: Refactor negative test cases in refund.test to use Jest assertions #3464

Closed
Closed
Show file tree
Hide file tree
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 @@ -312,22 +312,24 @@ describe("HTLC Coordinator Besu", () => {
gas: estimatedGas,
};

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;
await expect(
htlcCoordinatorBesuApiClient.withdrawCounterpartyV1(withdrawCounterparty)
).rejects.toThrowErrorMatchingSnapshot();
Comment on lines +315 to +317
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Deepakchowdavarapu What does this additional assertion accomplish? Is this covering some edge case scenario that the other assertion does not?


await expect(
htlcCoordinatorBesuApiClient.withdrawCounterpartyV1(withdrawCounterparty)
).rejects.toThrow(expect.objectContaining({
response: {
data: {
cause: {
receipt: {
revertReason: expect.stringMatching(/0e494e56414c49445f5345435245540/)
}
}
}
}
}));

Comment on lines +315 to +332
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation to match the rest of the file


const responseFinalBalanceReceiver = await connector.invokeContract({
contractName: TestTokenJSON.contractName,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"@types/benchmark": "2.1.5",
"@types/debug": "4.1.12",
"@types/fs-extra": "11.0.4",
"@types/jest": "29.5.3",
"@types/jest": "29.5.12",
"@types/madge": "5.0.3",
"@types/node": "18.11.9",
"@types/node-fetch": "2.6.4",
Expand Down
Loading