Closed bananlabs closed 2 years ago
I tried run my test for getEntranceFee function and got an error. I can't figure out whats going on here.
My test_lottery.py file :
from brownie import Lottery, accounts, config, network from web3 import Web3 def test_get_entrance_fee(): account = accounts[0] lottery = Lottery.deploy( config["networks"][network.show_active()]["eth_usd_price_feed"], {"from": account}, ) assert lottery.getEntranceFee() > Web3.toWei(0.018, "ether") assert lottery.getEntranceFee() < Web3.toWei(0.022, "ether")
my config file:
dependencies: - smartcontractkit/chainlink-brownie-contracts@1.1.1 compiler: solc: remappings: - "@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1" networks: mainnet-fork: eth_usd_price_feed: "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419"
output error:
__________________________________________ test_get_entrance_fee ___________________________________________ def test_get_entrance_fee(): account = accounts[0] lottery = Lottery.deploy( config["networks"][network.show_active()]["eth_usd_price_feed"], {"from": account}, ) > assert lottery.getEntranceFee() > Web3.toWei(0.018, "ether") tests\test_lottery.py:12: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ C:\Users\ssd\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\multicall.py:115: in _proxy_call result = ContractCall.__call__(*args, **kwargs) # type: ignore C:\Users\ssd\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1751: in __call__ return self.call(*args, block_identifier=block_identifier, override=override) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <ContractCall 'getEntranceFee()'>, block_identifier = None, override = None, args = () tx = {'allow_revert': None, 'data': '0x09bc33a7', 'from': '0x66aB6D9362d4F35596279692F0251Db635165871', 'gas': None, ...} def call( self, *args: Tuple, block_identifier: Union[int, str, bytes] = None, override: Dict = None ) -> Any: """ Call the contract method without broadcasting a transaction. Arguments --------- *args Contract method inputs. You can optionally provide a dictionary of transaction properties as the last arg. block_identifier : int | str | bytes, optional A block number or hash that the call is executed at. If not given, the latest block used. Raises `ValueError` if this value is too far in the past and you are not using an archival node. override : dict, optional A mapping from addresses to balance, nonce, code, state, stateDiff overrides for the context of the call. Returns ------- Contract method return value(s). """ args, tx = _get_tx(self._owner, args) if tx["from"]: tx["from"] = str(tx["from"]) del tx["required_confs"] tx.update({"to": self._address, "data": self.encode_input(*args)}) try: data = web3.eth.call({k: v for k, v in tx.items() if v}, block_identifier, override) except ValueError as e: > raise VirtualMachineError(e) from None E brownie.exceptions.VirtualMachineError: revert C:\Users\ssd\.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py:1542: VirtualMachineError ========================================= short test summary info ========================================== FAILED tests/test_lottery.py::test_get_entrance_fee - brownie.exceptions.VirtualMachineError: revert ============================================ 1 failed in 8.88s ============================================= Terminating local RPC client...
Could you ask on the main repo? Thanks!
https://github.com/smartcontractkit/full-blockchain-solidity-course-py
I tried run my test for getEntranceFee function and got an error. I can't figure out whats going on here.
My test_lottery.py file :
my config file:
output error: