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

How to trace a code snippet? #47

Open
RLSoftwareDev opened this issue May 19, 2023 · 5 comments
Open

How to trace a code snippet? #47

RLSoftwareDev opened this issue May 19, 2023 · 5 comments

Comments

@RLSoftwareDev
Copy link

I was picking some random await someContract.someContractCall() to sandwich with hre.tracer.enabled=true/false and trace but still not getting anything.
Is it supposed to print something on console while running a test like npx hardhat test?
I can see the tracer object is working as console.log(hre.tracer._internal) prints something.

Feel like I'm missing something pretty basic. Would appreciate some help!

zemse added a commit that referenced this issue May 19, 2023
@zemse
Copy link
Owner

zemse commented May 19, 2023

Thanks for pointing this out, this should have ideally worked but it didn't because the default verbosity was set to 0. Just published [email protected] with the fix, you can update to it.

Without updating, the following prop can be added to the hh config.

tracer: {
  defaultVerbosity: 3,
},

@RLSoftwareDev
Copy link
Author

Thanks for getting back so quickly. With 2.3.1 everything is traced by default, even without the --trace flag. I tried playing around with defaultVerbosity both in hh config and in node_modules but didn't see any change.

@zemse
Copy link
Owner

zemse commented May 19, 2023

Ah :(

In the original case, i.e. with 2.3.0, npx hardhat test --trace should print the trace for sandwiched code snippet

zemse added a commit that referenced this issue May 19, 2023
@nishuzumi
Copy link

Same issue

@georgeroman
Copy link

One workaround for this is to run in all-traces mode (eg. npx hardhat test --trace) and wrap the code snippet for which you don't want traces (eg. hre.tracer.enabled = false; ...; hre.tracer.enabled = true;). It can be a bit inconvenient but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants