Skip to content

Commit

Permalink
Tests: add test check HWM after signing when no chain has been setup
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Feb 5, 2024
1 parent 4b04f50 commit 4ac86f9
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 63 additions & 2 deletions test/python/test_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def test_setup_app_context(account: Account, tezos_navigator: TezosNavigator) ->
"""Test the SETUP instruction."""
snap_path = Path(f"{account}")

main_chain_id = "NetXH12AexHqTQa"
main_chain_id = "NetXH12AexHqTQa" # Chain = 1
main_hwm = Hwm(1)
test_hwm = Hwm(2)

Expand Down Expand Up @@ -588,7 +588,7 @@ def test_sign_level_authorized(
def test_sign_not_authorized_key(
client: TezosClient,
tezos_navigator: TezosNavigator) -> None:
"""Check that signing with a key different from the authorized key is not authorized.."""
"""Check that signing with a key different from the authorized key is not authorized."""

account_1 = DEFAULT_ACCOUNT
account_2 = DEFAULT_ACCOUNT_2
Expand All @@ -608,6 +608,67 @@ def test_sign_not_authorized_key(
client.sign_message(account_2, attestation)


def test_sign_when_no_chain_setup(
client: TezosClient,
tezos_navigator: TezosNavigator) -> None:
"""Check that signing when no chain has been setup change main HWM."""

account = DEFAULT_ACCOUNT

tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID, # Chain = 0
main_hwm=Hwm(0),
test_hwm=Hwm(0)
)

attestation = build_attestation(
1, 0,
DEFAULT_CHAIN_ID # Chain = 0
)

client.sign_message(account, attestation)

tezos_navigator.check_app_context(
account,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(1, 0),
test_hwm=Hwm(0, 0),
snap_path=Path("sign_1_0")
)

attestation = build_attestation(
2, 0,
"NetXH12AexHqTQa" # Chain = 1
)

client.sign_message(account, attestation)

tezos_navigator.check_app_context(
account,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(2, 0),
test_hwm=Hwm(0, 0),
snap_path=Path("sign_2_0")
)

attestation = build_attestation(
2, 0,
"NetXH12Af5mrXhq" # Chain = 2
)

with StatusCode.WRONG_VALUES.expected():
client.sign_message(account, attestation)

tezos_navigator.check_app_context(
account,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(2, 0),
test_hwm=Hwm(0, 0),
snap_path=Path("sign_2_0")
)


# Data generated by the old application itself
HMAC_TEST_SET = [
(DEFAULT_ACCOUNT,
Expand Down

0 comments on commit 4ac86f9

Please sign in to comment.