@@ -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+ )
719724class 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