No transactions when running tests on anvil #5421
-
Hey there!I have an issue/question about running local tests on an anvil node. When I spin up a local anvil node and try to run my foundry tests there, I only see a couple of calls being made to the anvil node, however, there are no transactions being published or blocks being mined. If I try to deploy a contract to the node, I can successfully see the transaction being published, but when I run my foundry tests (which use foundyry cheatcodes), only RPC calls show up. My question: Is that expected behaviour? Are foundry tests when specifying I wanted to have a ethers/viem listener running to capture the transactions of my tests, which should run on the anvil node, but it seems like something like that is not possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
AFAIK |
Beta Was this translation helpful? Give feedback.
-
when you specifying --rpc-url, that means you are asking to run the test on node, you can get the rpc-url from alchemy.com for different network, you can see the transactions in the dashboard in the alchemy.com. |
Beta Was this translation helpful? Give feedback.
AFAIK
foundry test
does not execute its tests in the node, but rather, within its own local evm. I.e.,foundry test
is not "deploying" the test contracts themselves into the node. Instead it is using the node to get blockchain state from which to create an internal execution context to run the test. I'm still studying all the foundry source code so take what I just said with that in mind. Arguably, at some point in the future, foundry test could work by running the tests in the node, checkpointing & reverting the chain prior to each run of the test. I'm not clear on how much (if any) code duplication exists since both environments need to handle cheatcodes etc, but they probably share the…