@@ -205,10 +205,12 @@ mod tests {
205
205
"" ,
206
206
) ;
207
207
208
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
208
209
assert_eq ! (
209
210
hex:: encode( secp256k1_get_private_key( keypath) . unwrap( ) ) ,
210
211
"4604b4b710fe91f584fff084e1a9159fe4f8408fff380596a604948474ce4fa3"
211
212
) ;
213
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 1 ) ;
212
214
}
213
215
214
216
#[ test]
@@ -222,10 +224,12 @@ mod tests {
222
224
"" ,
223
225
) ;
224
226
227
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
225
228
assert_eq ! (
226
229
hex:: encode( secp256k1_get_private_key_twice( keypath) . unwrap( ) ) ,
227
230
"4604b4b710fe91f584fff084e1a9159fe4f8408fff380596a604948474ce4fa3"
228
231
) ;
232
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 2 ) ;
229
233
}
230
234
231
235
#[ test]
@@ -252,13 +256,19 @@ mod tests {
252
256
"sleep own lobster state clean thrive tail exist cactus bitter pass soccer clinic riot dream turkey before sport action praise tunnel hood donate man" ,
253
257
"" ,
254
258
) ;
259
+
260
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
261
+
255
262
assert_eq ! (
256
263
get_xpub_twice( & [ ] )
257
264
. unwrap( )
258
265
. serialize_str( bip32:: XPubType :: Xpub )
259
266
. unwrap( ) ,
260
267
"xpub661MyMwAqRbcEhX8d9WJh78SZrxusAzWFoykz4n5CF75uYRzixw5FZPUSoWyhaaJ1bpiPFdzdHSQqJN38PcTkyrLmxT4J2JDYfoGJQ4ioE2" ,
261
268
) ;
269
+
270
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 2 ) ;
271
+
262
272
assert_eq ! (
263
273
get_xpub_twice( keypath)
264
274
. unwrap( )
@@ -310,7 +320,10 @@ mod tests {
310
320
"purity concert above invest pigeon category peace tuition hazard vivid latin since legal speak nation session onion library travel spell region blast estate stay" ,
311
321
"" ,
312
322
) ;
323
+
324
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
313
325
assert_eq ! ( root_fingerprint( ) , Ok ( vec![ 0x02 , 0x40 , 0xe9 , 0x2a ] ) ) ;
326
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 2 ) ;
314
327
315
328
mock_unlocked_using_mnemonic (
316
329
"small agent wife animal marine cloth exit thank stool idea steel frame" ,
@@ -439,20 +452,37 @@ mod tests {
439
452
mock_memory ( ) ;
440
453
keystore:: lock ( ) ;
441
454
let seed = & seed[ ..test. seed_len ] ;
455
+
442
456
assert ! ( keystore:: unlock_bip39( test. mnemonic_passphrase) . is_err( ) ) ;
457
+
458
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
443
459
assert ! ( keystore:: encrypt_and_store_seed( seed, "foo" ) . is_ok( ) ) ;
460
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 11 ) ;
461
+
444
462
assert ! ( keystore:: unlock_bip39( test. mnemonic_passphrase) . is_err( ) ) ;
445
463
assert ! ( keystore:: is_locked( ) ) ;
464
+
465
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
446
466
assert ! ( keystore:: unlock( "foo" ) . is_ok( ) ) ;
467
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 6 ) ;
468
+
447
469
assert ! ( keystore:: is_locked( ) ) ;
470
+
471
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
448
472
assert ! ( keystore:: unlock_bip39( test. mnemonic_passphrase) . is_ok( ) ) ;
473
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 2 ) ;
474
+
449
475
assert ! ( !keystore:: is_locked( ) ) ;
450
476
assert_eq ! (
451
477
get_bip39_mnemonic( ) . unwrap( ) . as_str( ) ,
452
478
test. expected_mnemonic,
453
479
) ;
454
480
let keypath = & [ 44 + HARDENED , 0 + HARDENED , 0 + HARDENED ] ;
481
+
482
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
455
483
let xpub = get_xpub_once ( keypath) . unwrap ( ) ;
484
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 1 ) ;
485
+
456
486
assert_eq ! (
457
487
xpub. serialize_str( crate :: bip32:: XPubType :: Xpub ) . unwrap( ) ,
458
488
test. expected_xpub,
@@ -482,7 +512,11 @@ mod tests {
482
512
483
513
// Test without tweak
484
514
bitbox02:: random:: fake_reset ( ) ;
515
+
516
+ bitbox02:: securechip:: fake_event_counter_reset ( ) ;
485
517
let sig = secp256k1_schnorr_sign ( & keypath, & msg, None ) . unwrap ( ) ;
518
+ assert_eq ! ( bitbox02:: securechip:: fake_event_counter( ) , 1 ) ;
519
+
486
520
assert ! (
487
521
SECP256K1
488
522
. verify_schnorr(
0 commit comments