Skip to content

Commit

Permalink
[CLI] Add cli e2e for move view command (#8831)
Browse files Browse the repository at this point in the history
* Add cli e2e for move view command

* fix conflict after rebase
  • Loading branch information
0xmigo authored and gedigi committed Aug 2, 2023
1 parent db65b8f commit 8464b5e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 26 additions & 2 deletions crates/aptos/e2e/cases/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_move_compile(run_helper: RunHelper, test_name=None):
if f"{account_info.account_address}::cli_e2e_tests" not in response.stdout:
raise TestError("Module did not compile successfully")


@test_case
def test_move_compile_dev_mode(run_helper: RunHelper, test_name=None):
package_dir = f"move/cli-e2e-tests/{run_helper.base_network}"
Expand All @@ -104,6 +105,7 @@ def test_move_compile_dev_mode(run_helper: RunHelper, test_name=None):
if f"{account_info.account_address}::cli_e2e_tests" not in response.stdout:
raise TestError("Module did not compile successfully")


@test_case
def test_move_compile_script(run_helper: RunHelper, test_name=None):
package_dir = f"move/cli-e2e-tests/{run_helper.base_network}"
Expand Down Expand Up @@ -150,8 +152,7 @@ def test_move_run(run_helper: RunHelper, test_name=None):
],
)

response = json.loads(response.stdout)
if response["Result"].get("success") != True:
if '"success": true' not in response.stdout:
raise TestError("Move run did not execute successfully")

# Get what modules exist on chain.
Expand All @@ -176,3 +177,26 @@ def test_move_run(run_helper: RunHelper, test_name=None):
raise TestError(
"Data on chain (view_hero) does not match expected data from (mint_hero)"
)


@test_case
def test_move_view(run_helper: RunHelper, test_name=None):
account_info = run_helper.get_account_info()

# Run the view function
response = run_helper.run_command(
test_name,
[
"aptos",
"move",
"view",
"--function-id",
"0x1::account::exists_at",
"--args",
f"address:{account_info.account_address}",
],
)

response = json.loads(response.stdout)
if response["Result"] == None or response["Result"][0] != True:
raise TestError("View function did not return correct result")
2 changes: 2 additions & 0 deletions crates/aptos/e2e/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
test_move_compile_script,
test_move_publish,
test_move_run,
test_move_view,
)
from common import Network
from local_testnet import run_node, stop_node, wait_for_startup
Expand Down Expand Up @@ -125,6 +126,7 @@ def run_tests(run_helper):
test_aptos_header_included(run_helper)

# Run move subcommand group tests.
test_move_view(run_helper)
test_move_compile(run_helper)
test_move_compile_script(run_helper)
test_move_publish(run_helper)
Expand Down

0 comments on commit 8464b5e

Please # to comment.