sean
@swabbie.eth
exp. with Foundry recently, and it's cool, but I'm a bit confused as to why testing in Solidity is preferred when it's highly likely interactions w/ your contract will need to use JS/TS anyway. 3P apps call your contract directly via frontend or they have a contract that calls your contract that itself uses a frontend
5 replies
0 recast
1 reaction
Varun Srinivasan
@v
Testing code written in one language using another language is a massive kludge (very rare that this happens, except maybe e2e tests) You introduce a lot of complexity at the boundary, translating objects from one language to another and back. That makes it hard to write good tests.
1 reply
0 recast
3 reactions
sean
@swabbie.eth
That makes sense, but since the goal of the contract is likely to often be called via a frontend, would it not also be wise to test via that use case? It seems poor practice to neglect an (often primary) interaction. In the past, my team has just written test contracts to test contract calls anyway, so both are tested
2 replies
0 recast
0 reaction
maurelian
@maurelian.eth
It feels to me like too are not separating concerns. You test your contracts in solidity to ensure security and correctness of the solidity. You test your js bindings and front end stuff with js. For that you should be able to use a mock ethers Contract even.
1 reply
0 recast
1 reaction
maurelian
@maurelian.eth
> the goal of the contract is likely to often be called via a frontend Hard disagree :) The goal of the contract is to uphold certain guarantees. It should not be tightly coupled with the front end at all, rather it should and likely will be used by multiple other frontends (ie. etherscan)
1 reply
0 recast
3 reactions
sean
@swabbie.eth
very true, but if (for example) javascript could not appropriately handle certain data types, the contract functions would need to consider that given the likelihood of a requestor operating in that environment. but in this case that would be very atypical, and I agree with your philosophy here.
0 reply
0 recast
0 reaction