@@ -1162,22 +1162,13 @@ pub fn transactions_from_blocks<'a>(
11621162 } )
11631163}
11641164
1165- // FIXME: make it a generic to support V6?
1166- /// Modify a V5 transaction to insert fake Orchard shielded data.
1167- ///
11681165/// Creates a fake instance of [`orchard::ShieldedData`] with one fake action. Note that both the
11691166/// action and the shielded data are invalid and shouldn't be used in tests that require them to be
11701167/// valid.
1171- ///
1172- /// A mutable reference to the inserted shielded data is returned, so that the caller can further
1173- /// customize it if required.
1174- ///
1175- /// # Panics
1176- ///
1177- /// Panics if the transaction to be modified is not V5.
1178- pub fn insert_fake_orchard_shielded_data (
1179- transaction : & mut Transaction ,
1180- ) -> & mut orchard:: ShieldedData < orchard:: OrchardVanilla > {
1168+ pub fn create_fake_orchard_shielded_data < Flavor : orchard:: ShieldedDataFlavor + ' static > (
1169+ ) -> orchard:: ShieldedData < Flavor >
1170+ //where <<Flavor as orchard::ShieldedDataFlavor>::EncryptedNote as Arbitrary>::Strategy: 'static
1171+ {
11811172 // Create a dummy action
11821173 let mut runner = TestRunner :: default ( ) ;
11831174 let dummy_action = orchard:: Action :: arbitrary ( )
@@ -1192,7 +1183,7 @@ pub fn insert_fake_orchard_shielded_data(
11921183 } ;
11931184
11941185 // Place the dummy action inside the Orchard shielded data
1195- let dummy_shielded_data = orchard:: ShieldedData :: < orchard :: OrchardVanilla > {
1186+ orchard:: ShieldedData :: < Flavor > {
11961187 flags : orchard:: Flags :: empty ( ) ,
11971188 value_balance : Amount :: try_from ( 0 ) . expect ( "invalid transaction amount" ) ,
11981189 shared_anchor : orchard:: tree:: Root :: default ( ) ,
@@ -1201,15 +1192,27 @@ pub fn insert_fake_orchard_shielded_data(
12011192 binding_sig : Signature :: from ( [ 0u8 ; 64 ] ) ,
12021193 #[ cfg( all( zcash_unstable = "nu7" , feature = "tx_v6" ) ) ]
12031194 burn : Default :: default ( ) ,
1204- } ;
1195+ }
1196+ }
12051197
1198+ /// Modify a V5 transaction to insert fake Orchard shielded data.
1199+ ///
1200+ /// A mutable reference to the inserted shielded data is returned, so that the caller can further
1201+ /// customize it if required.
1202+ ///
1203+ /// # Panics
1204+ ///
1205+ /// Panics if the transaction to be modified is not V5.
1206+ pub fn insert_fake_v5_orchard_shielded_data (
1207+ transaction : & mut Transaction ,
1208+ ) -> & mut orchard:: ShieldedData < orchard:: OrchardVanilla > {
12061209 // Replace the shielded data in the transaction
12071210 match transaction {
12081211 Transaction :: V5 {
12091212 orchard_shielded_data,
12101213 ..
12111214 } => {
1212- * orchard_shielded_data = Some ( dummy_shielded_data ) ;
1215+ * orchard_shielded_data = Some ( create_fake_orchard_shielded_data ( ) ) ;
12131216
12141217 orchard_shielded_data
12151218 . as_mut ( )
@@ -1218,3 +1221,31 @@ pub fn insert_fake_orchard_shielded_data(
12181221 _ => panic ! ( "Fake V5 transaction is not V5" ) ,
12191222 }
12201223}
1224+
1225+ /// Modify a V6 transaction to insert fake Orchard shielded data.
1226+ ///
1227+ /// A mutable reference to the inserted shielded data is returned, so that the caller can further
1228+ /// customize it if required.
1229+ ///
1230+ /// # Panics
1231+ ///
1232+ /// Panics if the transaction to be modified is not V6.
1233+ #[ cfg( all( zcash_unstable = "nu7" , feature = "tx_v6" ) ) ]
1234+ pub fn insert_fake_v6_orchard_shielded_data (
1235+ transaction : & mut Transaction ,
1236+ ) -> & mut orchard:: ShieldedData < orchard:: OrchardZSA > {
1237+ // Replace the shielded data in the transaction
1238+ match transaction {
1239+ Transaction :: V6 {
1240+ orchard_shielded_data,
1241+ ..
1242+ } => {
1243+ * orchard_shielded_data = Some ( create_fake_orchard_shielded_data ( ) ) ;
1244+
1245+ orchard_shielded_data
1246+ . as_mut ( )
1247+ . expect ( "shielded data was just inserted" )
1248+ }
1249+ _ => panic ! ( "Fake V6 transaction is not V6" ) ,
1250+ }
1251+ }
0 commit comments