From 68abe21d221edb4920844e79003a947ea0779647 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 2 Oct 2023 21:05:27 +0300 Subject: [PATCH] fixes after review --- multiversx_sdk_cli/cli_contracts.py | 2 +- multiversx_sdk_cli/projects/templates.py | 6 +-- .../tests/test_cli_contracts.py | 4 +- .../tests/test_cli_contracts.sh | 50 ------------------- 4 files changed, 6 insertions(+), 56 deletions(-) diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index 82ca633e..27be0001 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -39,7 +39,7 @@ def setup_parser(args: List[str], subparsers: Any) -> Any: sub = cli_shared.add_command_subparser(subparsers, "contract", "templates", "List the available Smart Contract templates.") - sub.add_argument("--tag", help="the sc-meta framework version reffered to") + sub.add_argument("--tag", help="the sc-meta framework version referred to") sub.set_defaults(func=list_templates) sub = cli_shared.add_command_subparser(subparsers, "contract", "build", diff --git a/multiversx_sdk_cli/projects/templates.py b/multiversx_sdk_cli/projects/templates.py index 58cf206b..bfd9fdb2 100644 --- a/multiversx_sdk_cli/projects/templates.py +++ b/multiversx_sdk_cli/projects/templates.py @@ -21,17 +21,17 @@ def __init__(self, self.path = path def get_contract_templates(self) -> str: - self._check_if_dependencies_installed() + self._ensure_dependencies_installed() args = self._prepare_args_to_list_templates() templates = myprocess.run_process(args=args, dump_to_stdout=False) return templates def create_from_template(self) -> None: - self._check_if_dependencies_installed() + self._ensure_dependencies_installed() args = self._prepare_args_to_create_new_contract_from_template() myprocess.run_process(args) - def _check_if_dependencies_installed(self): + def _ensure_dependencies_installed(self): logger.info("Checking if the necessarry dependencies are installed.") install_module("rust") diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.py b/multiversx_sdk_cli/tests/test_cli_contracts.py index 63323a97..259b1a0e 100644 --- a/multiversx_sdk_cli/tests/test_cli_contracts.py +++ b/multiversx_sdk_cli/tests/test_cli_contracts.py @@ -34,10 +34,10 @@ def test_contract_new_with_bad_code(): ]) assert Path.is_dir(parent / "testdata-out" / "SANDBOX" / "adder-bad-src") - replace_variable_with_unknown_variable() + replace_variable_with_unknown_variable_for_adder() -def replace_variable_with_unknown_variable(): +def replace_variable_with_unknown_variable_for_adder(): # this is done in order to replace the value added in the adder contract with a unknown variable with open(parent / "testdata-out" / "SANDBOX" / "adder-bad-src" / "src" / "adder_bad_src.rs", "r") as f: contract_lines = f.readlines() diff --git a/multiversx_sdk_cli/tests/test_cli_contracts.sh b/multiversx_sdk_cli/tests/test_cli_contracts.sh index 04f023f6..fe980cfe 100755 --- a/multiversx_sdk_cli/tests/test_cli_contracts.sh +++ b/multiversx_sdk_cli/tests/test_cli_contracts.sh @@ -12,13 +12,6 @@ testCreateContracts() { ${CLI} contract new --template adder --path ${SANDBOX} || return 1 ${CLI} contract new --template crypto-zombies --path ${SANDBOX} || return 1 ${CLI} contract new --template empty --path ${SANDBOX} || return 1 - - # uncomment when other contract templates are available in sc-meta - # ${CLI} contract new --template factorial --path ${SANDBOX} myfactorial-rs || return 1 - # ${CLI} contract new --template crypto-bubbles --path ${SANDBOX} mybubbles-rs || return 1 - # ${CLI} contract new --template lottery-esdt --path ${SANDBOX} mylottery-rs || return 1 - # ${CLI} contract new --template crowdfunding-esdt --path ${SANDBOX} myfunding-rs || return 1 - # ${CLI} contract new --template multisig --path ${SANDBOX} multisig-rs || return 1 } testBuildContracts() { @@ -39,30 +32,12 @@ testBuildContracts() { ${CLI} contract build --path=${SANDBOX}/empty --target-dir=${TARGET_DIR} || return 1 assertFileExists ${SANDBOX}/empty/output/empty.wasm || return 1 assertFileExists ${SANDBOX}/empty/output/empty.abi.json || return 1 - - # uncomment when other contract templates are available in sc-meta - # ${CLI} contract build --path=${SANDBOX}/myfactorial-rs --target-dir=${TARGET_DIR} || return 1 - # assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 - - # ${CLI} contract build --path=${SANDBOX}/mybubbles-rs --target-dir=${TARGET_DIR} || return 1 - # assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - - # ${CLI} contract build --path=${SANDBOX}/mylottery-rs --target-dir=${TARGET_DIR} || return 1 - # assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - - # ${CLI} contract build --path=${SANDBOX}/myfunding-rs --target-dir=${TARGET_DIR} || return 1 - # assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 } testRunScenarios() { echo "testRunScenarios" ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/adder || return 1 ${CLI} --verbose contract test --directory="scenarios" ${SANDBOX}/empty || return 1 - # ${CLI} --verbose contract test --directory="scenarios" --recursive ${SANDBOX}/myfunding-rs || return 1 } testWasmName() { @@ -95,31 +70,6 @@ testCleanContracts() { ${CLI} contract clean --path ${SANDBOX}/empty || return 1 assertFileDoesNotExist ${SANDBOX}/empty/output/empty.wasm || return 1 assertFileDoesNotExist ${SANDBOX}/empty/output/empty.abi.json || return 1 - - # uncomment when other contract templates are available in sc-meta - # assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 - # ${CLI} contract clean --path ${SANDBOX}/myfactorial-rs || return 1 - # assertFileDoesNotExist ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.wasm || return 1 - # assertFileDoesNotExist ${SANDBOX}/myfactorial-rs/output/myfactorial-rs.abi.json || return 1 - - # assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - # ${CLI} contract clean --path ${SANDBOX}/mybubbles-rs || return 1 - # assertFileDoesNotExist ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.wasm || return 1 - # assertFileDoesNotExist ${SANDBOX}/mybubbles-rs/output/mybubbles-rs.abi.json || return 1 - - # assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - # ${CLI} contract clean --path ${SANDBOX}/mylottery-rs || return 1 - # assertFileDoesNotExist ${SANDBOX}/mylottery-rs/output/mylottery-rs.wasm || return 1 - # assertFileDoesNotExist ${SANDBOX}/mylottery-rs/output/mylottery-rs.abi.json || return 1 - - # assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - # assertFileExists ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 - # ${CLI} contract clean --path ${SANDBOX}/myfunding-rs || return 1 - # assertFileDoesNotExist ${SANDBOX}/myfunding-rs/output/myfunding-rs.wasm || return 1 - # assertFileDoesNotExist ${SANDBOX}/myfunding-rs/output/myfunding-rs.abi.json || return 1 } testVerifyContract(){