eth-educators / ethstaker-deposit-cli

Secure key generation for deposits
https://eth-educators.github.io/ethstaker-deposit-cli/
Creative Commons Zero v1.0 Universal
3 stars 5 forks source link

Race condition or failing test in `test_exit_transaction_mnemonic_multiple` #49

Closed remyroy closed 4 months ago

remyroy commented 4 months ago

From https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779

============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli
plugins: asyncio-0.23.6
asyncio: mode=strict
collected 714 items

tests/test_cli/test_existing_mnemonic.py ......                          [  0%]
tests/test_cli/test_exit_transaction_keystore.py .....                   [  1%]
tests/test_cli/test_exit_transaction_mnemonic.py .F.....                 [  2%]
tests/test_cli/test_generate_bls_to_execution_change.py ...              [  2%]
tests/test_cli/test_new_mnemonic.py ........                             [  4%]
tests/test_cli/test_regeneration.py .                                    [  4%]
tests/test_credentials.py .                                              [  4%]
tests/test_deposit.py ........                                           [  5%]
tests/test_intl/test_json_schema.py .................................... [ 10%]
....................................                                     [ 15%]
tests/test_key_handling/test_key_derivation/test_mnemonic.py ........... [ 17%]
........................................................................ [ 27%]
........................................................................ [ 37%]
........................................................................ [ 47%]
........................................................................ [ 57%]
........................................................................ [ 67%]
........................................................................ [ 77%]
................................................................         [ 86%]
tests/test_key_handling/test_key_derivation/test_path.py ........        [ 87%]
tests/test_key_handling/test_key_derivation/test_tree.py ............... [ 89%]
........                                                                 [ 90%]
tests/test_key_handling/test_keystore.py ............                    [ 92%]
tests/test_utils/test_constants.py ..                                    [ 92%]
tests/test_utils/test_crypto.py ..........                               [ 94%]
tests/test_utils/test_intl.py ..........                                 [ 95%]
tests/test_utils/test_ssz.py .........                                   [ 96%]
tests/test_utils/test_validation.py ......................               [100%]

=================================== FAILURES ===================================
___________________ test_exit_transaction_mnemonic_multiple ____________________

    @pytest.mark.asyncio
    async def test_exit_transaction_mnemonic_multiple() -> None:
        # Prepare folder
        my_folder_path = os.path.join(os.getcwd(), 'TESTING_TEMP_FOLDER')
        clean_exit_transaction_folder(my_folder_path)
        if not os.path.exists(my_folder_path):
            os.mkdir(my_folder_path)

        if os.name == 'nt':  # Windows
            run_script_cmd = 'sh deposit.sh'
        else:  # Mac or Linux
            run_script_cmd = './deposit.sh'

        install_cmd = run_script_cmd + ' install'
        proc = await asyncio.create_subprocess_shell(
            install_cmd,
        )
        await proc.wait()

        cmd_args = [
            run_script_cmd,
            '--language', 'english',
            '--non_interactive',
            'exit-transaction-mnemonic',
            '--output_folder', my_folder_path,
            '--chain', 'mainnet',
            '--mnemonic', '"aban aban aban aban aban aban aban aban aban aban aban abou"',
            '--validator_start_index', '0',
            '--validator_indices', '0,1,2,3',
            '--epoch', '[12](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:13)34',
        ]
        proc = await asyncio.create_subprocess_shell(
            ' '.join(cmd_args),
        )
        await proc.wait()

>       assert proc.returncode == 0
E       assert 1 == 0
E        +  where 1 = <Process 2[13](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:14)5>.returncode

tests/test_cli/test_exit_transaction_mnemonic.py:94: AssertionError
----------------------------- Captured stdout call -----------------------------
linux-gnu
Installing dependencies...
Requirement already satisfied: py-ecc==7.0.0 in /opt/hostedtoolcache/Python/3.10.[14](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:15)/x64/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (7.0.0)
Requirement already satisfied: pycryptodome==3.20.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 4)) (3.20.0)
Requirement already satisfied: click==7.1.2 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 37)) (7.1.2)
Requirement already satisfied: ssz==0.5.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 40)) (0.5.0)
Requirement already satisfied: eth-typing==4.1.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 43)) (4.1.0)
Requirement already satisfied: eth-utils==4.1.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 46)) (4.1.0)
Requirement already satisfied: mypy-extensions==1.0.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 51)) (1.0.0)
Requirement already satisfied: lru-dict==1.3.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 54)) (1.3.0)
Requirement already satisfied: pyrsistent==0.[16](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:17).1 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 136)) (0.16.1)
Requirement already satisfied: eth-hash==0.7.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 138)) (0.7.0)
Requirement already satisfied: cytoolz==0.12.3 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 141)) (0.12.3)
Requirement already satisfied: toolz==0.12.1 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 246)) (0.12.1)
Requirement already satisfied: six==1.16.0 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 249)) (1.16.0)
Requirement already satisfied: cached-property==1.5.2 in /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages (from -r requirements.txt (line 252)) (1.5.2)
linux-gnu
Running deposit-cli...
----------------------------- Captured stderr call -----------------------------
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/process.py", line 205, in _process_chunk
    return [fn(*args) for args in chunk]
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/process.py", line 205, in <listcomp>
    return [fn(*args) for args in chunk]
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/cli/exit_transaction_mnemonic.py", line 33, in _exit_exporter
    return credential.save_exit_transaction(**kwargs)
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/credentials.py", line 231, in save_exit_transaction
    return export_exit_transaction_json(folder=folder, signed_exit=signed_voluntary_exit)
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/exit_transaction.py", line 52, in export_exit_transaction_json
    os.mkdir(folder)
FileExistsError: [Errno [17](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:18)] File exists: '/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/TESTING_TEMP_FOLDER/exit_transactions'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/runpy.py", line [19](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:20)6, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/__main__.py", line 4, in <module>
    deposit.run()
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/deposit.py", line 97, in run
    cli()
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/click/decorators.py", line [21](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:22), in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/staking_deposit/cli/exit_transaction_mnemonic.py", line 144, in exit_transaction_mnemonic
    for filefolder in executor.map(_exit_exporter, executor_kwargs):
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/process.py", line 575, in _chain_from_iterable_of_lists
    for element in iterable:
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/_base.py", line [31](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:32)9, in _result_or_cancel
    return fut.result(timeout)
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
FileExistsError: [Errno 17] File exists: '/home/runner/work/ethstaker-deposit-cli/ethstaker-deposit-cli/TESTING_TEMP_FOLDER/exit_transactions'
=========================== short test summary info ============================
FAILED tests/test_cli/test_exit_transaction_mnemonic.py::test_exit_transaction_mnemonic_multiple - assert 1 == 0
 +  where 1 = <Process 2135>.returncode
================== 1 failed, 713 passed in 105.[32](https://github.com/eth-educators/ethstaker-deposit-cli/actions/runs/9257058845/job/25464387779#step:5:33)s (0:01:45) ===================
Error: Process completed with exit code 1.

Blocking #48

Might be related to #47