Lesson 15: NftMarketplace.sol - help with test for withdrawProceeds()
#5909
Unanswered
Spencer-Sch
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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 requiresmsg.sender
to have a balance greater than 0 in thes_proceeds
mapping mapped to the address being used to callwithdrawProceeds()
.Is there a way to give
TestHelper
a balance ins_proceeds
using waffle/chai/ethers/hardhat?In previous tests, the process to fund an account was:
s_proceeds[A.address]
)I have been unsuccessful in having
TestHelper
:So, the process of listing with
TestHelper
and 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!
Beta Was this translation helpful? Give feedback.
All reactions