Skip to content

Commit fff6cf5

Browse files
committed
test(conway): reject legacy certificates and proposals in Conway era
- Add negative tests to ensure legacy stake address registration, delegation, pool registration, governance proposals, and MIR certificates are rejected in Conway. - Parametrize tests across all compatible legacy eras (Shelley, Allegra, Mary, Alonzo, Babbage). - Expect transaction submission to fail with a "TextEnvelope type error" or era mismatch error. - Remove obsolete tests for legacy proposal build with Conway CLI. - Add issue marker for cli issue 1347 (Compat stake reg cert accepted without deposit amount).
1 parent a483c9d commit fff6cf5

7 files changed

Lines changed: 348 additions & 150 deletions

File tree

cardano_node_tests/tests/issues.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@
121121
fixed_in="10.15.0.1", # Fixed in release after 10.15.0.1
122122
message="Cannot get policyid for SimpleScript reference script.",
123123
)
124+
cli_1347 = blockers.GH(
125+
issue=1347,
126+
repo="IntersectMBO/cardano-cli",
127+
fixed_in="10.15.0.1", # Fixed in some release after 10.15.0.1
128+
message="Compat stake reg cert accepted without deposit amount.",
129+
)
124130

125131
consensus_973 = blockers.GH(
126132
issue=973,

cardano_node_tests/tests/test_addr_registration.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import allure
77
import pytest
88
from cardano_clusterlib import clusterlib
9+
from packaging import version
910

1011
from cardano_node_tests.cluster_management import cluster_management
1112
from cardano_node_tests.tests import common
@@ -813,3 +814,54 @@ def _submit_tx(
813814
else:
814815
err = f"Invalid issue: {issue}"
815816
raise ValueError(err)
817+
818+
@allure.link(helpers.get_vcs_link())
819+
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
820+
@pytest.mark.testnets
821+
@pytest.mark.smoke
822+
def test_legacy_stake_addr_registration_rejected_in_conway(
823+
self,
824+
cluster: clusterlib.ClusterLib,
825+
pool_users: list[clusterlib.PoolUser],
826+
pool_users_disposable: list[clusterlib.PoolUser],
827+
era: str,
828+
):
829+
"""Reject legacy stake address registration in Conway.
830+
831+
* Generate a stake address registration certificate using the compatible CLI
832+
for a legacy era.
833+
* Attempt to submit the legacy certificate in a Conway-era transaction.
834+
* Expect the transaction submission to fail with a TextEnvelope type error.
835+
"""
836+
temp_template = common.get_test_id(cluster)
837+
838+
era_api = getattr(cluster.g_compatible, era)
839+
legacy_stake_reg_cert = era_api.stake_address.gen_registration_cert(
840+
name=f"{temp_template}_{era}",
841+
stake_vkey_file=pool_users_disposable[0].stake.vkey_file,
842+
)
843+
tx_files = clusterlib.TxFiles(
844+
certificate_files=[legacy_stake_reg_cert],
845+
signing_key_files=[
846+
pool_users[0].payment.skey_file,
847+
pool_users_disposable[0].stake.skey_file,
848+
],
849+
)
850+
851+
err_str = ""
852+
try:
853+
cluster.g_transaction.send_tx(
854+
src_address=pool_users[0].payment.address,
855+
tx_name=f"{temp_template}_{era}_legacy_stake_reg",
856+
tx_files=tx_files,
857+
)
858+
except clusterlib.CLIError as exc:
859+
err_str = str(exc)
860+
861+
if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
862+
issues.cli_1347.finish_test()
863+
864+
assert err_str, "Expected transaction submission to fail, but it succeeded"
865+
866+
with common.allow_unstable_error_messages():
867+
assert "TextEnvelope type error" in err_str, err_str

cardano_node_tests/tests/test_delegation.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import allure
66
import pytest
77
from cardano_clusterlib import clusterlib
8+
from packaging import version
89

910
from cardano_node_tests.cluster_management import cluster_management
1011
from cardano_node_tests.cluster_management import resources_management
@@ -15,6 +16,7 @@
1516
from cardano_node_tests.utils import dbsync_utils
1617
from cardano_node_tests.utils import helpers
1718
from cardano_node_tests.utils import tx_view
19+
from cardano_node_tests.utils.versions import VERSIONS
1820

1921
LOGGER = logging.getLogger(__name__)
2022

@@ -1316,3 +1318,74 @@ def test_delegatee_not_registered(
13161318
"DelegateeNotRegisteredDELEG" in exc_value # Before cardano-node 10.0.0
13171319
or "DelegateeStakePoolNotRegisteredDELEG" in exc_value
13181320
), exc_value
1321+
1322+
@allure.link(helpers.get_vcs_link())
1323+
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
1324+
@pytest.mark.testnets
1325+
@pytest.mark.smoke
1326+
def test_legacy_stake_delegation_rejected_in_conway(
1327+
self,
1328+
cluster: clusterlib.ClusterLib,
1329+
pool_users: list[clusterlib.PoolUser],
1330+
pool_users_disposable: list[clusterlib.PoolUser],
1331+
era: str,
1332+
):
1333+
"""Reject legacy stake address delegation in Conway.
1334+
1335+
* Register stake address using Conway-era commands.
1336+
* Generate a stake address delegation certificate using the compatible CLI
1337+
for a legacy era.
1338+
* Attempt to submit the legacy certificate in a Conway-era transaction.
1339+
* Expect the transaction submission to fail with a TextEnvelope type error.
1340+
"""
1341+
temp_template = common.get_test_id(cluster)
1342+
1343+
user_registered = pool_users_disposable[0]
1344+
user_payment = pool_users[0].payment
1345+
1346+
# Register stake address using Conway commands
1347+
clusterlib_utils.register_stake_address(
1348+
cluster_obj=cluster,
1349+
pool_user=clusterlib.PoolUser(payment=user_payment, stake=user_registered.stake),
1350+
name_template=f"{temp_template}_{era}_reg",
1351+
deposit_amt=cluster.g_query.get_address_deposit(),
1352+
)
1353+
1354+
# Use an existing registered pool
1355+
pool_ids = cluster.g_query.get_stake_pools()
1356+
assert pool_ids, "No registered stake pools available on this testnet"
1357+
pool_id = pool_ids[0]
1358+
1359+
# Generate legacy delegation cert via compatible CLI
1360+
era_api = getattr(cluster.g_compatible, era)
1361+
legacy_stake_deleg_cert = era_api.stake_address.gen_delegation_cert(
1362+
name=f"{temp_template}_{era}",
1363+
stake_vkey_file=user_registered.stake.vkey_file,
1364+
stake_pool_id=pool_id,
1365+
)
1366+
1367+
tx_files = clusterlib.TxFiles(
1368+
certificate_files=[legacy_stake_deleg_cert],
1369+
signing_key_files=[
1370+
pool_users[0].payment.skey_file,
1371+
user_registered.stake.skey_file,
1372+
],
1373+
)
1374+
1375+
err_str = ""
1376+
try:
1377+
cluster.g_transaction.send_tx(
1378+
src_address=pool_users[0].payment.address,
1379+
tx_name=f"{temp_template}_{era}_legacy_deleg",
1380+
tx_files=tx_files,
1381+
)
1382+
except clusterlib.CLIError as exc:
1383+
err_str = str(exc)
1384+
1385+
if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
1386+
issues.cli_1347.finish_test()
1387+
1388+
assert err_str, "Expected transaction submission to fail, but it succeeded"
1389+
1390+
with common.allow_unstable_error_messages():
1391+
assert "TextEnvelope type error" in err_str, err_str

cardano_node_tests/tests/test_pools.py

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pytest_subtests
2121
from _pytest.fixtures import FixtureRequest
2222
from cardano_clusterlib import clusterlib
23+
from packaging import version
2324

2425
from cardano_node_tests.cluster_management import cluster_management
2526
from cardano_node_tests.tests import common
@@ -2047,7 +2048,8 @@ def pool_users(
20472048
num=2,
20482049
fund_idx=[0],
20492050
caching_key=helpers.get_current_line_str(),
2050-
amount=600_000_000,
2051+
amount=900_000_000,
2052+
min_amount=600_000_000,
20512053
)
20522054
return created_users
20532055

@@ -2607,6 +2609,89 @@ def test_stake_pool_long_metadata_url(
26072609
in exc_value
26082610
)
26092611

2612+
@allure.link(helpers.get_vcs_link())
2613+
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
2614+
@pytest.mark.testnets
2615+
@pytest.mark.smoke
2616+
def test_legacy_pool_registration_rejected_in_conway(
2617+
self,
2618+
cluster: clusterlib.ClusterLib,
2619+
pool_users: list[clusterlib.PoolUser],
2620+
testfile_temp_dir: pl.Path,
2621+
era: str,
2622+
request: FixtureRequest,
2623+
):
2624+
"""Reject legacy stake pool registration in Conway.
2625+
2626+
* Generate a stake pool registration certificate using the compatible CLI
2627+
for a legacy era.
2628+
* Attempt to submit the legacy certificate in a Conway-era transaction.
2629+
* Expect the transaction submission to fail with a TextEnvelope type error.
2630+
"""
2631+
rand_str = clusterlib.get_rand_str(4)
2632+
temp_template = f"{common.get_test_id(cluster)}_{rand_str}"
2633+
2634+
node_vrf = cluster.g_node.gen_vrf_key_pair(f"{temp_template}_{era}_vrf")
2635+
node_cold = cluster.g_node.gen_cold_key_pair_and_counter(f"{temp_template}_{era}_cold")
2636+
2637+
pool_data = clusterlib.PoolData(
2638+
pool_name=f"pool_{rand_str}",
2639+
pool_pledge=5,
2640+
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
2641+
pool_margin=0.01,
2642+
)
2643+
2644+
era_api = getattr(cluster.g_compatible, era)
2645+
legacy_pool_reg_cert = era_api.stake_pool.gen_registration_cert(
2646+
name=f"{temp_template}_{era}",
2647+
pool_data=pool_data,
2648+
vrf_vkey_file=node_vrf.vkey_file,
2649+
cold_vkey_file=node_cold.vkey_file,
2650+
owner_stake_vkey_files=[pool_users[0].stake.vkey_file],
2651+
)
2652+
2653+
tx_files = clusterlib.TxFiles(
2654+
certificate_files=[legacy_pool_reg_cert],
2655+
signing_key_files=[
2656+
pool_users[0].payment.skey_file,
2657+
pool_users[0].stake.skey_file,
2658+
node_cold.skey_file,
2659+
],
2660+
)
2661+
2662+
err_str = ""
2663+
try:
2664+
cluster.g_transaction.send_tx(
2665+
src_address=pool_users[0].payment.address,
2666+
tx_name=f"{temp_template}_{era}_legacy_pool_reg",
2667+
tx_files=tx_files,
2668+
)
2669+
except clusterlib.CLIError as exc:
2670+
err_str = str(exc)
2671+
2672+
# Deregister stake pool in case it was unexpectedly registered
2673+
def _deregister():
2674+
depoch = 1 if cluster.time_to_epoch_end() >= DEREG_BUFFER_SEC else 2
2675+
with helpers.change_cwd(testfile_temp_dir):
2676+
cluster.g_stake_pool.deregister_stake_pool(
2677+
pool_owners=pool_users,
2678+
cold_key_pair=node_cold,
2679+
epoch=cluster.g_query.get_epoch() + depoch,
2680+
pool_name=pool_data.pool_name,
2681+
tx_name=f"{temp_template}_cleanup",
2682+
)
2683+
2684+
if not err_str:
2685+
request.addfinalizer(_deregister)
2686+
2687+
if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
2688+
issues.cli_1347.finish_test()
2689+
2690+
assert err_str, "Expected transaction submission to fail, but it succeeded"
2691+
2692+
with common.allow_unstable_error_messages():
2693+
assert "TextEnvelope type error" in err_str, err_str
2694+
26102695

26112696
@pytest.mark.skipif(
26122697
VERSIONS.transaction_era < VERSIONS.CONWAY, reason="runs only with Tx era >= Conway"

cardano_node_tests/tests/tests_conway/test_conway.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,62 @@ def test_ratify_state_fields(self, cluster: clusterlib.ClusterLib):
208208

209209
missing = expected_fields - set(ratify_state)
210210
assert not missing, f"Missing expected fields in ratify-state: {missing}"
211+
212+
213+
class TestNegativeLegacyGovernance:
214+
@allure.link(helpers.get_vcs_link())
215+
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
216+
@pytest.mark.smoke
217+
def test_mixed_legacy_govaction_and_conway_vote_cert_fails(
218+
self,
219+
cluster: clusterlib.ClusterLib,
220+
pool_user: clusterlib.PoolUser,
221+
era: str,
222+
):
223+
"""Reject mixed legacy governance action and Conway vote delegation.
224+
225+
* Generate a legacy governance action using the compatible CLI.
226+
* Generate a Conway-era stake and vote delegation certificate.
227+
* Submit both certificates in a single Conway-era transaction.
228+
* Expect the transaction submission to fail with a TextEnvelope type error.
229+
"""
230+
temp_template = common.get_test_id(cluster)
231+
232+
payment_rec = pool_user.payment
233+
stake_rec = pool_user.stake
234+
235+
pool_ids = cluster.g_query.get_stake_pools()
236+
assert pool_ids, "No stake pools available on this testnet"
237+
pool_id = pool_ids[0]
238+
239+
era_api = getattr(cluster.g_compatible, era)
240+
legacy_prop = era_api.governance.gen_pparams_update(
241+
name=f"{temp_template}_era",
242+
epoch=cluster.g_query.get_epoch(),
243+
genesis_vkey_file=cluster.g_genesis.genesis_keys.genesis_vkeys[0],
244+
cli_args=["--max-block-body-size", "65536"],
245+
)
246+
247+
deleg_cert = cluster.g_stake_address.gen_stake_and_vote_delegation_cert(
248+
addr_name=temp_template,
249+
stake_vkey_file=stake_rec.vkey_file,
250+
stake_pool_id=pool_id,
251+
always_abstain=True,
252+
)
253+
254+
tx_files = clusterlib.TxFiles(
255+
certificate_files=[deleg_cert],
256+
proposal_files=[legacy_prop],
257+
signing_key_files=[payment_rec.skey_file, stake_rec.skey_file],
258+
)
259+
260+
with pytest.raises(clusterlib.CLIError) as excinfo:
261+
cluster.g_transaction.send_tx(
262+
src_address=payment_rec.address,
263+
tx_name=f"{temp_template}_mixed_fail",
264+
tx_files=tx_files,
265+
)
266+
267+
exc_value = str(excinfo.value)
268+
with common.allow_unstable_error_messages():
269+
assert "TextEnvelope type error" in exc_value, exc_value

0 commit comments

Comments
 (0)