Skip to content

Commit

Permalink
[tests] add tests for the staking operation
Browse files Browse the repository at this point in the history
Operations:
 - stake
 - unstake
 - finalize_unstake
 - set_delegate_parameters
Check:
 - display
 - complexity
  • Loading branch information
spalmer25 committed Sep 11, 2024
1 parent 575b1ab commit 964865f
Show file tree
Hide file tree
Showing 148 changed files with 193 additions and 0 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.
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.
112 changes: 112 additions & 0 deletions tests/integration/nano/test_sign_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,115 @@ def test_too_complex_transaction(app):
path=path)

app.quit()

# Operation (0): Transaction
# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W
# Fee: 0.04 XTZ
# Storage limit: 2
# Amount: 1000 XTZ
# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk
# Entrypoint: stake
# Parameter: Unit
def test_sign_stake_transaction(app):
path = test_path / "stake"

app.setup_expert_mode()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031028094ebdc0300012bad922d045c068660fabe19576f8506a1fa8fa3ff0600000002030b")

data = app.sign(DEFAULT_ACCOUNT,
message,
with_hash=True,
path=path)

app.checker.check_signature(
account=DEFAULT_ACCOUNT,
message=message,
with_hash=True,
data=data)

app.quit()

# Operation (0): Transaction
# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W
# Fee: 0.04 XTZ
# Storage limit: 2
# Amount: 500 XTZ
# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk
# Entrypoint: unstake
# Parameter: Unit
def test_sign_unstake_transaction(app):
path = test_path / "unstake"

app.setup_expert_mode()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b80200310280cab5ee0100012bad922d045c068660fabe19576f8506a1fa8fa3ff0700000002030b")

data = app.sign(DEFAULT_ACCOUNT,
message,
with_hash=True,
path=path)

app.checker.check_signature(
account=DEFAULT_ACCOUNT,
message=message,
with_hash=True,
data=data)

app.quit()

# Operation (0): Transaction
# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W
# Fee: 0.04 XTZ
# Storage limit: 2
# Amount: 0 XTZ
# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk
# Entrypoint: finalize_unstake
# Parameter: Unit
def test_sign_finalize_unstake_transaction(app):
path = test_path / "finalize_unstake"

app.setup_expert_mode()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad922d045c068660fabe19576f8506a1fa8fa3ff0800000002030b")

data = app.sign(DEFAULT_ACCOUNT,
message,
with_hash=True,
path=path)

app.checker.check_signature(
account=DEFAULT_ACCOUNT,
message=message,
with_hash=True,
data=data)

app.quit()

# Operation (0): Transaction
# Source: tz2WmivuMG8MMRKMEmzKRMMxMApxZQWYNS4W
# Fee: 0.04 XTZ
# Storage limit: 2
# Amount: 0 XTZ
# Destination: tz2CJBeWWLsUDjVUDqGZL6od3DeBCNzYXrXk
# Entrypoint: set_delegate_parameters
# Parameter: Pair 4000000 (Pair 20000000 Unit)
def test_sign_set_delegate_parameters_transaction(app):
path = test_path / "delegate_parameters"

app.setup_expert_mode()

message = Message.from_bytes("0300000000000000000000000000000000000000000000000000000000000000006c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad922d045c068660fabe19576f8506a1fa8fa3ff090000001007070080a4e80307070080b48913030b")

data = app.sign(DEFAULT_ACCOUNT,
message,
with_hash=True,
path=path)

app.checker.check_signature(
account=DEFAULT_ACCOUNT,
message=message,
with_hash=True,
data=data)

app.quit()
81 changes: 81 additions & 0 deletions tests/unit/ctest/tests_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,87 @@ CTEST2(operation_parser, check_double_transaction_complexity)
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_stake_complexity)
{
char str[]
= "030000000000000000000000000000000000000000000000000000000000000000"
"6c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031028094ebdc03"
"00012bad922d045c068660fabe19576f8506a1fa8fa3ff0600000002030b";
const tz_fields_check fields_check[] = {
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_unstake_complexity)
{
char str[]
= "030000000000000000000000000000000000000000000000000000000000000000"
"6c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b80200310280cab5ee01"
"00012bad922d045c068660fabe19576f8506a1fa8fa3ff0700000002030b";
const tz_fields_check fields_check[] = {
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_finalize_unstake_complexity)
{
char str[]
= "030000000000000000000000000000000000000000000000000000000000000000"
"6c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad"
"922d045c068660fabe19576f8506a1fa8fa3ff0800000002030b";
const tz_fields_check fields_check[] = {
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_set_delegate_parameters_complexity)
{
char str[]
= "030000000000000000000000000000000000000000000000000000000000000000"
"6c01f6552df4f5ff51c3d13347cab045cfdb8b9bd803c0b8020031020000012bad"
"922d045c068660fabe19576f8506a1fa8fa3ff090000001007070080a4e8030707"
"0080b48913030b";
const tz_fields_check fields_check[] = {
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", false, 8},
{"Parameter", true, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_origination_complexity)
{
char str[]
Expand Down

0 comments on commit 964865f

Please sign in to comment.