PatrickAlphaC / brownie_fund_me

26 stars 64 forks source link

Lesson 6: "FAILED test_fund_me.py::test_can_fun_and_withdraw #29

Closed Liam-Hughes closed 2 years ago

Liam-Hughes commented 2 years ago

After connecting to alchemy, everything worked fine up until this error.

Went through and checked and even copy pasted my code from the files on here.

Any ideas? I know it's going to be something stupid on my end. Here's my code: from scripts.helpful_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() + 100 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") fund_me = deploy_fund_me() bad_actor = accounts.add() with pytest.raises(exceptions.VirtualMachineError): fund_me.withdraw({"from": bad_actor})

Any and all help appreciated!

PatrickAlphaC commented 2 years ago

Could you ask in the main repo? Thanks! https://github.com/smartcontractkit/full-blockchain-solidity-course-py