Description
Hi When I try and run: 'brownie test' after creating the fund_and_withdraw.py test - I get the below error:
I copied the file from to make sure it was all entered correctly from:
https://github.com/PatrickAlphaC/brownie_fund_me/blob/main/scripts/fund_and_withdraw.py
Error
PS C:\Users\Tim\demos\brownie_fund_me> brownie test
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum
======================================================= test session starts =======================================================
platform win32 -- Python 3.9.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:\Users\Tim\demos\brownie_fund_me
plugins: eth-brownie-1.17.2, hypothesis-6.27.3, forked-1.3.0, xdist-1.34.0, web3-5.25.0
collected 1 item
Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
tests\test_fund_me.py F [100%]
============================================================ FAILURES =============================================================
___________________________________________________ test_can_fund_and_withdraw ____________________________________________________
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})
tests\test_fund_me.py:9:
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1629: in call
return self.transact(*args)
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1502: in transact
return tx["from"].transfer(
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py:682: in transfer
receipt._raise_if_reverted(exc)
self = <Transaction '0x6f471369c15376d4dbfed76376ba0b2618aba183624c39cef54164b0b6d9a886'>
exc = VirtualMachineError(ValueError({'message': 'VM Exception while processing transaction: revert You need to spend more E...core.node.cli.js:42:50915)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)', 'name': 'c'}}))
def _raise_if_reverted(self, exc: Any) -> None:
if self.status or CONFIG.mode == "console":
return
if not web3.supports_traces:
# if traces are not available, do not attempt to determine the revert reason
raise exc or ValueError("Execution reverted")
if self._dev_revert_msg is None:
# no revert message and unable to check dev string - have to get trace
self._expand_trace()
if self.contract_address:
source = ""
elif CONFIG.argv["revert"]:
source = self._traceback_string()
else:
source = self._error_string(1)
contract = state._find_contract(self.receiver)
if contract:
marker = "//" if contract._build["language"] == "Solidity" else "#"
line = self._traceback_string().split("\n")[-1]
if marker + " dev: " in line:
self._dev_revert_msg = line[line.index(marker) + len(marker) : -5].strip()
raise exc._with_attr(
source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
)
E brownie.exceptions.VirtualMachineError: revert: You need to spend more ETH!
E Trace step -1, program counter 1118:
E File "contracts/FundMe.sol", line 34, in FundMe.fund:
E // 18 digit number to be compared with donated amount
E uint256 minimumUSD = 50 * 10 ** 18;
E //is the donated amount less than 50USD?
E require(getConversionRate(msg.value) >= minimumUSD, "You need to spend more ETH!");
E //if not, add to mapping and funders array
E addressToAmountFunded[msg.sender] += msg.value;
E funders.push(msg.sender);
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\transaction.py:446: VirtualMachineError
------------------------------------------------------ Captured stdout call -------------------------------------------------------
The active network is development
Deploying Mocks...
Mocks Deployed...
Transaction sent: 0x6f471369c15376d4dbfed76376ba0b2618aba183624c39cef54164b0b6d9a886
===================================================== short test summary info =====================================================
FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - brownie.exceptions.VirtualMachineError: revert: You need to spend more...======================================================== 1 failed in 7.91s ========================================================
Terminating local RPC client...
PS C:\Users\Tim\demos\brownie_fund_me> brownie test
INFO: Could not find files for the given pattern(s).
Brownie v1.17.2 - Python development framework for Ethereum
======================================================= test session starts =======================================================
platform win32 -- Python 3.9.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:\Users\Tim\demos\brownie_fund_me
plugins: eth-brownie-1.17.2, hypothesis-6.27.3, forked-1.3.0, xdist-1.34.0, web3-5.25.0
collected 1 item
Launching 'ganache-cli.cmd --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
tests\test_fund_me.py F [100%]
============================================================ FAILURES =============================================================
___________________________________________________ test_can_fund_and_withdraw ____________________________________________________
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})
tests\test_fund_me.py:9:
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1629: in call
return self.transact(*args)
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1502: in transact
return tx["from"].transfer(
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py:682: in transfer
receipt._raise_if_reverted(exc)
self = <Transaction '0x6f471369c15376d4dbfed76376ba0b2618aba183624c39cef54164b0b6d9a886'>
exc = VirtualMachineError(ValueError({'message': 'VM Exception while processing transaction: revert You need to spend more E...core.node.cli.js:42:50915)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)', 'name': 'c'}}))
def _raise_if_reverted(self, exc: Any) -> None:
if self.status or CONFIG.mode == "console":
return
if not web3.supports_traces:
# if traces are not available, do not attempt to determine the revert reason
raise exc or ValueError("Execution reverted")
if self._dev_revert_msg is None:
# no revert message and unable to check dev string - have to get trace
self._expand_trace()
if self.contract_address:
source = ""
elif CONFIG.argv["revert"]:
source = self._traceback_string()
else:
source = self._error_string(1)
contract = state._find_contract(self.receiver)
if contract:
marker = "//" if contract._build["language"] == "Solidity" else "#"
line = self._traceback_string().split("\n")[-1]
if marker + " dev: " in line:
self._dev_revert_msg = line[line.index(marker) + len(marker) : -5].strip()
raise exc._with_attr(
source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
)
E brownie.exceptions.VirtualMachineError: revert: You need to spend more ETH!
E Trace step -1, program counter 1118:
E File "contracts/FundMe.sol", line 34, in FundMe.fund:
E // 18 digit number to be compared with donated amount
E uint256 minimumUSD = 50 * 10 ** 18;
E //is the donated amount less than 50USD?
E require(getConversionRate(msg.value) >= minimumUSD, "You need to spend more ETH!");
E //if not, add to mapping and funders array
E addressToAmountFunded[msg.sender] += msg.value;
E funders.push(msg.sender);
.....local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\transaction.py:446: VirtualMachineError
------------------------------------------------------ Captured stdout call -------------------------------------------------------
The active network is development
Deploying Mocks...
Mocks Deployed...
Transaction sent: 0x6f471369c15376d4dbfed76376ba0b2618aba183624c39cef54164b0b6d9a886
===================================================== short test summary info =====================================================
FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - brownie.exceptions.VirtualMachineError: revert: You need to spend more...======================================================== 1 failed in 7.88s ========================================================
Terminating local RPC client...
PS C:\Users\Tim\demos\brownie_fund_me>
below is screenshot from VSC: