Skip to content

Commit fdf5a43

Browse files
update compatible tests
1 parent ed180ab commit fdf5a43

File tree

2 files changed

+49
-78
lines changed

2 files changed

+49
-78
lines changed

cardano_node_tests/tests/tests_conway/test_pparam_update.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,27 +1436,16 @@ def test_pparam_keys(
14361436
class TestLegacyProposals:
14371437
"""Tests for legacy update proposals in Conway."""
14381438

1439-
@pytest.fixture(scope="class")
1440-
def skip_on_missing_legacy(self) -> None:
1441-
if not clusterlib_utils.cli_has("legacy governance"):
1442-
pytest.skip("`legacy governance` commands are not available")
1443-
14441439
@allure.link(helpers.get_vcs_link())
14451440
@submit_utils.PARAM_SUBMIT_METHOD
14461441
@pytest.mark.smoke
14471442
def test_legacy_proposal_submit(
14481443
self,
1449-
skip_on_missing_legacy: None, # noqa: ARG002
14501444
cluster: clusterlib.ClusterLib,
14511445
payment_addr: clusterlib.AddressRecord,
14521446
submit_method: str,
14531447
):
1454-
"""Test submitting a legacy update proposal in Conway.
1455-
1456-
Expect failure as the legacy update proposals are not supported in Conway.
1457-
"""
1458-
# TODO: convert to use
1459-
# `compatible babbage governance action create-protocol-parameters-update`
1448+
"""Test that a compatible Babbage pparam proposal cannot be submitted in Conway era."""
14601449
temp_template = common.get_test_id(cluster)
14611450

14621451
update_proposals = [
@@ -1468,43 +1457,35 @@ def test_legacy_proposal_submit(
14681457
]
14691458

14701459
cli_args = clusterlib_utils.get_pparams_update_args(update_proposals=update_proposals)
1471-
out_file = f"{temp_template}_update.proposal"
14721460

1473-
cluster.cli(
1474-
[
1475-
"cardano-cli",
1476-
"legacy",
1477-
"governance",
1478-
"create-update-proposal",
1479-
*cli_args,
1480-
"--out-file",
1481-
str(out_file),
1482-
"--epoch",
1483-
str(cluster.g_query.get_epoch()),
1484-
*helpers.prepend_flag(
1485-
"--genesis-verification-key-file",
1486-
cluster.g_genesis.genesis_keys.genesis_vkeys,
1487-
),
1488-
],
1489-
add_default_args=False,
1461+
# NEW: use compatible babbage pparam action
1462+
action_file = cluster.g_compatible.babbage.governance.action.gen_pparams_update(
1463+
name=temp_template,
1464+
epoch=cluster.g_query.get_epoch(),
1465+
genesis_vkey_file=cluster.g_genesis.genesis_keys.genesis_vkeys[0],
1466+
cli_args=cli_args,
14901467
)
14911468

1469+
# Submitting a Babbage-era proposal in Conway must fail
14921470
with pytest.raises((clusterlib.CLIError, submit_api.SubmitApiError)) as excinfo:
14931471
clusterlib_utils.build_and_submit_tx(
14941472
cluster_obj=cluster,
14951473
name_template=f"{temp_template}_submit_proposal",
14961474
src_address=payment_addr.address,
14971475
submit_method=submit_method,
14981476
tx_files=clusterlib.TxFiles(
1499-
proposal_files=[out_file],
1477+
proposal_files=[action_file],
15001478
signing_key_files=[
15011479
*cluster.g_genesis.genesis_keys.delegate_skeys,
15021480
pl.Path(payment_addr.skey_file),
15031481
],
15041482
),
15051483
)
1484+
15061485
err_str = str(excinfo.value)
1507-
assert 'TextEnvelopeType "UpdateProposalShelley"' in err_str, err_str
1486+
assert "era" in err_str or "mismatch" in err_str or "TextEnvelope type error" in err_str, (
1487+
err_str
1488+
)
15081489

15091490
@allure.link(helpers.get_vcs_link())
15101491
@pytest.mark.smoke

cardano_node_tests/tests/tests_conway/test_treasury_withdrawals.py

Lines changed: 36 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -716,80 +716,70 @@ def test_expire_treasury_withdrawals(
716716
[r.success() for r in (reqc.cip032ex, reqc.cip069ex)]
717717

718718

719+
@pytest.mark.parametrize("era", ["shelley", "mary", "alonzo", "babbage"])
720+
@pytest.mark.parametrize(
721+
"mir_cert",
722+
("to_treasury", "to_rewards", "treasury_to_addr", "reserves_to_addr"),
723+
)
719724
class TestMIRCerts:
720-
"""Tests for MIR certificates."""
725+
"""Tests for MIR certificates in all compatible eras."""
721726

722727
@pytest.fixture
723-
def payment_addr(
724-
self,
725-
cluster_manager: cluster_management.ClusterManager,
726-
cluster: clusterlib.ClusterLib,
727-
) -> clusterlib.AddressRecord:
728-
"""Create new payment address."""
729-
addr = common.get_payment_addr(
728+
def payment_addr(self, cluster_manager, cluster):
729+
return common.get_payment_addr(
730730
name_template=common.get_test_id(cluster),
731731
cluster_manager=cluster_manager,
732732
cluster_obj=cluster,
733733
caching_key=helpers.get_current_line_str(),
734734
amount=4_000_000,
735735
)
736-
return addr
737736

738737
@allure.link(helpers.get_vcs_link())
739-
@pytest.mark.parametrize(
740-
"mir_cert", ("to_treasury", "to_rewards", "treasury_to_addr", "reserves_to_addr")
741-
)
742738
@pytest.mark.smoke
743-
def test_mir_certificates(
744-
self,
745-
cluster: clusterlib.ClusterLib,
746-
payment_addr: clusterlib.AddressRecord,
747-
mir_cert: str,
748-
):
749-
"""Try to use MIR certificates in Conway+ eras.
750-
751-
Expect failure.
739+
def test_mir_certificates(self, cluster, payment_addr, era, mir_cert):
740+
"""
741+
Try each MIR certificate across all compatible eras.
752742
753-
* try and fail to build the Tx using `transaction build`
754-
* successfully build the Tx as Babbage Tx using compatible `signed-transaction`
755-
* try and fail to submit the Babbage Tx (expected era mismatch)
743+
Expected behavior:
744+
* Conway build fails with MIR (TextEnvelope type error)
745+
* Compatible <era> signed-transaction builds successfully
746+
* Submitting a non-Conway tx in Conway must fail (era mismatch)
756747
"""
757748
temp_template = common.get_test_id(cluster)
758749
amount = 1_500_000
759750

760751
reqc.cip070.start(url=helpers.get_vcs_link())
761752

762-
# Generate MIR certificate using compatible governance commands
753+
# Get compatible governance for selected era dynamically
754+
gov = getattr(cluster.g_compatible, era).governance
755+
756+
# Generate cert based on MIR type
763757
if mir_cert == "to_treasury":
764-
cert_file = cluster.g_compatible.babbage.governance.gen_mir_cert(
758+
cert_file = gov.gen_mir_cert_to_treasury(
765759
name=temp_template,
766-
subcommand="transfer-to-treasury",
767-
transfer_amt=amount,
760+
transfer=amount,
768761
)
769762
elif mir_cert == "to_rewards":
770-
cert_file = cluster.g_compatible.babbage.governance.gen_mir_cert(
763+
cert_file = gov.gen_mir_cert_to_rewards(
771764
name=temp_template,
772-
subcommand="transfer-to-rewards",
773-
transfer_amt=amount,
765+
transfer=amount,
774766
)
775767
elif mir_cert == "treasury_to_addr":
776-
cert_file = cluster.g_compatible.babbage.governance.gen_mir_cert(
768+
cert_file = gov.gen_mir_cert_stake_addr(
777769
name=temp_template,
778-
subcommand="stake-addresses",
779770
stake_address="stake_test1uzy5myemjnne3gr0jp7yhtznxx2lvx4qgv730jktsu46v5gaw7rmt",
780771
reward=amount,
781-
funds="treasury",
772+
use_treasury=True,
782773
)
783774
elif mir_cert == "reserves_to_addr":
784-
cert_file = cluster.g_compatible.babbage.governance.gen_mir_cert(
775+
cert_file = gov.gen_mir_cert_stake_addr(
785776
name=temp_template,
786-
subcommand="stake-addresses",
787777
stake_address="stake_test1uzy5myemjnne3gr0jp7yhtznxx2lvx4qgv730jktsu46v5gaw7rmt",
788778
reward=amount,
789-
funds="reserves",
779+
use_treasury=False,
790780
)
791781
else:
792-
msg = f"Unknown MIR certificate: {mir_cert}"
782+
msg = f"Unknown MIR certificate type: {mir_cert}"
793783
raise ValueError(msg)
794784

795785
tx_files = clusterlib.TxFiles(
@@ -800,33 +790,33 @@ def test_mir_certificates(
800790
],
801791
)
802792

803-
# Conway cannot build MIR Tx using the Conway `build` command, expect failure
793+
# Conway build MUST fail
804794
with pytest.raises(clusterlib.CLIError) as excinfo:
805795
cluster.g_transaction.build_tx(
806796
tx_name=temp_template,
807797
src_address=payment_addr.address,
808798
tx_files=tx_files,
809799
)
810-
err_build = str(excinfo.value)
811-
assert "TextEnvelope type error:" in err_build, err_build
800+
assert "TextEnvelope type error" in str(excinfo.value)
812801

813-
# Build a Babbage-era signed Tx using compatible signed-transaction
814-
signed_tx = cluster.g_compatible.babbage.transaction.gen_signed_tx(
802+
# Build signed tx using compatible <era> transaction command
803+
tx_builder = getattr(cluster.g_compatible, era).transaction
804+
signed_tx = tx_builder.gen_signed_tx(
815805
name=temp_template,
816806
src_address=payment_addr.address,
817807
txouts=[],
818808
tx_files=tx_files,
819809
fee=400_000,
820810
)
821811

822-
# Submitting this Babbage Tx in Conway should fail (era mismatch expected)
812+
# Submitting non-Conway tx in Conway MUST fail
823813
with pytest.raises(clusterlib.CLIError) as excinfo:
824814
cluster.g_transaction.submit_tx(
825815
tx_file=signed_tx.out_file,
826816
txins=signed_tx.txins,
827817
)
828-
err_submit = str(excinfo.value)
829-
assert "era" in err_submit or "mismatch" in err_submit, err_submit
818+
err = str(excinfo.value)
819+
assert "era" in err or "mismatch" in err
830820

831821
reqc.cip070.success()
832822

0 commit comments

Comments
 (0)