Lesson 6: Test fails on mainnet-fork-dev #160
Answered
by
PatrickAlphaC
manukumar123
asked this question in
Q&A
-
When I run the test_fund_me.py script on mainnet-fork-dev from scripts.util_scripts import get_account, LOCAL_BLOCKCHAIN_ENVIRONMENTS
from scripts.deploy import deploy_fund_me
from brownie import network, accounts, exceptions
import pytest
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
def test_only_owner_can_withdraw():
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("Only for local testing")
account = get_account()
fund_me = deploy_fund_me()
bad_actor = accounts.add()
with pytest.raises(exceptions.VirtualMachineError):
fund_me.withdraw({"from": bad_actor}) I get a VirtualMachineError: revert issue:
I also cannot run the fund_and_withdraw script on mainnet-fork-dev from brownie import FundMe
from scripts.util_scripts import get_account
def fund():
fund_me = FundMe[-1]
account = get_account()
entrance_fee = fund_me.getEntranceFee()
print(f"The current entrance fee is {entrance_fee}")
print("Funding")
fund_me.fund({"from": account, "value": entrance_fee})
def withdraw():
fund_me = FundMe[-1]
account = get_account()
fund_me.withdraw({"from": account})
def main():
fund()
withdraw() ERROR
|
Beta Was this translation helpful? Give feedback.
Answered by
PatrickAlphaC
Oct 11, 2021
Replies: 1 comment
-
Thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
PatrickAlphaC
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IndexError: list index out of range
means you haven't deployed the contract yet. For this example / lesson, please skip running tests on the fork for now.Thank you!