-
Notifications
You must be signed in to change notification settings - Fork 405
Open
Description
In the video 5:53:30, try to use withdraw function with a bad_actor and get an browning.exceptions.VirtualMachineError: revert. But when I use brownie test -k test_only_owner_can_withdraw to test, the console gives this error message:
Brownie v1.19.3 - Python development framework for Ethereum
================================================================================================================= test session starts =================================================================================================================
platform win32 -- Python 3.10.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: E:\Smart_Contract_Python_Tutorial\brownie_fund_me
plugins: eth-brownie-1.19.3, anyio-3.6.2, hypothesis-6.27.3, forked-1.4.0, xdist-1.34.0, web3-5.31.3
collected 2 items / 1 deselected / 1 selected
Launching 'ganache-cli.cmd --chain.vmErrorsOnRPCResponse true --wallet.totalAccounts 10 --hardfork istanbul --miner.blockGasLimit 12000000 --wallet.mnemonic brownie --server.port 8545'...
tests\test_fund_me.py F [100%]
====================================================================================================================== FAILURES =======================================================================================================================
____________________________________________________________________________________________________________ test_only_owner_can_withdraw _____________________________________________________________________________________________________________
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()
print(bad_actor.balance())
> fund_me.withdraw({"from": bad_actor})
tests\test_fund_me.py:25:
and
The active network is development
Deploying Mocks...
Mocks Deployed!
Contract deployed to 0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6
mnemonic: 'calm junk spy run drink sadness govern crunch dish captain clip race'
0
=============================================================================================================== short test summary info ===============================================================================================================
FAILED tests/test_fund_me.py::test_only_owner_can_withdraw - ValueError: insufficient funds for gas * price + value
=========================================================================================================== 1 failed, 1 deselected in 7.79s ===========================================================================================================
Terminating local RPC client...
Here is my test_only_owner_can_withdraw() function:
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()
print(bad_actor.balance())
fund_me.withdraw({"from": bad_actor})
It seems that the account bad_actor does not have enough balance to send a tx, the print its balance is 0. And then raise this error. Why in the video there is not this error?
Metadata
Metadata
Assignees
Labels
No labels