defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Set Contract Balance #147

Closed huseyindeniz closed 1 year ago

huseyindeniz commented 2 years ago

Hi all, first of all, thank you very much for this great repository. The number of lines in my tests has been cut in half thanks to this package. My question is, I checked the documents but can't see it. Is it possible to set the balance of the mock contract (not uint balanceOf someone, balance of the contract itself)? I'd like to test my withdraw function without helpers and set it directly with Smock but can't figure out how to do it.

0xGorilla commented 2 years ago

I'm glad Smock is helping with your tests!

Smock doesn't support setting the ether balance of a contract or an address, but I believe that can be easily achieved with hardhat hardhat_setBalance

huseyindeniz commented 2 years ago

Thanks for the explanation. I just wanted to make my tests shorter, but it's fine. Thanks again for this great package. Btw, I don't see any setBalance method of contract object in the hardhat environment. Could you give me an example? I had searched it many times before, and I just searched it again and found nothing.