Skip to content

Commit

Permalink
Use right matchers in the reverted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fvictorio committed May 10, 2022
1 parent 0ac4e1e commit 7773251
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe("INTEGRATION: Reverted with", function () {
matchers.connect(signer).revertsWithoutReasonString({
gasLimit: 1_000_000,
})
).to.not.be.reverted
).to.not.be.revertedWith("some reason")
).to.be.eventually.rejectedWith(
ProviderError,
"sender doesn't have enough funds to send tx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ describe("INTEGRATION: Reverted with custom error", function () {
describe("invalid values", function () {
it("non-errors as subject", async function () {
await expect(
expect(Promise.reject({})).to.be.revertedWith("some reason")
expect(Promise.reject({})).to.be.revertedWithCustomError(
matchers,
"SomeCustomError"
)
).to.be.rejectedWith(AssertionError, "Expected an Error object");
});

Expand Down Expand Up @@ -347,7 +350,7 @@ describe("INTEGRATION: Reverted with custom error", function () {
matchers.connect(signer).revertsWithoutReasonString({
gasLimit: 1_000_000,
})
).to.not.be.reverted
).to.not.be.revertedWithCustomError(matchers, "SomeCustomError")
).to.be.eventually.rejectedWith(
ProviderError,
"sender doesn't have enough funds to send tx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe("INTEGRATION: Reverted with panic", function () {
matchers.connect(signer).revertsWithoutReasonString({
gasLimit: 1_000_000,
})
).to.not.be.reverted
).to.not.be.revertedWithPanic()
).to.be.eventually.rejectedWith(
ProviderError,
"sender doesn't have enough funds to send tx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ describe("INTEGRATION: Reverted without reason string", function () {
matchers,
method: "revertWithSomeCustomError",
successfulAssert: (x) =>
expect(x).to.not.be.revertedWith("some reason"),
expect(x).to.not.be.revertedWithoutReasonString(),
});
});

it("failed asserts", async function () {
await runFailedAsserts({
matchers,
method: "revertWithSomeCustomError",
failedAssert: (x) => expect(x).to.be.revertedWith("some reason"),
failedAssert: (x) => expect(x).to.be.revertedWithoutReasonString(),
failedAssertReason:
"Expected transaction to be reverted with reason 'some reason', but it reverted with a custom error",
"Expected transaction to be reverted without a reason string, but it reverted with a custom error",
});
});
});
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("INTEGRATION: Reverted without reason string", function () {
matchers.connect(signer).revertsWithoutReasonString({
gasLimit: 1_000_000,
})
).to.not.be.reverted
).to.not.be.revertedWithoutReasonString()
).to.be.eventually.rejectedWith(
ProviderError,
"sender doesn't have enough funds to send tx"
Expand Down

0 comments on commit 7773251

Please sign in to comment.