diff --git a/.github/workflows/deploy.py b/.github/workflows/deploy.py index 297cac4fd..d65775c49 100644 --- a/.github/workflows/deploy.py +++ b/.github/workflows/deploy.py @@ -105,7 +105,7 @@ def run_tests(github_sha): project_name = f"neon-evm-{github_sha}" stop_containers(project_name) - run_subprocess(f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml up -d") + run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml up -d") container_name = get_solana_container_name(project_name) click.echo("Start tests") exec_id = docker_client.exec_create( @@ -127,7 +127,7 @@ def run_tests(github_sha): exec_status = docker_client.exec_inspect(exec_id['Id'])["ExitCode"] - run_subprocess(f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml logs dk-neon-api") + run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml logs dk-neon-api") stop_containers(project_name) @@ -137,7 +137,7 @@ def run_tests(github_sha): def get_solana_container_name(project_name): data = subprocess.run( - f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml ps", + f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml ps", shell=True, capture_output=True, text=True).stdout click.echo(data) pattern = rf'{project_name}_solana_[1-9]+' @@ -147,7 +147,7 @@ def get_solana_container_name(project_name): def stop_containers(project_name): - run_subprocess(f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml down") + run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml down") @cli.command(name="trigger_proxy_action") diff --git a/Dockerfile b/Dockerfile index 5d11bd626..55744efae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,8 @@ FROM ubuntu:20.04 AS contracts RUN apt-get update && \ DEBIAN_FRONTEND=nontineractive apt-get -y install xxd && \ rm -rf /var/lib/apt/lists/* /var/lib/apt/cache/* -COPY evm_loader/tests/contracts/*.sol /opt/ -COPY evm_loader/solidity/*.sol /opt/ +COPY tests/contracts/*.sol /opt/ +COPY solidity/*.sol /opt/ #COPY evm_loader/tests/test_solidity_precompiles.json /opt/ COPY --from=solc /usr/bin/solc /usr/bin/solc WORKDIR /opt/ @@ -51,10 +51,10 @@ RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install vim less openssl ca-certificates curl python3 python3-pip parallel && \ rm -rf /var/lib/apt/lists/* -COPY evm_loader/tests/requirements.txt /tmp/ +COPY tests/requirements.txt /tmp/ RUN pip3 install -r /tmp/requirements.txt -COPY /evm_loader/solidity/ /opt/contracts/contracts/ +#COPY /evm_loader/solidity/ /opt/contracts/contracts/ WORKDIR /opt COPY --from=solana \ @@ -80,19 +80,19 @@ COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/release/neon-api COPY --from=solana /usr/bin/spl-token /opt/spl-token COPY --from=contracts /opt/ /opt/solidity/ COPY --from=contracts /usr/bin/solc /usr/bin/solc -COPY evm_loader/wait-for-solana.sh \ - evm_loader/wait-for-neon.sh \ - evm_loader/deploy-evm.sh \ - evm_loader/deploy-test.sh \ - evm_loader/create-test-accounts.sh \ - evm_loader/evm_loader-keypair.json \ +COPY ci/wait-for-solana.sh \ + ci/wait-for-neon.sh \ + ci/deploy-evm.sh \ + ci/deploy-test.sh \ + ci/create-test-accounts.sh \ + ci/evm_loader-keypair.json \ /opt/ -COPY evm_loader/operator-keypairs/ /opt/operator-keypairs -COPY evm_loader/tests /opt/tests -COPY evm_loader/operator-keypairs/id.json /root/.config/solana/id.json -COPY evm_loader/operator-keypairs/id2.json /root/.config/solana/id2.json -COPY evm_loader/keys/ /opt/keys +COPY ci/operator-keypairs/ /opt/operator-keypairs +COPY tests /opt/tests +COPY ci/operator-keypairs/id.json /root/.config/solana/id.json +COPY ci/operator-keypairs/id2.json /root/.config/solana/id2.json +COPY ci/keys/ /opt/keys -ENV CONTRACTS_DIR=/opt/solidity/ +#ENV CONTRACTS_DIR=/opt/solidity/ ENV PATH=/opt/solana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt diff --git a/evm_loader/create-test-accounts.sh b/ci/create-test-accounts.sh similarity index 100% rename from evm_loader/create-test-accounts.sh rename to ci/create-test-accounts.sh diff --git a/evm_loader/deploy-evm.sh b/ci/deploy-evm.sh similarity index 100% rename from evm_loader/deploy-evm.sh rename to ci/deploy-evm.sh diff --git a/evm_loader/deploy-test.sh b/ci/deploy-test.sh similarity index 100% rename from evm_loader/deploy-test.sh rename to ci/deploy-test.sh diff --git a/evm_loader/docker-compose-ci.yml b/ci/docker-compose-ci.yml similarity index 100% rename from evm_loader/docker-compose-ci.yml rename to ci/docker-compose-ci.yml diff --git a/evm_loader/docker-compose-test.yml b/ci/docker-compose-test.yml similarity index 100% rename from evm_loader/docker-compose-test.yml rename to ci/docker-compose-test.yml diff --git a/evm_loader/evm_loader-keypair.json b/ci/evm_loader-keypair.json similarity index 100% rename from evm_loader/evm_loader-keypair.json rename to ci/evm_loader-keypair.json diff --git a/evm_loader/keys/neon_token_keypair.json b/ci/keys/neon_token_keypair.json similarity index 100% rename from evm_loader/keys/neon_token_keypair.json rename to ci/keys/neon_token_keypair.json diff --git a/evm_loader/operator-keypairs/id.json b/ci/operator-keypairs/id.json similarity index 100% rename from evm_loader/operator-keypairs/id.json rename to ci/operator-keypairs/id.json diff --git a/evm_loader/operator-keypairs/id10.json b/ci/operator-keypairs/id10.json similarity index 100% rename from evm_loader/operator-keypairs/id10.json rename to ci/operator-keypairs/id10.json diff --git a/evm_loader/operator-keypairs/id11.json b/ci/operator-keypairs/id11.json similarity index 100% rename from evm_loader/operator-keypairs/id11.json rename to ci/operator-keypairs/id11.json diff --git a/evm_loader/operator-keypairs/id12.json b/ci/operator-keypairs/id12.json similarity index 100% rename from evm_loader/operator-keypairs/id12.json rename to ci/operator-keypairs/id12.json diff --git a/evm_loader/operator-keypairs/id13.json b/ci/operator-keypairs/id13.json similarity index 100% rename from evm_loader/operator-keypairs/id13.json rename to ci/operator-keypairs/id13.json diff --git a/evm_loader/operator-keypairs/id14.json b/ci/operator-keypairs/id14.json similarity index 100% rename from evm_loader/operator-keypairs/id14.json rename to ci/operator-keypairs/id14.json diff --git a/evm_loader/operator-keypairs/id15.json b/ci/operator-keypairs/id15.json similarity index 100% rename from evm_loader/operator-keypairs/id15.json rename to ci/operator-keypairs/id15.json diff --git a/evm_loader/operator-keypairs/id16.json b/ci/operator-keypairs/id16.json similarity index 100% rename from evm_loader/operator-keypairs/id16.json rename to ci/operator-keypairs/id16.json diff --git a/evm_loader/operator-keypairs/id17.json b/ci/operator-keypairs/id17.json similarity index 100% rename from evm_loader/operator-keypairs/id17.json rename to ci/operator-keypairs/id17.json diff --git a/evm_loader/operator-keypairs/id18.json b/ci/operator-keypairs/id18.json similarity index 100% rename from evm_loader/operator-keypairs/id18.json rename to ci/operator-keypairs/id18.json diff --git a/evm_loader/operator-keypairs/id19.json b/ci/operator-keypairs/id19.json similarity index 100% rename from evm_loader/operator-keypairs/id19.json rename to ci/operator-keypairs/id19.json diff --git a/evm_loader/operator-keypairs/id2.json b/ci/operator-keypairs/id2.json similarity index 100% rename from evm_loader/operator-keypairs/id2.json rename to ci/operator-keypairs/id2.json diff --git a/evm_loader/operator-keypairs/id20.json b/ci/operator-keypairs/id20.json similarity index 100% rename from evm_loader/operator-keypairs/id20.json rename to ci/operator-keypairs/id20.json diff --git a/evm_loader/operator-keypairs/id21.json b/ci/operator-keypairs/id21.json similarity index 100% rename from evm_loader/operator-keypairs/id21.json rename to ci/operator-keypairs/id21.json diff --git a/evm_loader/operator-keypairs/id22.json b/ci/operator-keypairs/id22.json similarity index 100% rename from evm_loader/operator-keypairs/id22.json rename to ci/operator-keypairs/id22.json diff --git a/evm_loader/operator-keypairs/id23.json b/ci/operator-keypairs/id23.json similarity index 100% rename from evm_loader/operator-keypairs/id23.json rename to ci/operator-keypairs/id23.json diff --git a/evm_loader/operator-keypairs/id24.json b/ci/operator-keypairs/id24.json similarity index 100% rename from evm_loader/operator-keypairs/id24.json rename to ci/operator-keypairs/id24.json diff --git a/evm_loader/operator-keypairs/id25.json b/ci/operator-keypairs/id25.json similarity index 100% rename from evm_loader/operator-keypairs/id25.json rename to ci/operator-keypairs/id25.json diff --git a/evm_loader/operator-keypairs/id26.json b/ci/operator-keypairs/id26.json similarity index 100% rename from evm_loader/operator-keypairs/id26.json rename to ci/operator-keypairs/id26.json diff --git a/evm_loader/operator-keypairs/id27.json b/ci/operator-keypairs/id27.json similarity index 100% rename from evm_loader/operator-keypairs/id27.json rename to ci/operator-keypairs/id27.json diff --git a/evm_loader/operator-keypairs/id28.json b/ci/operator-keypairs/id28.json similarity index 100% rename from evm_loader/operator-keypairs/id28.json rename to ci/operator-keypairs/id28.json diff --git a/evm_loader/operator-keypairs/id29.json b/ci/operator-keypairs/id29.json similarity index 100% rename from evm_loader/operator-keypairs/id29.json rename to ci/operator-keypairs/id29.json diff --git a/evm_loader/operator-keypairs/id3.json b/ci/operator-keypairs/id3.json similarity index 100% rename from evm_loader/operator-keypairs/id3.json rename to ci/operator-keypairs/id3.json diff --git a/evm_loader/operator-keypairs/id30.json b/ci/operator-keypairs/id30.json similarity index 100% rename from evm_loader/operator-keypairs/id30.json rename to ci/operator-keypairs/id30.json diff --git a/evm_loader/operator-keypairs/id4.json b/ci/operator-keypairs/id4.json similarity index 100% rename from evm_loader/operator-keypairs/id4.json rename to ci/operator-keypairs/id4.json diff --git a/evm_loader/operator-keypairs/id5.json b/ci/operator-keypairs/id5.json similarity index 100% rename from evm_loader/operator-keypairs/id5.json rename to ci/operator-keypairs/id5.json diff --git a/evm_loader/operator-keypairs/id6.json b/ci/operator-keypairs/id6.json similarity index 100% rename from evm_loader/operator-keypairs/id6.json rename to ci/operator-keypairs/id6.json diff --git a/evm_loader/operator-keypairs/id7.json b/ci/operator-keypairs/id7.json similarity index 100% rename from evm_loader/operator-keypairs/id7.json rename to ci/operator-keypairs/id7.json diff --git a/evm_loader/operator-keypairs/id8.json b/ci/operator-keypairs/id8.json similarity index 100% rename from evm_loader/operator-keypairs/id8.json rename to ci/operator-keypairs/id8.json diff --git a/evm_loader/operator-keypairs/id9.json b/ci/operator-keypairs/id9.json similarity index 100% rename from evm_loader/operator-keypairs/id9.json rename to ci/operator-keypairs/id9.json diff --git a/evm_loader/wait-for-neon.sh b/ci/wait-for-neon.sh similarity index 100% rename from evm_loader/wait-for-neon.sh rename to ci/wait-for-neon.sh diff --git a/evm_loader/wait-for-solana.sh b/ci/wait-for-solana.sh similarity index 100% rename from evm_loader/wait-for-solana.sh rename to ci/wait-for-solana.sh diff --git a/evm_loader/solidity/Metaplex.sol b/solidity/Metaplex.sol similarity index 100% rename from evm_loader/solidity/Metaplex.sol rename to solidity/Metaplex.sol diff --git a/evm_loader/solidity/SPLToken.sol b/solidity/SPLToken.sol similarity index 100% rename from evm_loader/solidity/SPLToken.sol rename to solidity/SPLToken.sol diff --git a/evm_loader/solidity/big_contract.sol b/solidity/big_contract.sol similarity index 100% rename from evm_loader/solidity/big_contract.sol rename to solidity/big_contract.sol diff --git a/evm_loader/solidity/erc20_for_spl.sol b/solidity/erc20_for_spl.sol similarity index 100% rename from evm_loader/solidity/erc20_for_spl.sol rename to solidity/erc20_for_spl.sol diff --git a/evm_loader/solidity/erc20_for_spl_factory.sol b/solidity/erc20_for_spl_factory.sol similarity index 100% rename from evm_loader/solidity/erc20_for_spl_factory.sol rename to solidity/erc20_for_spl_factory.sol diff --git a/evm_loader/solidity/erc721_for_metaplex.sol b/solidity/erc721_for_metaplex.sol similarity index 100% rename from evm_loader/solidity/erc721_for_metaplex.sol rename to solidity/erc721_for_metaplex.sol diff --git a/evm_loader/solidity/lib_query_account.sol b/solidity/lib_query_account.sol similarity index 100% rename from evm_loader/solidity/lib_query_account.sol rename to solidity/lib_query_account.sol diff --git a/evm_loader/solidity/neon_wrapper.sol b/solidity/neon_wrapper.sol similarity index 100% rename from evm_loader/solidity/neon_wrapper.sol rename to solidity/neon_wrapper.sol diff --git a/evm_loader/tests/.gitignore b/tests/.gitignore similarity index 100% rename from evm_loader/tests/.gitignore rename to tests/.gitignore diff --git a/evm_loader/tests/README.md b/tests/README.md similarity index 100% rename from evm_loader/tests/README.md rename to tests/README.md diff --git a/evm_loader/tests/__init__.py b/tests/__init__.py similarity index 100% rename from evm_loader/tests/__init__.py rename to tests/__init__.py diff --git a/evm_loader/tests/conftest.py b/tests/conftest.py similarity index 97% rename from evm_loader/tests/conftest.py rename to tests/conftest.py index ef25a219a..b19051ee0 100644 --- a/evm_loader/tests/conftest.py +++ b/tests/conftest.py @@ -1,167 +1,167 @@ -import os -import json -import pathlib - -import eth_abi -import pytest - -from solana.keypair import Keypair -from eth_keys import keys as eth_keys -from solana.publickey import PublicKey -from solana.rpc.commitment import Confirmed - -from .solana_utils import EvmLoader, create_treasury_pool_address, make_new_user, \ - deposit_neon, solana_client, spl_cli, wait_confirm_transaction, get_solana_balance -from .utils.constants import NEON_TOKEN_MINT_ID -from .utils.contract import deploy_contract -from .utils.storage import create_holder -from .utils.types import TreasuryPool, Caller, Contract -from .utils.neon_api_client import NeonApiClient - - -def pytest_addoption(parser): - parser.addoption( - "--neon-api-uri", action="store", default="http://neon_api:8085/api", - help="" - ) - - -def pytest_configure(): - if "RUST_LOG" in os.environ: - pytest.CONTRACTS_PATH = pathlib.Path("/opt/solidity") - else: - pytest.CONTRACTS_PATH = pathlib.Path(__file__).parent / "contracts" - - -@pytest.fixture(scope="session") -def evm_loader(operator_keypair) -> EvmLoader: - loader = EvmLoader(operator_keypair) - return loader - - -def prepare_operator(key_file): - with open(key_file, "r") as key: - secret_key = json.load(key)[:32] - account = Keypair.from_secret_key(secret_key) - tx = solana_client.request_airdrop(account.public_key, 1000000 * 10 ** 9, commitment=Confirmed) - wait_confirm_transaction(solana_client, tx.value) - caller_ether = eth_keys.PrivateKey(account.secret_key[:32]).public_key.to_canonical_address() - evm_loader = EvmLoader(account) - evm_loader.ether2program(caller_ether) - caller, caller_nonce = evm_loader.ether2program(caller_ether) - acc_info = solana_client.get_account_info(PublicKey(caller), commitment=Confirmed) - if acc_info.value is None: - token = spl_cli.create_token_account(NEON_TOKEN_MINT_ID, account.public_key, fee_payer=key_file) - spl_cli.mint(NEON_TOKEN_MINT_ID, token, 5000000, fee_payer=key_file) - evm_loader.create_ether_account(caller_ether) - return account - - -@pytest.fixture(scope="session") -def operator_keypair(worker_id) -> Keypair: - """ - Initialized solana keypair with balance. Get private keys from ci/operator-keypairs - """ - key_path = pathlib.Path(__file__).parent.parent / "operator-keypairs" - if worker_id in ("master", "gw1"): - key_file = key_path / "id.json" - else: - file_id = int(worker_id[-1]) + 2 - key_file = key_path / f"id{file_id}.json" - return prepare_operator(key_file) - - -@pytest.fixture(scope="session") -def second_operator_keypair(worker_id) -> Keypair: - """ - Initialized solana keypair with balance. Get private key from cli or ./ci/operator-keypairs - """ - key_path = pathlib.Path(__file__).parent.parent / "operator-keypairs" - if worker_id in ("master", "gw1"): - key_file = key_path / "id20.json" - else: - file_id = 20 + int(worker_id[-1]) + 2 - key_file = key_path / f"id{file_id}.json" - - return prepare_operator(key_file) - - -@pytest.fixture(scope="session") -def treasury_pool(evm_loader) -> TreasuryPool: - index = 2 - address = create_treasury_pool_address(index) - index_buf = index.to_bytes(4, 'little') - return TreasuryPool(index, address, index_buf) - - -@pytest.fixture(scope="function") -def user_account(evm_loader) -> Caller: - return make_new_user(evm_loader) - - -@pytest.fixture(scope="session") -def session_user(evm_loader) -> Caller: - return make_new_user(evm_loader) - - -@pytest.fixture(scope="session") -def second_session_user(evm_loader) -> Caller: - return make_new_user(evm_loader) - - -@pytest.fixture(scope="session") -def sender_with_tokens(evm_loader, operator_keypair) -> Caller: - user = make_new_user(evm_loader) - deposit_neon(evm_loader, operator_keypair, user.eth_address, 100000) - return user - - -@pytest.fixture(scope="session") -def holder_acc(operator_keypair) -> PublicKey: - return create_holder(operator_keypair) - - -@pytest.fixture(scope="function") -def new_holder_acc(operator_keypair) -> PublicKey: - return create_holder(operator_keypair) - - -@pytest.fixture(scope="function") -def rw_lock_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, - treasury_pool) -> Contract: - return deploy_contract(operator_keypair, session_user, "rw_lock.binary", evm_loader, treasury_pool) - - -@pytest.fixture(scope="function") -def rw_lock_caller(evm_loader: EvmLoader, operator_keypair: Keypair, - session_user: Caller, treasury_pool: TreasuryPool, rw_lock_contract: Contract) -> Contract: - constructor_args = eth_abi.encode(['address'], [rw_lock_contract.eth_address.hex()]) - return deploy_contract(operator_keypair, session_user, "rw_lock_caller.binary", evm_loader, - treasury_pool, encoded_args=constructor_args) - - -@pytest.fixture(scope="function") -def string_setter_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, - treasury_pool) -> Contract: - return deploy_contract(operator_keypair, session_user, "string_setter.binary", evm_loader, treasury_pool) - - -@pytest.fixture(scope="session") -def calculator_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, - treasury_pool) -> Contract: - return deploy_contract(operator_keypair, session_user, "Calculator.binary", evm_loader, treasury_pool) - - -@pytest.fixture(scope="session") -def calculator_caller_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, - treasury_pool, calculator_contract) -> Contract: - constructor_args = eth_abi.encode(['address'], [calculator_contract.eth_address.hex()]) - - return deploy_contract(operator_keypair, session_user, "CalculatorCaller.binary", evm_loader, treasury_pool, - encoded_args=constructor_args) - - -@pytest.fixture(scope="session") -def neon_api_client(request): - client = NeonApiClient(url=request.config.getoption("--neon-api-uri")) - return client +import os +import json +import pathlib + +import eth_abi +import pytest + +from solana.keypair import Keypair +from eth_keys import keys as eth_keys +from solana.publickey import PublicKey +from solana.rpc.commitment import Confirmed + +from .solana_utils import EvmLoader, create_treasury_pool_address, make_new_user, \ + deposit_neon, solana_client, spl_cli, wait_confirm_transaction, get_solana_balance +from .utils.constants import NEON_TOKEN_MINT_ID +from .utils.contract import deploy_contract +from .utils.storage import create_holder +from .utils.types import TreasuryPool, Caller, Contract +from .utils.neon_api_client import NeonApiClient + + +def pytest_addoption(parser): + parser.addoption( + "--neon-api-uri", action="store", default="http://neon_api:8085/api", + help="" + ) + + +def pytest_configure(): + if "RUST_LOG" in os.environ: + pytest.CONTRACTS_PATH = pathlib.Path("/opt/solidity") + else: + pytest.CONTRACTS_PATH = pathlib.Path(__file__).parent / "contracts" + + +@pytest.fixture(scope="session") +def evm_loader(operator_keypair) -> EvmLoader: + loader = EvmLoader(operator_keypair) + return loader + + +def prepare_operator(key_file): + with open(key_file, "r") as key: + secret_key = json.load(key)[:32] + account = Keypair.from_secret_key(secret_key) + tx = solana_client.request_airdrop(account.public_key, 1000000 * 10 ** 9, commitment=Confirmed) + wait_confirm_transaction(solana_client, tx.value) + caller_ether = eth_keys.PrivateKey(account.secret_key[:32]).public_key.to_canonical_address() + evm_loader = EvmLoader(account) + evm_loader.ether2program(caller_ether) + caller, caller_nonce = evm_loader.ether2program(caller_ether) + acc_info = solana_client.get_account_info(PublicKey(caller), commitment=Confirmed) + if acc_info.value is None: + token = spl_cli.create_token_account(NEON_TOKEN_MINT_ID, account.public_key, fee_payer=key_file) + spl_cli.mint(NEON_TOKEN_MINT_ID, token, 5000000, fee_payer=key_file) + evm_loader.create_ether_account(caller_ether) + return account + + +@pytest.fixture(scope="session") +def operator_keypair(worker_id) -> Keypair: + """ + Initialized solana keypair with balance. Get private keys from ci/operator-keypairs + """ + key_path = pathlib.Path(__file__).parent.parent / "operator-keypairs" + if worker_id in ("master", "gw1"): + key_file = key_path / "id.json" + else: + file_id = int(worker_id[-1]) + 2 + key_file = key_path / f"id{file_id}.json" + return prepare_operator(key_file) + + +@pytest.fixture(scope="session") +def second_operator_keypair(worker_id) -> Keypair: + """ + Initialized solana keypair with balance. Get private key from cli or ./ci/operator-keypairs + """ + key_path = pathlib.Path(__file__).parent.parent / "operator-keypairs" + if worker_id in ("master", "gw1"): + key_file = key_path / "id20.json" + else: + file_id = 20 + int(worker_id[-1]) + 2 + key_file = key_path / f"id{file_id}.json" + + return prepare_operator(key_file) + + +@pytest.fixture(scope="session") +def treasury_pool(evm_loader) -> TreasuryPool: + index = 2 + address = create_treasury_pool_address(index) + index_buf = index.to_bytes(4, 'little') + return TreasuryPool(index, address, index_buf) + + +@pytest.fixture(scope="function") +def user_account(evm_loader) -> Caller: + return make_new_user(evm_loader) + + +@pytest.fixture(scope="session") +def session_user(evm_loader) -> Caller: + return make_new_user(evm_loader) + + +@pytest.fixture(scope="session") +def second_session_user(evm_loader) -> Caller: + return make_new_user(evm_loader) + + +@pytest.fixture(scope="session") +def sender_with_tokens(evm_loader, operator_keypair) -> Caller: + user = make_new_user(evm_loader) + deposit_neon(evm_loader, operator_keypair, user.eth_address, 100000) + return user + + +@pytest.fixture(scope="session") +def holder_acc(operator_keypair) -> PublicKey: + return create_holder(operator_keypair) + + +@pytest.fixture(scope="function") +def new_holder_acc(operator_keypair) -> PublicKey: + return create_holder(operator_keypair) + + +@pytest.fixture(scope="function") +def rw_lock_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, + treasury_pool) -> Contract: + return deploy_contract(operator_keypair, session_user, "rw_lock.binary", evm_loader, treasury_pool) + + +@pytest.fixture(scope="function") +def rw_lock_caller(evm_loader: EvmLoader, operator_keypair: Keypair, + session_user: Caller, treasury_pool: TreasuryPool, rw_lock_contract: Contract) -> Contract: + constructor_args = eth_abi.encode(['address'], [rw_lock_contract.eth_address.hex()]) + return deploy_contract(operator_keypair, session_user, "rw_lock_caller.binary", evm_loader, + treasury_pool, encoded_args=constructor_args) + + +@pytest.fixture(scope="function") +def string_setter_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, + treasury_pool) -> Contract: + return deploy_contract(operator_keypair, session_user, "string_setter.binary", evm_loader, treasury_pool) + + +@pytest.fixture(scope="session") +def calculator_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, + treasury_pool) -> Contract: + return deploy_contract(operator_keypair, session_user, "Calculator.binary", evm_loader, treasury_pool) + + +@pytest.fixture(scope="session") +def calculator_caller_contract(evm_loader: EvmLoader, operator_keypair: Keypair, session_user: Caller, + treasury_pool, calculator_contract) -> Contract: + constructor_args = eth_abi.encode(['address'], [calculator_contract.eth_address.hex()]) + + return deploy_contract(operator_keypair, session_user, "CalculatorCaller.binary", evm_loader, treasury_pool, + encoded_args=constructor_args) + + +@pytest.fixture(scope="session") +def neon_api_client(request): + client = NeonApiClient(url=request.config.getoption("--neon-api-uri")) + return client diff --git a/evm_loader/tests/contracts/contracts.sol b/tests/contracts/contracts.sol similarity index 100% rename from evm_loader/tests/contracts/contracts.sol rename to tests/contracts/contracts.sol diff --git a/evm_loader/tests/eth_tx_utils.py b/tests/eth_tx_utils.py similarity index 100% rename from evm_loader/tests/eth_tx_utils.py rename to tests/eth_tx_utils.py diff --git a/evm_loader/tests/requirements.txt b/tests/requirements.txt similarity index 100% rename from evm_loader/tests/requirements.txt rename to tests/requirements.txt diff --git a/evm_loader/tests/solana_utils.py b/tests/solana_utils.py similarity index 100% rename from evm_loader/tests/solana_utils.py rename to tests/solana_utils.py diff --git a/evm_loader/tests/test_cancel_trx.py b/tests/test_cancel_trx.py similarity index 100% rename from evm_loader/tests/test_cancel_trx.py rename to tests/test_cancel_trx.py diff --git a/evm_loader/tests/test_cli.py b/tests/test_cli.py similarity index 100% rename from evm_loader/tests/test_cli.py rename to tests/test_cli.py diff --git a/evm_loader/tests/test_execute_trx_from_instruction.py b/tests/test_execute_trx_from_instruction.py similarity index 100% rename from evm_loader/tests/test_execute_trx_from_instruction.py rename to tests/test_execute_trx_from_instruction.py diff --git a/evm_loader/tests/test_holder_account.py b/tests/test_holder_account.py similarity index 100% rename from evm_loader/tests/test_holder_account.py rename to tests/test_holder_account.py diff --git a/evm_loader/tests/test_neon_core_api.py b/tests/test_neon_core_api.py similarity index 100% rename from evm_loader/tests/test_neon_core_api.py rename to tests/test_neon_core_api.py diff --git a/evm_loader/tests/test_parallel.py b/tests/test_parallel.py similarity index 100% rename from evm_loader/tests/test_parallel.py rename to tests/test_parallel.py diff --git a/evm_loader/tests/test_step_instructions_work_the_same.py b/tests/test_step_instructions_work_the_same.py similarity index 100% rename from evm_loader/tests/test_step_instructions_work_the_same.py rename to tests/test_step_instructions_work_the_same.py diff --git a/evm_loader/tests/test_transaction_step_from_account.py b/tests/test_transaction_step_from_account.py similarity index 100% rename from evm_loader/tests/test_transaction_step_from_account.py rename to tests/test_transaction_step_from_account.py diff --git a/evm_loader/tests/test_transaction_step_from_account_no_chainid.py b/tests/test_transaction_step_from_account_no_chainid.py similarity index 100% rename from evm_loader/tests/test_transaction_step_from_account_no_chainid.py rename to tests/test_transaction_step_from_account_no_chainid.py diff --git a/evm_loader/tests/test_transaction_step_from_instruction.py b/tests/test_transaction_step_from_instruction.py similarity index 100% rename from evm_loader/tests/test_transaction_step_from_instruction.py rename to tests/test_transaction_step_from_instruction.py diff --git a/evm_loader/tests/utils/__init__.py b/tests/utils/__init__.py similarity index 100% rename from evm_loader/tests/utils/__init__.py rename to tests/utils/__init__.py diff --git a/evm_loader/tests/utils/assert_messages.py b/tests/utils/assert_messages.py similarity index 100% rename from evm_loader/tests/utils/assert_messages.py rename to tests/utils/assert_messages.py diff --git a/evm_loader/tests/utils/constants.py b/tests/utils/constants.py similarity index 100% rename from evm_loader/tests/utils/constants.py rename to tests/utils/constants.py diff --git a/evm_loader/tests/utils/contract.py b/tests/utils/contract.py similarity index 100% rename from evm_loader/tests/utils/contract.py rename to tests/utils/contract.py diff --git a/evm_loader/tests/utils/ethereum.py b/tests/utils/ethereum.py similarity index 100% rename from evm_loader/tests/utils/ethereum.py rename to tests/utils/ethereum.py diff --git a/evm_loader/tests/utils/instructions.py b/tests/utils/instructions.py similarity index 100% rename from evm_loader/tests/utils/instructions.py rename to tests/utils/instructions.py diff --git a/evm_loader/tests/utils/layouts.py b/tests/utils/layouts.py similarity index 100% rename from evm_loader/tests/utils/layouts.py rename to tests/utils/layouts.py diff --git a/evm_loader/tests/utils/neon_api_client.py b/tests/utils/neon_api_client.py similarity index 100% rename from evm_loader/tests/utils/neon_api_client.py rename to tests/utils/neon_api_client.py diff --git a/evm_loader/tests/utils/storage.py b/tests/utils/storage.py similarity index 100% rename from evm_loader/tests/utils/storage.py rename to tests/utils/storage.py diff --git a/evm_loader/tests/utils/transaction_checks.py b/tests/utils/transaction_checks.py similarity index 100% rename from evm_loader/tests/utils/transaction_checks.py rename to tests/utils/transaction_checks.py diff --git a/evm_loader/tests/utils/types.py b/tests/utils/types.py similarity index 100% rename from evm_loader/tests/utils/types.py rename to tests/utils/types.py