zemse / hardhat-tracer

🕵️ allows you to see internal calls, events and storage operations in the console
MIT License
353 stars 36 forks source link

"Hardhat Tracer wanted to print trace, but lastTrace is undefined." when using `--trace-error` #72

Closed fvictorio closed 2 months ago

fvictorio commented 3 months ago

Versions used:

Reproduction steps

Solidity file:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Foo {
    uint public x;

    function incBy(uint by) public {
        require(by > 0, "by must be positive");
        x += by;
    }
}

Test file:

const { expect } = require("chai");

describe("Foo", function () {
  it("test", async function () {
    const foo = await ethers.deployContract("Foo")

    await expect(foo.incBy(0)).to.be.reverted;
  });
});

Hardhat config:

require("@nomicfoundation/hardhat-toolbox");
require("hardhat-tracer");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.24",
};

Run npx hardhat test --trace-error. Curiously, --trace seems to work fine.

zemse commented 2 months ago

Thanks for reporting, I just pushed a commit and released 3.0.3. Does that fix this issue?

shark0der commented 2 months ago

I can confirm it fixed the issue. Thank you!

fvictorio commented 2 months ago

@shark0der was the one that pointed me to this problem, so I'm going to assume it's fixed. Thanks for the quick fix, @zemse!