@@ -6,6 +6,7 @@ use ic_management_canister_types::{VetKdCurve, VetKdKeyId};
6
6
use ic_types:: crypto:: threshold_sig:: ni_dkg:: { NiDkgId , NiDkgTargetId , NiDkgTargetSubnet } ;
7
7
use ic_types:: Height ;
8
8
use ic_types_test_utils:: ids:: { node_test_id, SUBNET_1 } ;
9
+ use sign:: tests:: { REG_V1 , REG_V2 } ;
9
10
use strum:: { EnumCount , IntoEnumIterator } ;
10
11
11
12
const NODE_1 : u64 = 1 ;
@@ -42,7 +43,7 @@ fn should_contain_transcript_data_after_insertion_with_nidkg_id() {
42
43
43
44
let dkg_id = ni_dkg_id_with_tag ( tag. clone ( ) , 42 ) ;
44
45
45
- store. insert_transcript_data ( & dkg_id, public_coeffs. clone ( ) , indices) ;
46
+ store. insert_transcript_data ( & dkg_id, public_coeffs. clone ( ) , indices, REG_V1 ) ;
46
47
47
48
let transcript_data = store. transcript_data ( & dkg_id) . unwrap ( ) ;
48
49
assert_eq ! ( transcript_data. public_coefficients( ) , & public_coeffs) ;
@@ -54,6 +55,7 @@ fn should_contain_transcript_data_after_insertion_with_nidkg_id() {
54
55
transcript_data. index( node_test_id( NODE_2 ) ) ,
55
56
Some ( & NODE_2_INDEX )
56
57
) ;
58
+ assert_eq ! ( transcript_data. registry_version( ) , REG_V1 ) ;
57
59
}
58
60
}
59
61
@@ -127,8 +129,8 @@ fn should_overwrite_existing_public_coefficients() {
127
129
assert_ne ! ( public_coeffs_1, public_coeffs_2) ;
128
130
let ni_dkg_id = ni_dkg_id_with_tag ( tag. clone ( ) , 1 ) ;
129
131
130
- store. insert_transcript_data ( & ni_dkg_id, public_coeffs_1, BTreeMap :: new ( ) ) ;
131
- store. insert_transcript_data ( & ni_dkg_id, public_coeffs_2. clone ( ) , BTreeMap :: new ( ) ) ;
132
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs_1, BTreeMap :: new ( ) , REG_V1 ) ;
133
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs_2. clone ( ) , BTreeMap :: new ( ) , REG_V1 ) ;
132
134
133
135
let transcript_data = store. transcript_data ( & ni_dkg_id) . unwrap ( ) ;
134
136
assert_eq ! ( transcript_data. public_coefficients( ) , & public_coeffs_2) ;
@@ -144,8 +146,8 @@ fn should_overwrite_existing_indices() {
144
146
let public_coeffs = public_coeffs ( ) ;
145
147
let ni_dkg_id = ni_dkg_id_with_tag ( tag. clone ( ) , 1 ) ;
146
148
147
- store. insert_transcript_data ( & ni_dkg_id, public_coeffs. clone ( ) , indices_1) ;
148
- store. insert_transcript_data ( & ni_dkg_id, public_coeffs, indices_2) ;
149
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs. clone ( ) , indices_1, REG_V1 ) ;
150
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs, indices_2, REG_V1 ) ;
149
151
150
152
let transcript_data = store. transcript_data ( & ni_dkg_id) . unwrap ( ) ;
151
153
assert_eq ! ( transcript_data. index( node_test_id( NODE_1 ) ) , None ) ;
@@ -156,6 +158,22 @@ fn should_overwrite_existing_indices() {
156
158
}
157
159
}
158
160
161
+ #[ test]
162
+ fn should_overwrite_existing_registry_version ( ) {
163
+ for tag in all_tags ( ) {
164
+ let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
165
+ let ( reg_v1, reg_v2) = ( REG_V1 , REG_V2 ) ;
166
+ assert_ne ! ( reg_v1, reg_v2) ;
167
+ let ni_dkg_id = ni_dkg_id_with_tag ( tag. clone ( ) , 1 ) ;
168
+
169
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs ( ) , BTreeMap :: new ( ) , reg_v1) ;
170
+ store. insert_transcript_data ( & ni_dkg_id, public_coeffs ( ) , BTreeMap :: new ( ) , reg_v2) ;
171
+
172
+ let transcript_data = store. transcript_data ( & ni_dkg_id) . unwrap ( ) ;
173
+ assert_eq ! ( transcript_data. registry_version( ) , reg_v2) ;
174
+ }
175
+ }
176
+
159
177
#[ test]
160
178
fn should_overwrite_existing_individual_public_keys ( ) {
161
179
for tag in all_tags ( ) {
@@ -176,7 +194,7 @@ fn should_overwrite_existing_individual_public_keys() {
176
194
}
177
195
178
196
#[ test]
179
- fn should_not_purge_data_on_inserting_coeffs_and_indices_if_capacity_not_exceeded ( ) {
197
+ fn should_not_purge_data_on_inserting_transcript_data_if_capacity_not_exceeded ( ) {
180
198
for tag in all_tags ( ) {
181
199
let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
182
200
@@ -185,6 +203,7 @@ fn should_not_purge_data_on_inserting_coeffs_and_indices_if_capacity_not_exceede
185
203
& ni_dkg_id_with_tag ( tag. clone ( ) , i) ,
186
204
public_coeffs ( ) ,
187
205
BTreeMap :: new ( ) ,
206
+ REG_V1 ,
188
207
) ;
189
208
}
190
209
@@ -216,16 +235,18 @@ fn should_not_purge_data_on_inserting_pubkeys_if_capacity_not_exceeded() {
216
235
}
217
236
218
237
#[ test]
219
- fn should_purge_data_on_inserting_coeffs_and_indices_if_capacity_exceeded ( ) {
238
+ fn should_purge_data_on_inserting_transcript_data_if_capacity_exceeded ( ) {
220
239
for tag in all_tags ( ) {
221
240
let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
222
241
let pub_coeffs = public_coeffs ( ) ;
242
+ let registry_version = REG_V1 ;
223
243
224
244
for i in 1 ..=ThresholdSigDataStoreImpl :: CAPACITY_PER_TAG_OR_KEY + 1 {
225
245
store. insert_transcript_data (
226
246
& ni_dkg_id_with_tag ( tag. clone ( ) , i) ,
227
247
pub_coeffs. clone ( ) ,
228
248
BTreeMap :: new ( ) ,
249
+ registry_version,
229
250
) ;
230
251
}
231
252
@@ -246,16 +267,18 @@ fn should_purge_data_on_inserting_coeffs_and_indices_if_capacity_exceeded() {
246
267
}
247
268
248
269
#[ test]
249
- fn should_purge_data_in_insertion_order_on_inserting_coeffs_and_indices_if_capacity_exceeded ( ) {
270
+ fn should_purge_data_in_insertion_order_on_inserting_transcript_data_if_capacity_exceeded ( ) {
250
271
for tag in all_tags ( ) {
251
272
let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
252
273
let pub_coeffs = public_coeffs ( ) ;
274
+ let registry_version = REG_V1 ;
253
275
254
276
for i in ( 1 ..=ThresholdSigDataStoreImpl :: CAPACITY_PER_TAG_OR_KEY + 1 ) . rev ( ) {
255
277
store. insert_transcript_data (
256
278
& ni_dkg_id_with_tag ( tag. clone ( ) , i) ,
257
279
pub_coeffs. clone ( ) ,
258
280
BTreeMap :: new ( ) ,
281
+ registry_version,
259
282
) ;
260
283
}
261
284
@@ -284,17 +307,20 @@ fn should_not_purge_all_transcripts_of_certain_threshold_if_capacity_exceeded(
284
307
) {
285
308
let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
286
309
let pub_coeffs = public_coeffs ( ) ;
310
+ let registry_version = REG_V1 ;
287
311
288
312
store. insert_transcript_data (
289
313
& ni_dkg_id_with_tag ( single_transcript_threshold. clone ( ) , 1 ) ,
290
314
pub_coeffs. clone ( ) ,
291
315
BTreeMap :: new ( ) ,
316
+ registry_version,
292
317
) ;
293
318
for i in 0 ..ThresholdSigDataStoreImpl :: CAPACITY_PER_TAG_OR_KEY + 1 {
294
319
store. insert_transcript_data (
295
320
& ni_dkg_id_with_tag ( other_transcripts_threshold. clone ( ) , i) ,
296
321
pub_coeffs. clone ( ) ,
297
322
BTreeMap :: new ( ) ,
323
+ registry_version,
298
324
) ;
299
325
}
300
326
@@ -409,13 +435,15 @@ fn should_purge_data_in_insertion_order_on_inserting_pubkeys_if_max_size_exceede
409
435
fn should_store_up_to_capacity_per_tag_for_all_tags ( ) {
410
436
let mut store = ThresholdSigDataStoreImpl :: new ( ) ;
411
437
let pub_coeffs = public_coeffs ( ) ;
438
+ let registry_version = REG_V1 ;
412
439
413
440
for i in 0 ..ThresholdSigDataStoreImpl :: CAPACITY_PER_TAG_OR_KEY {
414
441
for tag in all_tags ( ) {
415
442
store. insert_transcript_data (
416
443
& ni_dkg_id_with_tag ( tag. clone ( ) , i) ,
417
444
pub_coeffs. clone ( ) ,
418
445
BTreeMap :: new ( ) ,
446
+ registry_version,
419
447
) ;
420
448
}
421
449
}
@@ -430,6 +458,7 @@ fn should_store_up_to_capacity_per_tag_for_all_tags() {
430
458
& ni_dkg_id_with_tag ( tag, ThresholdSigDataStoreImpl :: CAPACITY_PER_TAG_OR_KEY ) ,
431
459
pub_coeffs. clone ( ) ,
432
460
BTreeMap :: new ( ) ,
461
+ registry_version,
433
462
) ;
434
463
}
435
464
0 commit comments