Development Environment: Foundry vs Hardhat/Truffle #55
-
In https://uniswapv3book.com/docs/introduction/dev-environment/#local-development-environment, you mention:
Is this true? What's the difference between a "node" and an "internal EVM" here? The "node" that Truffle and Hardhat node is definitely not a full ethereum client. I'm not sure there is much difference between hardhat network and Foundry's anvil. Both of them are "local devnets". If there is an actual difference, then your paragraph should be way more specific, as I feel it is misleading currently and is very foundry-biased. Otherwise very nice intro! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Forge doesn't run tests in Anvil, Hardhat does run tests in a local node. While it's not a full node, it's still slower than what Forge does. In Hardhat tests, calling a function of a contract means: sending a transaction to the local node; mining a block in the local node; processing the block and the transaction receipt. Also, since Hardhat is written in JS, its node uses a slow EVM implementation, which is also written in JS. Forge doesn't start a node when running tests. Instead, it executes tests in the same process, in an EVM implemented in Rust. So when you call a contract function in a Forge test, it doesn't send a transaction and doesn't mine a block. All tests are executed closer to the blockchain state and the EVM. And, yes, the paragraph and me are very Foundry-biased. |
Beta Was this translation helpful? Give feedback.
Forge doesn't run tests in Anvil, Hardhat does run tests in a local node. While it's not a full node, it's still slower than what Forge does. In Hardhat tests, calling a function of a contract means: sending a transaction to the local node; mining a block in the local node; processing the block and the transaction receipt. Also, since Hardhat is written in JS, its node uses a slow EVM implementation, which is also written in JS.
Forge doesn't start a node when running tests. Instead, it executes tests in the same process, in an EVM implemented in Rust. So when you call a contract function in a Forge test, it doesn't send a transaction and doesn't mine a block. All tests are executed close…