Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

truffle test --debug hangs without starting the debugger #6163

Open
1 task done
aardvarkk opened this issue Aug 15, 2023 · 5 comments
Open
1 task done

truffle test --debug hangs without starting the debugger #6163

aardvarkk opened this issue Aug 15, 2023 · 5 comments

Comments

@aardvarkk
Copy link


Issue

When I try to use in-test debugging, it hangs my terminal. Ganache seems to show the contract getting deployed successfully, and the output from the truffle test command shows the contract getting successfully compiled.


> Artifacts written to /var/folders/4x/gnfwkbhn3dv7277cbcd0wjr80000gn/T/test--3627-470AjUBtVWpk
> Compiled successfully using:
   - solc: 0.8.21+commit.d9974bed.Emscripten.clang

However, then it just says "Contract: MyContract" and stalls. I can see pairs of calls to eth_getBlockByNumber being called about once per second in the ganache output. My contract

Steps to Reproduce

  • Create a brand new project created with the latest version of Truffle
  • Create a contract function (mine is a tokenURI function of the following form: function tokenURI(address creator, uint256 tokenId) external view returns (string memory);)
  • Add a test to call the tokenURI function in the contract, and wrap it in debug()

Expected Behavior

The debugger should start in the terminal when running truffle test --debug

Actual Results

The terminal hangs, showing only "Contract: MyContract".

Environment

  • Operating System: macOS (M2 Max)
  • Ethereum client: Ganache
  • Truffle version (truffle version): 5.11.2
  • node version (node --version): 18.17.2
  • npm version (npm --version): 8.19.4
@aardvarkk
Copy link
Author

aardvarkk commented Aug 16, 2023

For more context, I've started diving into the debugger a bit and it looks like it's stuck in the checkConfirmation function inside web3.js? It keeps getting called over and over and doesn't seem to resolve properly for some reason.

It looks like confirmationCount keeps having the value 2, and it maybe wants to equal method.transactionConfirmationBlocks + 1, which is 25. Every time the polling happens the values stay the same.

@gnidan
Copy link
Contributor

gnidan commented Aug 16, 2023

Hm, you can try disabling the confirmation listener. Not sure if that would make it work better or if it'd cause it to stop working altogether, but it's worth a shot :)

See docs here about how to specify disableConfirmationListener

@aardvarkk
Copy link
Author

aardvarkk commented Aug 18, 2023

@gnidan Well it changed the output a bit, but it's still hanging. Now when I inspect the ganache output I see a bit more "stuff":

eth_getTransactionReceipt
eth_getCode
evm_snapshot
Saved snapshot #1
net_version
eth_blockNumber
eth_getBlockByNumber
eth_call

Normally it'd just keep repeating the eth_getBlockByNumber until I set up the disableConfirmationListener. Now it actually tries to call it, but then the truffle test code just sits indefinitely as it did before.

@aardvarkk
Copy link
Author

I thought maybe this was a MacOS problem so I tried on my Linux machine with the exact same results.

@gnidan
Copy link
Contributor

gnidan commented Aug 24, 2023

Hm, really weird. How much gas does the eth_call require? It's possible that the hanging you're observing is just Ganache taking a long time to execute eth_call. This guess is a long shot.

Not sure what else might be going wrong here. Maybe you could try running truffle test --debug inside truffle console --verbose-rpc (while connecting to a separately running Ganache instance). That might give you a bit more detail.

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

No branches or pull requests

2 participants