How to trace a code snippet?
Opened this issue · 5 comments
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!
Thanks for pointing this out, this should have ideally worked but it didn't because the default verbosity was set to 0. Just published hardhat-tracer@2.3.1
with the fix, you can update to it.
Without updating, the following prop can be added to the hh config.
tracer: {
defaultVerbosity: 3,
},
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.
Ah :(
In the original case, i.e. with 2.3.0, npx hardhat test --trace
should print the trace for sandwiched code snippet
Same issue
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.