Skip to content

Commit

Permalink
fix trace error mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Jul 9, 2024
1 parent 57df10f commit 7d3e4d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TracerWrapper extends ProviderWrapper {
isEthCall ||
isEstimateGas) &&
(!!this.dependencies.tracerEnv.printNext ||
this.dependencies.tracerEnv.verbosity > 2);
this.dependencies.tracerEnv.verbosity > 0);

if (shouldTrace) {
await this.dependencies.tracerEnv.switch!.enable();
Expand Down
20 changes: 20 additions & 0 deletions test/fixture-projects/hardhat-project/test/Hello.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ describe("Hello", () => {
}
});

it("should work for reverted", async () => {
const hello = await hre.ethers.getContractAt(
"Hello",
"0x0000000000000000000000000000001234567890",
wallet
);

try {
await hello.hi2(
[
{ id: 1, id2: 1 },
{ id: 2, id2: 1 },
],
{ value: parseEther("1") }
);
} catch {}

expect(!!hre.tracer.lastTrace()).to.be.true;
});

it("should ignore next", async () => {
console.log("========> hello.kick()");
const hello = await hre.ethers.getContractAt(
Expand Down
9 changes: 8 additions & 1 deletion test/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ describe("Hardhat Runtime Environment extension", function () {
// await this.hre.run("compile");
// });

it("test works", async function () {
it("test trace works", async function () {
await this.hre.run("compile");
await this.hre.run("test", {
trace: true,
});
});

it("test traceError works", async function () {
await this.hre.run("compile");
await this.hre.run("test", {
traceError: true,
});
});
});

describe("Trace task", function () {
Expand Down

0 comments on commit 7d3e4d2

Please sign in to comment.