@@ -28,26 +28,11 @@ use sp_std::vec;
28
28
29
29
use test_utils:: ias:: consts:: TEST8_MRENCLAVE ;
30
30
const USER_SEED : u32 = 9966 ;
31
- const VC_HASH : H256 = H256 :: zero ( ) ;
32
- const VC_INDEX : H256 = H256 :: zero ( ) ;
33
31
34
32
fn assert_last_event < T : Config > ( generic_event : <T as Config >:: RuntimeEvent ) {
35
33
frame_system:: Pallet :: < T > :: assert_last_event ( generic_event. into ( ) ) ;
36
34
}
37
35
38
- fn convert_u32_array_to_u8_array ( u32_array : [ u32 ; 8 ] ) -> [ u8 ; 32 ] {
39
- let mut u8_array = [ 0u8 ; 32 ] ;
40
- let mut index = 0 ;
41
-
42
- for u32_element in & u32_array {
43
- let u8_slice = u32_element. to_le_bytes ( ) ;
44
- u8_array[ index..index + 4 ] . copy_from_slice ( & u8_slice) ;
45
- index += 4 ;
46
- }
47
-
48
- u8_array
49
- }
50
-
51
36
benchmarks ! {
52
37
// Benchmark `add_delegatee`. There are no worst conditions. The benchmark showed that
53
38
// execution time is constant irrespective of encrypted_data size.
@@ -78,44 +63,16 @@ benchmarks! {
78
63
assert_last_event:: <T >( Event :: VCRequested { account, shard, assertion } . into( ) ) ;
79
64
}
80
65
81
- // Benchmark `disable_vc`. There are no worst conditions. The benchmark showed that
82
- // execution time is constant irrespective of encrypted_data size.
83
- disable_vc {
84
- let account: T :: AccountId = frame_benchmarking:: account( "TEST_A" , 0u32 , USER_SEED ) ;
85
- let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_A" , 0u32 , USER_SEED ) . into( ) ;
86
- let assertion = Assertion :: A1 ;
87
- let req_ext_hash = H256 :: default ( ) ;
88
- let tee_origin = T :: TEECallOrigin :: try_successful_origin( ) . map_err( |_| BenchmarkError :: Weightless ) ?;
89
- VCManagement :: <T >:: vc_issued( tee_origin, identity, assertion, VC_INDEX , VC_HASH , req_ext_hash) ?;
90
- } : _( RawOrigin :: Signed ( account. clone( ) ) , VC_INDEX )
91
- verify{
92
- assert_last_event:: <T >( Event :: VCDisabled { account, index: VC_HASH } . into( ) ) ;
93
- }
94
-
95
- // Benchmark `revoke_vc`. There are no worst conditions. The benchmark showed that
96
- // execution time is constant irrespective of encrypted_data size.
97
- revoke_vc {
98
- let account: T :: AccountId = frame_benchmarking:: account( "TEST_A" , 0u32 , USER_SEED ) ;
99
- let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_A" , 0u32 , USER_SEED ) . into( ) ;
100
- let assertion = Assertion :: A1 ;
101
- let req_ext_hash = H256 :: default ( ) ;
102
- let tee_origin = T :: TEECallOrigin :: try_successful_origin( ) . map_err( |_| BenchmarkError :: Weightless ) ?;
103
- VCManagement :: <T >:: vc_issued( tee_origin, identity, assertion, VC_INDEX , VC_HASH , req_ext_hash) ?;
104
- } : _( RawOrigin :: Signed ( account. clone( ) ) , VC_INDEX )
105
- verify{
106
- assert_last_event:: <T >( Event :: VCRevoked { account, index: VC_HASH } . into( ) ) ;
107
- }
108
-
109
66
// Benchmark `vc_issued`. There are no worst conditions. The benchmark showed that
110
67
// execution time is constant irrespective of encrypted_data size.
111
68
vc_issued {
112
69
let call_origin = T :: TEECallOrigin :: try_successful_origin( ) . map_err( |_| BenchmarkError :: Weightless ) ?;
113
70
let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_A" , 0u32 , USER_SEED ) . into( ) ;
114
71
let assertion = Assertion :: A1 ;
115
72
let req_ext_hash = H256 :: default ( ) ;
116
- } : _<T :: RuntimeOrigin >( call_origin, identity. clone( ) , assertion. clone( ) , VC_INDEX , VC_HASH , req_ext_hash)
73
+ } : _<T :: RuntimeOrigin >( call_origin, identity. clone( ) , assertion. clone( ) , req_ext_hash)
117
74
verify{
118
- assert_last_event:: <T >( Event :: VCIssued { identity, assertion, index : VC_INDEX , req_ext_hash} . into( ) ) ;
75
+ assert_last_event:: <T >( Event :: VCIssued { identity, assertion, req_ext_hash} . into( ) ) ;
119
76
}
120
77
121
78
// Benchmark `some_error`. There are no worst conditions. The benchmark showed that
@@ -199,48 +156,6 @@ benchmarks! {
199
156
assert_last_event:: <T >( Event :: SchemaRevoked { account, shard, index: 0 } . into( ) )
200
157
}
201
158
202
- // Benchmark `add_vc_registry_item`. There are no worst conditions. The benchmark showed that
203
- // execution time is constant irrespective of encrypted_data size.
204
- add_vc_registry_item {
205
- let account: T :: AccountId = frame_benchmarking:: account( "TEST_A" , 0u32 , USER_SEED ) ;
206
- let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_B" , 0u32 , USER_SEED ) . into( ) ;
207
- VCManagement :: <T >:: set_admin( RawOrigin :: Root . into( ) , account. clone( ) ) ?;
208
- let assertion = Assertion :: A1 ;
209
- } : _( RawOrigin :: Signed ( account. clone( ) ) , VC_INDEX , identity. clone( ) , assertion. clone( ) , VC_HASH )
210
- verify {
211
- assert_last_event:: <T >( Event :: VCRegistryItemAdded { identity, assertion, index: VC_INDEX } . into( ) )
212
- }
213
-
214
- // Benchmark `remove_vc_registry_item`. There are no worst conditions. The benchmark showed that
215
- // execution time is constant irrespective of encrypted_data size.
216
- remove_vc_registry_item {
217
- let account: T :: AccountId = frame_benchmarking:: account( "TEST_A" , 0u32 , USER_SEED ) ;
218
- let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_B" , 0u32 , USER_SEED ) . into( ) ;
219
- VCManagement :: <T >:: set_admin( RawOrigin :: Root . into( ) , account. clone( ) ) ?;
220
- let assertion = Assertion :: A1 ;
221
- VCManagement :: <T >:: add_vc_registry_item( RawOrigin :: Signed ( account. clone( ) ) . into( ) , VC_INDEX , identity, assertion, VC_HASH ) ?;
222
- } : _( RawOrigin :: Signed ( account) , VC_INDEX )
223
- verify {
224
- assert_last_event:: <T >( Event :: VCRegistryItemRemoved { index: VC_INDEX } . into( ) )
225
- }
226
-
227
- // Benchmark `clear_vc_registry`.
228
- clear_vc_registry {
229
- let x in 0 ..100u32 ;
230
- let account: T :: AccountId = frame_benchmarking:: account( "TEST_A" , 0u32 , USER_SEED ) ;
231
- VCManagement :: <T >:: set_admin( RawOrigin :: Root . into( ) , account. clone( ) ) ?;
232
- let assertion = Assertion :: A1 ;
233
- for i in 0 ..x {
234
- let seed = USER_SEED - i;
235
- let identity: Identity = frame_benchmarking:: account:: <AccountId >( "TEST_A" , 0u32 , seed) . into( ) ;
236
- let seed_hash_u8_32 = convert_u32_array_to_u8_array( [ seed; 8 ] ) ;
237
- let hash: H256 = seed_hash_u8_32. into( ) ;
238
- VCManagement :: <T >:: add_vc_registry_item( RawOrigin :: Signed ( account. clone( ) ) . into( ) , hash, identity, assertion. clone( ) , VC_HASH ) ?;
239
- }
240
- } : _( RawOrigin :: Signed ( account) )
241
- verify {
242
- assert_last_event:: <T >( Event :: VCRegistryCleared . into( ) )
243
- }
244
159
}
245
160
246
161
#[ cfg( test) ]
0 commit comments