test_fund_me.py returns AttributeError: 'NoneType' object has no attribute 'getEntranceFee' #1750
Answered
by
cromewar
klovertexarkana
asked this question in
Q&A
-
I keep getting the above error. Prior to that testing returns: The active network is development So it appear that my deploy script is working fine and I haven't had any issues deploying to development, ganache-local, or Goerli. Here is test_fund_me.py: from scripts.helpful_scripts import get_account
from scripts.deploy import deploy_fund_me
def test_can_fund_and_withdraw():
account = get_account()
fund_me = deploy_fund_me()
entrance_fee = fund_me.getEntranceFee()
tx = fund_me.fund({'from': account, 'value': entrance_fee})
tx.wait(1)
assert fund_me.addressToAmountFunded(account.address) == entrance_fee
tx2 = fund_me.withdraw({'from': account})
tx2.wait(1)
assert fund_me.addressToAmountFunded(account.address) == 0
Here is my deploy.py:
from brownie import network, FundMe, MockV3Aggregator, config
from scripts.helpful_scripts import get_account, deploy_mocks, LOCAL_BLOCKCHAIN_ENVIRONMENTS
def deploy_fund_me():
account = get_account()
# need to pass appropriate price feed address to the .deploy() method
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
price_feed_address = config['networks'][network.show_active()]['eth_usd_price_feed']
else:
deploy_mocks()
price_feed_address = MockV3Aggregator[-1].address
fund_me = FundMe.deploy(price_feed_address, {'from': account},
publish_source=config['networks'][network.show_active()].get('verify'))
print(f'Contract deployed to {fund_me.address}')
def main():
deploy_fund_me() |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Oct 17, 2022
Replies: 1 comment 4 replies
-
Hello @klovertexarkana this might happen to several reasons.
I hope any of this info might help. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
cromewar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @klovertexarkana this might happen to several reasons.
getEntranceFee
to ensure the contract was deployed.getEntranceFee
? may be there is a typo causing the problem.I hope any of this info might help.