Skip to content
Draft
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
54 changes: 54 additions & 0 deletions cardano_node_tests/tests/test_addr_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,57 @@ def _submit_tx(
else:
err = f"Invalid issue: {issue}"
raise ValueError(err)

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_stake_addr_registration_rejected_in_conway(
self,
cluster_manager: cluster_management.ClusterManager,
cluster: clusterlib.ClusterLib,
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)

pool_users = common.get_pool_users(
name_template=f"{temp_template}_{era}_legacy",
cluster_manager=cluster_manager,
cluster_obj=cluster,
num=1,
fund_idx=[0],
amount=600_000_000,
)

era_api = getattr(cluster.g_compatible, era)

legacy_stake_reg_cert = era_api.stake_address.gen_registration_cert(
name=f"{temp_template}_{era}_stake",
stake_vkey_file=pool_users[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[0].stake.skey_file,
],
)

with pytest.raises(clusterlib.CLIError) as excinfo:
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,
)

err = str(excinfo.value)

assert "TextEnvelope type error" in err, err
70 changes: 70 additions & 0 deletions cardano_node_tests/tests/test_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,3 +1249,73 @@ def test_delegatee_not_registered(
"DelegateeNotRegisteredDELEG" in err_msg # Before cardano-node 10.0.0
or "DelegateeStakePoolNotRegisteredDELEG" in err_msg
), err_msg

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_stake_delegation_rejected_in_conway(
self,
cluster_manager: cluster_management.ClusterManager,
cluster: clusterlib.ClusterLib,
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)

# Create funded pool user
pool_users = common.get_pool_users(
name_template=f"{temp_template}_{era}_legacy",
cluster_manager=cluster_manager,
cluster_obj=cluster,
num=1,
fund_idx=[0],
amount=600_000_000,
)
pool_user = pool_users[0]

# Register stake address using Conway commands
clusterlib_utils.register_stake_address(
cluster_obj=cluster,
pool_user=pool_user,
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}_deleg",
stake_vkey_file=pool_user.stake.vkey_file,
stake_pool_id=pool_id,
)

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

with pytest.raises(clusterlib.CLIError) as excinfo:
cluster.g_transaction.send_tx(
src_address=pool_user.payment.address,
tx_name=f"{temp_template}_{era}_legacy_deleg",
tx_files=tx_files,
)

err = str(excinfo.value)
assert "TextEnvelope type error" in err, err
144 changes: 144 additions & 0 deletions cardano_node_tests/tests/test_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,150 @@ def test_stake_pool_long_metadata_url(
in err_str
)

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_pool_registration_rejected_in_conway(
self,
cluster_manager: cluster_management.ClusterManager,
cluster: clusterlib.ClusterLib,
era: str,
):
"""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.
"""
temp_template = common.get_test_id(cluster)

pool_users = common.get_pool_users(
name_template=f"{temp_template}_{era}_legacy",
cluster_manager=cluster_manager,
cluster_obj=cluster,
num=1,
fund_idx=[0],
amount=600_000_000,
)

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")

era_api = getattr(cluster.g_compatible, era)

legacy_pool_reg_cert = era_api.stake_pool.gen_registration_cert(
name=f"{temp_template}_{era}_pool",
pool_data=clusterlib.PoolData(
pool_name=f"{temp_template}_{era}_pool",
pool_pledge=5,
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
pool_margin=0.01,
),
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,
],
)

with pytest.raises(clusterlib.CLIError) as excinfo:
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,
)

err = str(excinfo.value)

assert "TextEnvelope type error" in err, err

@allure.link(helpers.get_vcs_link())
@pytest.mark.parametrize("era", ("shelley", "mary", "alonzo", "babbage"))
@pytest.mark.testnets
@pytest.mark.smoke
def test_legacy_pool_registration_plus_conway_delegation_fails(
self,
cluster_manager: cluster_management.ClusterManager,
cluster: clusterlib.ClusterLib,
era: str,
):
"""Reject mixed legacy pool registration and Conway delegation.

* Generate a legacy stake pool registration certificate using compatible CLI.
* Generate a Conway-era stake address 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)

# Pool user for funding and signing
pool_users = common.get_pool_users(
name_template=f"{temp_template}_{era}_mixed",
cluster_manager=cluster_manager,
cluster_obj=cluster,
num=1,
fund_idx=[0],
amount=600_000_000,
)

payment_rec = pool_users[0].payment
stake_rec = pool_users[0].stake

# Generate pool keys
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")

# Legacy (compatible-era) pool registration certificate
era_api = getattr(cluster.g_compatible, era)
legacy_pool_reg_cert = era_api.stake_pool.gen_registration_cert(
name=f"{temp_template}_{era}_legacy_pool",
pool_data=clusterlib.PoolData(
pool_name=f"{temp_template}_{era}_legacy_pool",
pool_pledge=5,
pool_cost=cluster.g_query.get_protocol_params().get("minPoolCost", 500),
pool_margin=0.01,
),
vrf_vkey_file=node_vrf.vkey_file,
cold_vkey_file=node_cold.vkey_file,
owner_stake_vkey_files=[stake_rec.vkey_file],
)

# Conway-era stake delegation certificate
conway_deleg_cert = cluster.g_stake_address.gen_stake_addr_delegation_cert(
addr_name=f"{temp_template}_{era}_deleg",
stake_vkey_file=stake_rec.vkey_file,
cold_vkey_file=node_cold.vkey_file,
)

tx_files = clusterlib.TxFiles(
certificate_files=[legacy_pool_reg_cert, conway_deleg_cert],
signing_key_files=[
payment_rec.skey_file,
stake_rec.skey_file,
node_cold.skey_file,
],
)

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

err = str(excinfo.value)

assert "TextEnvelope type error" in err, err


@pytest.mark.skipif(
VERSIONS.transaction_era < VERSIONS.CONWAY, reason="runs only with Tx era >= Conway"
Expand Down
57 changes: 57 additions & 0 deletions cardano_node_tests/tests/tests_conway/test_conway.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,60 @@ 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", "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.action.gen_pparams_update(
name=temp_template,
epoch=cluster.g_query.get_epoch(),
genesis_vkey_file=cluster.g_genesis.genesis_keys.genesis_vkeys[0],
cli_args=["--max-block-body-size", "65536"],
)

conway_vote = cluster.g_stake_address.gen_stake_and_vote_delegation_cert(
addr_name=f"{temp_template}_vote",
stake_vkey_file=stake_rec.vkey_file,
stake_pool_id=pool_id,
always_abstain=True,
)

tx_files = clusterlib.TxFiles(
certificate_files=[legacy_prop, conway_vote],
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,
)

err = str(excinfo.value)
assert "TextEnvelope type error" in err, err
Loading
Loading