-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
I am attempting to achieve 100% test coverage of the NftMarketplace.sol contract and I have one line left to test.
This one: https://github.com/PatrickAlphaC/hardhat-nft-marketplace-fcc/blob/1a7e27a9e7a9a22c0045b05f4fb2d49552a7e185/contracts/NftMarketplace.sol#L206C74-L206C74
I need a way to get this line to return false.
This issue on stack exchange describes how to get the .call{} to fail by calling it from a contract (TestHelper.sol) that cannot receive funds. This is nearly the answer to my problem accept for an issue...
The withdrawProceeds() function in NftMarketplace.sol requires msg.sender to have a balance greater than 0 in the s_proceeds mapping mapped to the address being used to call withdrawProceeds().
Is there a way to give TestHelper a balance in s_proceeds using waffle/chai/ethers/hardhat?
In previous tests, the process to fund an account was:
- Have account A list an nft
- Have account B buy the nft (this funds
s_proceeds[A.address])
I have been unsuccessful in having TestHelper:
- mint a token
- list a token
- approve a token on the marketplace
So, the process of listing withTestHelperand buying with account B doesn't work to funds_proceeds[TestHelper.address].
Perhaps there's another way to test this line that doesn't involve all of this, but I don't know what it is. Any advice is welcome.
Thank you!