@@ -189,4 +189,43 @@ mod benches {
189189 // 9) Assert: submission consumed.
190190 assert ! ( Submissions :: <T >:: get( id) . is_none( ) ) ;
191191 }
192+
193+ /// Benchmark `mark_decryption_failed`.
194+ #[ benchmark]
195+ fn mark_decryption_failed ( ) {
196+ // Any account can be the author of the submission.
197+ let who: T :: AccountId = whitelisted_caller ( ) ;
198+ let submitted_in: BlockNumberFor < T > = frame_system:: Pallet :: < T > :: block_number ( ) ;
199+
200+ // Build a dummy commitment and ciphertext.
201+ let commitment: T :: Hash =
202+ <T as frame_system:: Config >:: Hashing :: hash ( b"bench-mark-decryption-failed" ) ;
203+ const CT_DEFAULT_LEN : usize = 32 ;
204+ let ciphertext: BoundedVec < u8 , ConstU32 < 8192 > > =
205+ BoundedVec :: truncate_from ( vec ! [ 0u8 ; CT_DEFAULT_LEN ] ) ;
206+
207+ // Compute the submission id exactly like `submit_encrypted` does.
208+ let id: T :: Hash =
209+ <T as frame_system:: Config >:: Hashing :: hash_of ( & ( who. clone ( ) , commitment, & ciphertext) ) ;
210+
211+ // Seed Submissions with an entry for this id.
212+ let sub = Submission :: < T :: AccountId , BlockNumberFor < T > , <T as frame_system:: Config >:: Hash > {
213+ author : who,
214+ commitment,
215+ ciphertext : ciphertext. clone ( ) ,
216+ submitted_in,
217+ } ;
218+ Submissions :: < T > :: insert ( id, sub) ;
219+
220+ // Reason for failure.
221+ let reason: BoundedVec < u8 , ConstU32 < 256 > > =
222+ BoundedVec :: truncate_from ( b"benchmark-decryption-failed" . to_vec ( ) ) ;
223+
224+ // Measure: dispatch the unsigned extrinsic.
225+ #[ extrinsic_call]
226+ mark_decryption_failed ( RawOrigin :: None , id, reason) ;
227+
228+ // Assert: submission is removed.
229+ assert ! ( Submissions :: <T >:: get( id) . is_none( ) ) ;
230+ }
192231}
0 commit comments