-
Notifications
You must be signed in to change notification settings - Fork 27
/
test_protocol.py
117 lines (98 loc) · 3.6 KB
/
test_protocol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""Tests for protocol state and protocol parameters."""
import json
import logging
import typing as tp
import allure
import pytest
from cardano_clusterlib import clusterlib
from cardano_node_tests.tests import common
from cardano_node_tests.tests import issues
from cardano_node_tests.utils import clusterlib_utils
from cardano_node_tests.utils import helpers
LOGGER = logging.getLogger(__name__)
PROTOCOL_STATE_KEYS = frozenset(
(
"candidateNonce",
"epochNonce",
"evolvingNonce",
"labNonce",
"lastEpochBlockNonce",
"lastSlot",
"oCertCounters",
)
)
PROTOCOL_PARAM_KEYS = frozenset(
(
"collateralPercentage",
"costModels",
"decentralization",
"executionUnitPrices",
"extraPraosEntropy",
"maxBlockBodySize",
"maxBlockExecutionUnits",
"maxBlockHeaderSize",
"maxCollateralInputs",
"maxTxExecutionUnits",
"maxTxSize",
"maxValueSize",
"minPoolCost",
"minUTxOValue",
"monetaryExpansion",
"poolPledgeInfluence",
"poolRetireMaxEpoch",
"protocolVersion",
"stakeAddressDeposit",
"stakePoolDeposit",
"stakePoolTargetNum",
"treasuryCut",
"txFeeFixed",
"txFeePerByte",
"utxoCostPerWord",
)
)
PROTOCOL_PARAM_KEYS_1_35_2 = frozenset(("utxoCostPerByte",))
PROTOCOL_PARAM_KEYS_MISSING_8_6_0 = frozenset(("utxoCostPerWord",))
@common.SKIPIF_WRONG_ERA
@pytest.mark.testnets
@pytest.mark.smoke
class TestProtocol:
"""Basic tests for protocol."""
@allure.link(helpers.get_vcs_link())
def test_protocol_state_keys(self, cluster: clusterlib.ClusterLib):
"""Check output of `query protocol-state`."""
temp_template = common.get_test_id(cluster)
# The query dumps CBOR instead of JSON in some circumstances. We'll save the output
# for later.
protocol_state_raw = cluster.g_query.query_cli(["protocol-state"])
with open(f"{temp_template}_protocol_state.out", "w", encoding="utf-8") as fp_out:
fp_out.write(protocol_state_raw)
try:
protocol_state: dict = json.loads(protocol_state_raw)
except json.decoder.JSONDecodeError:
issues.node_3859.finish_test()
assert set(protocol_state) == PROTOCOL_STATE_KEYS
@allure.link(helpers.get_vcs_link())
def test_protocol_state_outfile(self, cluster: clusterlib.ClusterLib):
"""Check output file produced by `query protocol-state`."""
common.get_test_id(cluster)
try:
protocol_state: dict = json.loads(
cluster.g_query.query_cli(["protocol-state", "--out-file", "/dev/stdout"])
)
except UnicodeDecodeError as err:
if "invalid start byte" in str(err):
issues.node_2461.finish_test()
raise
assert set(protocol_state) == PROTOCOL_STATE_KEYS
@allure.link(helpers.get_vcs_link())
def test_protocol_params(self, cluster: clusterlib.ClusterLib):
"""Check output of `query protocol-parameters`."""
common.get_test_id(cluster)
protocol_params = cluster.g_query.get_protocol_params()
union_with: tp.FrozenSet[str] = frozenset()
if clusterlib_utils.cli_has("governance create-update-proposal --utxo-cost-per-byte"):
union_with = PROTOCOL_PARAM_KEYS_1_35_2
rem: tp.FrozenSet[str] = frozenset()
if clusterlib_utils.cli_has("conway"):
rem = PROTOCOL_PARAM_KEYS_MISSING_8_6_0
assert set(protocol_params) == PROTOCOL_PARAM_KEYS.union(union_with).difference(rem)