@@ -39,7 +39,8 @@ mod tests {
39
39
} ;
40
40
assert ! ( insert_proof. verify( ) . is_ok( ) ) ;
41
41
42
- let account_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
42
+ let account_tx =
43
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
43
44
44
45
let Proof :: Insert ( insert_proof) = tree. process_transaction ( account_tx) . unwrap ( ) else {
45
46
panic ! ( "Processing transaction did not return the expected insert proof" ) ;
@@ -63,8 +64,14 @@ mod tests {
63
64
let mut tree = KeyDirectoryTree :: new ( Arc :: new ( MockTreeStore :: default ( ) ) ) ;
64
65
let mut tx_builder = TransactionBuilder :: new ( ) ;
65
66
67
+ let service_signing_key = SigningKey :: new_ed25519 ( ) ;
68
+
66
69
let invalid_account_tx = tx_builder
67
- . create_account_with_random_key ( "acc_1" , "service_id_that_does_not_exist" )
70
+ . create_account_with_random_key (
71
+ "acc_1" ,
72
+ "service_id_that_does_not_exist" ,
73
+ & service_signing_key,
74
+ )
68
75
. build ( ) ;
69
76
70
77
let insertion_result = tree. process_transaction ( invalid_account_tx) ;
@@ -108,9 +115,10 @@ mod tests {
108
115
let mut tx_builder = TransactionBuilder :: new ( ) ;
109
116
110
117
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
111
- let account_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
118
+ let account_tx =
119
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
112
120
let account_with_same_id_tx =
113
- tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . build ( ) ;
121
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . build ( ) ;
114
122
115
123
let Proof :: Insert ( insert_proof) = tree. process_transaction ( service_tx) . unwrap ( ) else {
116
124
panic ! ( "Processing service registration failed" )
@@ -132,7 +140,8 @@ mod tests {
132
140
let mut tx_builder = TransactionBuilder :: new ( ) ;
133
141
134
142
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
135
- let acc_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
143
+ let acc_tx =
144
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
136
145
137
146
tree. process_transaction ( service_tx) . unwrap ( ) ;
138
147
tree. process_transaction ( acc_tx) . unwrap ( ) ;
@@ -161,8 +170,8 @@ mod tests {
161
170
162
171
// This is a signing key not known to the storage yet
163
172
let random_signing_key = SigningKey :: new_ed25519 ( ) ;
164
- // This transaction shall be invalid, because it is signed with a unknown key
165
- let invalid_key_tx = tx_builder. add_random_key ( "acc_1" , & random_signing_key, 0 ) . commit ( ) ;
173
+ // This transaction shall be invalid, because it is signed with an unknown key
174
+ let invalid_key_tx = tx_builder. add_random_key ( "acc_1" , & random_signing_key, 0 ) . build ( ) ;
166
175
167
176
let result = tree. process_transaction ( invalid_key_tx) ;
168
177
assert ! ( result. is_err( ) ) ;
@@ -187,8 +196,10 @@ mod tests {
187
196
let mut tx_builder = TransactionBuilder :: new ( ) ;
188
197
189
198
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
190
- let acc1_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
191
- let acc2_tx = tx_builder. create_account_with_random_key ( "acc_2" , "service_1" ) . commit ( ) ;
199
+ let acc1_tx =
200
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
201
+ let acc2_tx =
202
+ tx_builder. create_account_with_random_key_signed ( "acc_2" , "service_1" ) . commit ( ) ;
192
203
193
204
tree. process_transaction ( service_tx) . unwrap ( ) ;
194
205
@@ -224,8 +235,10 @@ mod tests {
224
235
let mut tx_builder = TransactionBuilder :: new ( ) ;
225
236
226
237
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
227
- let acc1_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
228
- let acc2_tx = tx_builder. create_account_with_random_key ( "acc_2" , "service_1" ) . commit ( ) ;
238
+ let acc1_tx =
239
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
240
+ let acc2_tx =
241
+ tx_builder. create_account_with_random_key_signed ( "acc_2" , "service_1" ) . commit ( ) ;
229
242
230
243
tree. process_transaction ( service_tx) . unwrap ( ) ;
231
244
tree. process_transaction ( acc1_tx) . unwrap ( ) ;
@@ -239,7 +252,7 @@ mod tests {
239
252
let last_proof = tree. process_transaction ( add_key_to_2_tx) . unwrap ( ) ;
240
253
241
254
// Update account_2 using the correct key index
242
- let Proof :: Insert ( insert_proof ) = last_proof else {
255
+ let Proof :: Update ( update_proof ) = last_proof else {
243
256
panic ! ( "Expetced insert proof for transaction" ) ;
244
257
} ;
245
258
@@ -251,7 +264,10 @@ mod tests {
251
264
252
265
assert ! ( matches!( get_result1, Found ( hc, _) if & hc == test_hashchain_acc1) ) ;
253
266
assert ! ( matches!( get_result2, Found ( hc, _) if & hc == test_hashchain_acc2) ) ;
254
- assert_eq ! ( insert_proof. new_root, tree. get_commitment( ) . unwrap( ) ) ;
267
+ assert_eq ! (
268
+ Digest :: from( update_proof. new_root) ,
269
+ tree. get_commitment( ) . unwrap( )
270
+ ) ;
255
271
}
256
272
257
273
#[ test]
@@ -260,7 +276,8 @@ mod tests {
260
276
let mut tx_builder = TransactionBuilder :: new ( ) ;
261
277
262
278
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
263
- let account1_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
279
+ let account1_tx =
280
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
264
281
265
282
tree. process_transaction ( service_tx) . unwrap ( ) ;
266
283
@@ -277,8 +294,10 @@ mod tests {
277
294
let mut tx_builder = TransactionBuilder :: new ( ) ;
278
295
279
296
let service_tx = tx_builder. register_service_with_random_keys ( "service_1" ) . commit ( ) ;
280
- let account1_tx = tx_builder. create_account_with_random_key ( "acc_1" , "service_1" ) . commit ( ) ;
281
- let account2_tx = tx_builder. create_account_with_random_key ( "acc_2" , "service_2" ) . commit ( ) ;
297
+ let account1_tx =
298
+ tx_builder. create_account_with_random_key_signed ( "acc_1" , "service_1" ) . commit ( ) ;
299
+ let account2_tx =
300
+ tx_builder. create_account_with_random_key_signed ( "acc_2" , "service_1" ) . commit ( ) ;
282
301
283
302
tree. process_transaction ( service_tx) . unwrap ( ) ;
284
303
0 commit comments