Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Oct 2, 2023
1 parent 4dbf018 commit 68abe21
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 56 deletions.
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions multiversx_sdk_cli/projects/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions multiversx_sdk_cli/tests/test_cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
50 changes: 0 additions & 50 deletions multiversx_sdk_cli/tests/test_cli_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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(){
Expand Down

0 comments on commit 68abe21

Please sign in to comment.