Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cardano_node_tests/tests/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
fixed_in="10.15.0.1", # Fixed in release after 10.15.0.1
message="Cannot get policyid for SimpleScript reference script.",
)
cli_1347 = blockers.GH(
issue=1347,
repo="IntersectMBO/cardano-cli",
fixed_in="10.15.0.1", # Fixed in some release after 10.15.0.1
message="Compat stake reg cert accepted without deposit amount.",
)

consensus_973 = blockers.GH(
issue=973,
Expand Down
52 changes: 52 additions & 0 deletions cardano_node_tests/tests/test_addr_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import allure
import pytest
from cardano_clusterlib import clusterlib
from packaging import version

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.tests import common
Expand Down Expand Up @@ -813,3 +814,54 @@ def _submit_tx(
else:
err = f"Invalid issue: {issue}"
raise ValueError(err)

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_stake_addr_registration_rejected_in_conway(
self,
cluster: clusterlib.ClusterLib,
pool_users: list[clusterlib.PoolUser],
pool_users_disposable: list[clusterlib.PoolUser],
era: str,
):
"""Reject legacy stake address registration in Conway.

* Generate a stake address registration certificate using the compatible CLI
for a legacy era.
* Attempt to submit the legacy certificate in a Conway-era transaction.
* Expect the transaction submission to fail with a TextEnvelope type error.
"""
temp_template = common.get_test_id(cluster)

era_api = getattr(cluster.g_compatible, era)
legacy_stake_reg_cert = era_api.stake_address.gen_registration_cert(
name=f"{temp_template}_{era}",
stake_vkey_file=pool_users_disposable[0].stake.vkey_file,
)
tx_files = clusterlib.TxFiles(
certificate_files=[legacy_stake_reg_cert],
signing_key_files=[
pool_users[0].payment.skey_file,
pool_users_disposable[0].stake.skey_file,
],
)

err_str = ""
try:
cluster.g_transaction.send_tx(
src_address=pool_users[0].payment.address,
tx_name=f"{temp_template}_{era}_legacy_stake_reg",
tx_files=tx_files,
)
except clusterlib.CLIError as exc:
err_str = str(exc)

if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
issues.cli_1347.finish_test()

assert err_str, "Expected transaction submission to fail, but it succeeded"

with common.allow_unstable_error_messages():
assert "TextEnvelope type error" in err_str, err_str
73 changes: 73 additions & 0 deletions cardano_node_tests/tests/test_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import allure
import pytest
from cardano_clusterlib import clusterlib
from packaging import version

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.cluster_management import resources_management
Expand All @@ -15,6 +16,7 @@
from cardano_node_tests.utils import dbsync_utils
from cardano_node_tests.utils import helpers
from cardano_node_tests.utils import tx_view
from cardano_node_tests.utils.versions import VERSIONS

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -1316,3 +1318,74 @@ def test_delegatee_not_registered(
"DelegateeNotRegisteredDELEG" in exc_value # Before cardano-node 10.0.0
or "DelegateeStakePoolNotRegisteredDELEG" in exc_value
), exc_value

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_stake_delegation_rejected_in_conway(
self,
cluster: clusterlib.ClusterLib,
pool_users: list[clusterlib.PoolUser],
pool_users_disposable: list[clusterlib.PoolUser],
era: str,
):
"""Reject legacy stake address delegation in Conway.

* Register stake address using Conway-era commands.
* Generate a stake address delegation certificate using the compatible CLI
for a legacy era.
* Attempt to submit the legacy certificate in a Conway-era transaction.
* Expect the transaction submission to fail with a TextEnvelope type error.
"""
temp_template = common.get_test_id(cluster)

user_registered = pool_users_disposable[0]
user_payment = pool_users[0].payment

# Register stake address using Conway commands
clusterlib_utils.register_stake_address(
cluster_obj=cluster,
pool_user=clusterlib.PoolUser(payment=user_payment, stake=user_registered.stake),
name_template=f"{temp_template}_{era}_reg",
deposit_amt=cluster.g_query.get_address_deposit(),
)

# Use an existing registered pool
pool_ids = cluster.g_query.get_stake_pools()
assert pool_ids, "No registered stake pools available on this testnet"
pool_id = pool_ids[0]

# Generate legacy delegation cert via compatible CLI
era_api = getattr(cluster.g_compatible, era)
legacy_stake_deleg_cert = era_api.stake_address.gen_delegation_cert(
name=f"{temp_template}_{era}",
stake_vkey_file=user_registered.stake.vkey_file,
stake_pool_id=pool_id,
)

tx_files = clusterlib.TxFiles(
certificate_files=[legacy_stake_deleg_cert],
signing_key_files=[
pool_users[0].payment.skey_file,
user_registered.stake.skey_file,
],
)

err_str = ""
try:
cluster.g_transaction.send_tx(
src_address=pool_users[0].payment.address,
tx_name=f"{temp_template}_{era}_legacy_deleg",
tx_files=tx_files,
)
except clusterlib.CLIError as exc:
err_str = str(exc)

if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
issues.cli_1347.finish_test()

assert err_str, "Expected transaction submission to fail, but it succeeded"

with common.allow_unstable_error_messages():
assert "TextEnvelope type error" in err_str, err_str
87 changes: 86 additions & 1 deletion cardano_node_tests/tests/test_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytest_subtests
from _pytest.fixtures import FixtureRequest
from cardano_clusterlib import clusterlib
from packaging import version

from cardano_node_tests.cluster_management import cluster_management
from cardano_node_tests.tests import common
Expand Down Expand Up @@ -2047,7 +2048,8 @@ def pool_users(
num=2,
fund_idx=[0],
caching_key=helpers.get_current_line_str(),
amount=600_000_000,
amount=900_000_000,
min_amount=600_000_000,
)
return created_users

Expand Down Expand Up @@ -2607,6 +2609,89 @@ def test_stake_pool_long_metadata_url(
in exc_value
)

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_pool_registration_rejected_in_conway(
self,
cluster: clusterlib.ClusterLib,
pool_users: list[clusterlib.PoolUser],
testfile_temp_dir: pl.Path,
era: str,
request: FixtureRequest,
):
"""Reject legacy stake pool registration in Conway.

* Generate a stake pool registration certificate using the compatible CLI
for a legacy era.
* Attempt to submit the legacy certificate in a Conway-era transaction.
* Expect the transaction submission to fail with a TextEnvelope type error.
"""
rand_str = clusterlib.get_rand_str(4)
temp_template = f"{common.get_test_id(cluster)}_{rand_str}"

node_vrf = cluster.g_node.gen_vrf_key_pair(f"{temp_template}_{era}_vrf")
node_cold = cluster.g_node.gen_cold_key_pair_and_counter(f"{temp_template}_{era}_cold")

pool_data = clusterlib.PoolData(
pool_name=f"pool_{rand_str}",
pool_pledge=5,
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
pool_margin=0.01,
)

era_api = getattr(cluster.g_compatible, era)
legacy_pool_reg_cert = era_api.stake_pool.gen_registration_cert(
name=f"{temp_template}_{era}",
pool_data=pool_data,
vrf_vkey_file=node_vrf.vkey_file,
cold_vkey_file=node_cold.vkey_file,
owner_stake_vkey_files=[pool_users[0].stake.vkey_file],
)

tx_files = clusterlib.TxFiles(
certificate_files=[legacy_pool_reg_cert],
signing_key_files=[
pool_users[0].payment.skey_file,
pool_users[0].stake.skey_file,
node_cold.skey_file,
],
)

err_str = ""
try:
cluster.g_transaction.send_tx(
src_address=pool_users[0].payment.address,
tx_name=f"{temp_template}_{era}_legacy_pool_reg",
tx_files=tx_files,
)
except clusterlib.CLIError as exc:
err_str = str(exc)

# Deregister stake pool in case it was unexpectedly registered
def _deregister():
depoch = 1 if cluster.time_to_epoch_end() >= DEREG_BUFFER_SEC else 2
with helpers.change_cwd(testfile_temp_dir):
cluster.g_stake_pool.deregister_stake_pool(
pool_owners=pool_users,
cold_key_pair=node_cold,
epoch=cluster.g_query.get_epoch() + depoch,
pool_name=pool_data.pool_name,
tx_name=f"{temp_template}_cleanup",
)

if not err_str:
request.addfinalizer(_deregister)

if not err_str and VERSIONS.cli >= version.parse("10.14.0.0"):
issues.cli_1347.finish_test()

assert err_str, "Expected transaction submission to fail, but it succeeded"

with common.allow_unstable_error_messages():
assert "TextEnvelope type error" in err_str, err_str


@pytest.mark.skipif(
VERSIONS.transaction_era < VERSIONS.CONWAY, reason="runs only with Tx era >= Conway"
Expand Down
59 changes: 59 additions & 0 deletions cardano_node_tests/tests/tests_conway/test_conway.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,62 @@ def test_ratify_state_fields(self, cluster: clusterlib.ClusterLib):

missing = expected_fields - set(ratify_state)
assert not missing, f"Missing expected fields in ratify-state: {missing}"


class TestNegativeLegacyGovernance:
@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "allegra", "mary", "alonzo", "babbage"))
@pytest.mark.smoke
def test_mixed_legacy_govaction_and_conway_vote_cert_fails(
self,
cluster: clusterlib.ClusterLib,
pool_user: clusterlib.PoolUser,
era: str,
):
"""Reject mixed legacy governance action and Conway vote delegation.

* Generate a legacy governance action using the compatible CLI.
* Generate a Conway-era stake and vote delegation certificate.
* Submit both certificates in a single Conway-era transaction.
* Expect the transaction submission to fail with a TextEnvelope type error.
"""
temp_template = common.get_test_id(cluster)

payment_rec = pool_user.payment
stake_rec = pool_user.stake

pool_ids = cluster.g_query.get_stake_pools()
assert pool_ids, "No stake pools available on this testnet"
pool_id = pool_ids[0]

era_api = getattr(cluster.g_compatible, era)
legacy_prop = era_api.governance.gen_pparams_update(
name=f"{temp_template}_era",
epoch=cluster.g_query.get_epoch(),
genesis_vkey_file=cluster.g_genesis.genesis_keys.genesis_vkeys[0],
cli_args=["--max-block-body-size", "65536"],
)

deleg_cert = cluster.g_stake_address.gen_stake_and_vote_delegation_cert(
addr_name=temp_template,
stake_vkey_file=stake_rec.vkey_file,
stake_pool_id=pool_id,
always_abstain=True,
)

tx_files = clusterlib.TxFiles(
certificate_files=[deleg_cert],
proposal_files=[legacy_prop],
signing_key_files=[payment_rec.skey_file, stake_rec.skey_file],
)

with pytest.raises(clusterlib.CLIError) as excinfo:
cluster.g_transaction.send_tx(
src_address=payment_rec.address,
tx_name=f"{temp_template}_mixed_fail",
tx_files=tx_files,
)

exc_value = str(excinfo.value)
with common.allow_unstable_error_messages():
assert "TextEnvelope type error" in exc_value, exc_value
Loading
Loading