smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.76k stars 2.9k forks source link

Lesson 6 - mainnet-fork-dev Testing Issue => brownie test --network mainnet-fork-dev - brownie.exceptions.VirtualMachineError: revert #1569

Closed tristanpeter closed 2 years ago

tristanpeter commented 2 years ago

Hi All, and thanks in advance for any assistance provided! I have searched through all the previous issues which may have been related, but I still cannot resolve the problem.

I am having an issues with Lesson 6, specifically with testing on mainnet-fork-dev when I run the command brownie test --network mainnet-fork-dev

I keep getting getting a failed test for test_can_fund_and_withdraw, and it seems to be pointing to this code (but I can't say if this is the problem or not, and I am pretty new to all of this):

def test_can_fund_and_withdraw(): account = get_account() fund_me = deploy_fund_me()

  entrance_fee = fund_me.getEntranceFee() + 100

In order to make sure I am indeed on mainnet-fork-dev I added the print statement print(f"The active network is {network.show_active()}") so that I can see if it working as expected on the correct network. However, I noticed that the Captured stdout call in the console prints the above print statement twice as follows (and the contract is being created successfully on Ganache):

The active network is mainnet-fork-dev The active network is mainnet-fork-dev Contract deployed to 0xF.............

I am attaching screenshots of my code for your reference console_output_2 deploy fund_and_withdraw helpful_scripts test_fund_me brownie_config console_output_1 FundMe.txt

tristanpeter commented 2 years ago

Hi All,

After hours of searching, this turned out to be a very simple issue which is detailed here: https://stackoverflow.com/questions/71472909/error-brownie-mainnet-fork-testing-brownie-exceptions-virtualmachineerror-reve Because I had a Ganache instance running, Brownie was automatically attaching to it, which is not the network I forked (mainnet-fork-dev). I simply had to close Ganache :)

Thanks all!!

tristanpeter commented 2 years ago

Closing this. Thanks