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, testing getting stuck in terminal after running brownie test #567

Open WeTheArtist opened 2 years ago

WeTheArtist commented 2 years ago

image

I got a popup from windows firewall when i ran brownie test, i accepted and allowed, but after this it is stuck at this screenshot. Earlier I was getting 2500000 instead of 25000000000000000 so i made uint256 precision = 1 * 10**28; in FundMe.sol, which made running the deploy.sol and fund_and_withdraw function ok. So not sure if that has anything to do with the terminal getting stuck( then i used cltr+c to quit.

WeTheArtist commented 2 years ago

I have another issue now, After reinstalling ganache I was able to make it run, but now a different error

PS D:\Python projects\Solidity dev\demo\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.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: D:\Python projects\Solidity dev\demo\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

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py:774: KeyboardInterrupt (to show a full traceback on KeyboardInterrupt use --full-trace) ====================================================================================== no tests ran in 48.26s ====================================================================================== Terminating local RPC client... PS D:\Python projects\Solidity dev\demo\brownie_fund_me>

Session contents restored from 14/12/2021 at 22:01:18

Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\Python projects\Solidity dev\demo\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.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: D:\Python projects\Solidity dev\demo\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'...

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! KeyboardInterrupt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py:774: KeyboardInterrupt (to show a full traceback on KeyboardInterrupt use --full-trace) Terminating local RPC client... PS D:\Python projects\Solidity dev\demo\brownie_fund_me> npm uninstall ganache@alpha --global

up to date, audited 1 package in 688ms

found 0 vulnerabilities PS D:\Python projects\Solidity dev\demo\brownie_fund_me> npm install -g ganache-cli npm ERR! code EEXIST npm ERR! path C:\Users\rosne\AppData\Roaming\npm\ganache-cli.cmd npm ERR! EEXIST: file already exists npm ERR! File exists: C:\Users\rosne\AppData\Roaming\npm\ganache-cli.cmd npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\rosne\AppData\Local\npm-cache_logs\2021-12-15T19_58_49_032Z-debug.log PS D:\Python projects\Solidity dev\demo\brownie_fund_me> npm install -g ganache-cli --global npm ERR! code EEXIST npm ERR! path C:\Users\rosne\AppData\Roaming\npm\ganache-cli
npm ERR! EEXIST: file already exists npm ERR! File exists: C:\Users\rosne\AppData\Roaming\npm\ganache-cli npm ERR! Remove the existing file and try again, or run npm npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\rosne\AppData\Local\npm-cache_logs\2021-12-15T20_00_01_081Z-debug.log PS D:\Python projects\Solidity dev\demo\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.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: D:\Python projects\Solidity dev\demo\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'... INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages_pytest\main.py", line 269, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages_pytest\main.py", line 322, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages_pytest\main.py", line 333, in pytest_collection INTERNALERROR> session.perform_collect() INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages_pytest\main.py", line 641, in perform_collect INTERNALERROR> hook.pytest_collection_finish(session=self) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_hooks.py", line 265, in call INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\pluggy_callers.py", line 55, in _multicall INTERNALERROR> gen.send(outcome) INTERNALERROR> brownie.network.connect(CONFIG.argv["network"]) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\main.py", line 50, in connect INTERNALERROR> rpc.launch(active["cmd"], active["cmd_settings"]) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\rpc__init__.py", line 75, in launch INTERNALERROR> self.process = self.backend.launch(cmd, kwargs) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\rpc\ganache.py", line 73, in launch INTERNALERROR> return psutil.Popen(cmd_list, stdin=DEVNULL, stdout=out, stderr=out) INTERNALERROR> File "C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\psutil__init.py", line 1312, in init INTERNALERROR> self.subproc = subprocess.Popen(args, **kwargs) INTERNALERROR> File "C:\Program Files\Python39\lib\subprocess.py", line 951, in init INTERNALERROR> self._execute_child(args, executable, preexec_fn, close_fds, INTERNALERROR> File "C:\Program Files\Python39\lib\subprocess.py", line 1420, in _execute_child INTERNALERROR> hp, ht, pid, tid = _winapi.CreateProcess(executable, args, INTERNALERROR> FileNotFoundError: [WinError 2] The system cannot find the file specified

====================================================================================== no tests ran in 4.20s ======================================================================================= PS D:\Python projects\Solidity dev\demo\brownie_fund_me> npm install -g ganache-cli

added 1 package, and audited 5 packages in 9s

found 0 vulnerabilities PS D:\Python projects\Solidity dev\demo\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.7, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 rootdir: D:\Python projects\Solidity dev\demo\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:11:


C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\contract.py:1629: in call return self.transact(*args) C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\contract.py:1502: in transact return tx["from"].transfer( C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py:644: in transfer receipt, exc = self._make_transaction( C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py:752: in _make_transaction exc = VirtualMachineError(e)


self = VirtualMachineError(ValueError({'message': "sender doesn't have enough funds to send tx. The upfront cost is: 25000000...ode.cli.js:55:2006575)\n at processTicksAndRejections (node:intern al/process/task_queues:96:5)", 'name': 'Error'}})) exc = {'code': -32000, 'data': {'name': 'Error', 'stack': "Error: sender doesn't have enough funds to send tx. The upfront c...to send tx. The upfront cost is: 250000000000000000000000000 and the s ender's account only has: 100000000000000000000"}

def __init__(self, exc: ValueError) -> None:
    try:
        exc = exc.args[0]
    except Exception:
        pass

    if isinstance(exc, dict) and "message" in exc:
        if "data" not in exc:
            raise ValueError(exc["message"]) from None

        self.message: str = exc["message"].rstrip(".")

        if isinstance(exc["data"], str):
            # handle parity exceptions - this logic probably is not perfect
            if "0x08c379a0" in exc["data"]:
                revert_type, err_msg = [i.strip() for i in exc["data"].split("0x08c379a0", 1)]
                err_msg = eth_abi.decode_abi(["string"], HexBytes(err_msg))
                err_msg = f"{revert_type} '{err_msg}'"
            elif exc["data"].endswith("0x"):
                err_msg = exc["data"][:-2].strip()
            else:
                err_msg = exc["data"]
            raise ValueError(f"{self.message}: {err_msg}") from None

        try:
            txid, data = next((k, v) for k, v in exc["data"].items() if k.startswith("0x"))
        except StopIteration:
          raise ValueError(exc["message"]) from None

E ValueError: sender doesn't have enough funds to send tx. The upfront cost is: 250000000000000000000000000 and the sender's account only has: 100000000000000000000

C:\Users\rosne\AppData\Roaming\Python\Python39\site-packages\brownie\exceptions.py:104: ValueError --------------------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------------------- The active network is development Deploying Mocks... Mocks deployed Contract deployed to0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6 ===================================================================================== short test summary info ====================================================================================== FAILED tests/test_fund_me.py::test_can_fund_and_withdraw - ValueError: sender doesn't have enough funds to send tx. The upfront cost is: 250000000000000000000000000 and the sender's account only... ======================================================================================== 1 failed in 9.50s ========================================================================================= Terminating local RPC client... PS D:\Python projects\Solidity dev\demo\brownie_fund_me> >