@@ -277,16 +277,10 @@ mod tests {
277277 async fn test_new_command ( ) {
278278 let rng = & mut rand:: thread_rng ( ) ;
279279 let chain_code = rand_chaincode ( rng) ;
280- for card_type in [
281- CardTypeOption :: SatsCard ,
282- CardTypeOption :: TapSigner ,
283- CardTypeOption :: SatsChip ,
284- ] {
280+ for card_type in CardTypeOption :: values ( ) {
285281 let pipe_path = format ! ( "/tmp/test-new-command-pipe{card_type}" ) ;
286282 let pipe_path = Path :: new ( & pipe_path) ;
287- // Only SatsCard is expected to be initialized
288- let no_init = card_type != CardTypeOption :: SatsCard ;
289- let python = EcardSubprocess :: new ( pipe_path, & card_type, no_init) . unwrap ( ) ;
283+ let python = EcardSubprocess :: new ( pipe_path, & card_type) . unwrap ( ) ;
290284 let emulator = find_emulator ( pipe_path) . await . unwrap ( ) ;
291285 match emulator {
292286 CkTapCard :: SatsCard ( mut sc) => {
@@ -321,6 +315,39 @@ mod tests {
321315 }
322316 }
323317
318+ #[ tokio:: test]
319+ async fn test_cert_command ( ) {
320+ for card_type in CardTypeOption :: values ( ) {
321+ let emulator_root_pubkey =
322+ "0312d005ca1501b1603c3b00412eefe27c6b20a74c29377263b357b3aff12de6fa" . to_string ( ) ;
323+ let pipe_path = format ! ( "/tmp/test-cert-command-pipe{card_type}" ) ;
324+ let pipe_path = Path :: new ( & pipe_path) ;
325+ let python = EcardSubprocess :: new ( pipe_path, & card_type) . unwrap ( ) ;
326+ let emulator = find_emulator ( pipe_path) . await . unwrap ( ) ;
327+ match emulator {
328+ CkTapCard :: SatsCard ( mut sc) => {
329+ assert_eq ! ( card_type, CardTypeOption :: SatsCard ) ;
330+ let response = sc. check_certificate ( ) . await ;
331+ assert ! ( response. is_err( ) ) ;
332+ matches ! ( response, Err ( Error :: InvalidRootCert ( pubkey) ) if pubkey == emulator_root_pubkey) ;
333+ }
334+ CkTapCard :: TapSigner ( mut ts) => {
335+ assert_eq ! ( card_type, CardTypeOption :: TapSigner ) ;
336+ let response = ts. check_certificate ( ) . await ;
337+ assert ! ( response. is_err( ) ) ;
338+ matches ! ( response, Err ( Error :: InvalidRootCert ( pubkey) ) if pubkey == emulator_root_pubkey) ;
339+ }
340+ CkTapCard :: SatsChip ( mut sc) => {
341+ assert_eq ! ( card_type, CardTypeOption :: SatsChip ) ;
342+ let response = sc. check_certificate ( ) . await ;
343+ assert ! ( response. is_err( ) ) ;
344+ matches ! ( response, Err ( Error :: InvalidRootCert ( pubkey) ) if pubkey == emulator_root_pubkey) ;
345+ }
346+ } ;
347+ drop ( python) ;
348+ }
349+ }
350+
324351 // #[test]
325352 // fn test_tapsigner_signature() {
326353 // let card_pubkey = PublicKey::from_slice(
0 commit comments