Skip to content

Commit e99761b

Browse files
committed
Restart simulator when testing wipe command twice
1 parent 7e61b2c commit e99761b

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ jobs:
8080
run: ./get_hwi.sh
8181
- name: Test
8282
run: cargo test --features ${{ matrix.rust.features }} -- --test-threads=1
83-
- name: Wipe
84-
run: cargo test test_wipe_device -- --ignored --test-threads=1
83+
- name: Wipe python
84+
run: cargo test test_wipe_device_pyhton -- --ignored --test-threads=1
85+
- name: Restart simulator
86+
run: docker restart simulator
87+
- name: Wipe binary
88+
run: cargo test test_wipe_device_binary -- --ignored --test-threads=1
8589
test-readme-examples:
8690
runs-on: ubuntu-22.04
8791
steps:

src/lib.rs

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mod tests {
5050
use crate::error::Error;
5151
use crate::implementations::binary_implementation::BinaryHWIImplementation;
5252
use crate::implementations::python_implementation::PythonHWIImplementation;
53-
use crate::types::{self, HWIBinaryExecutor, HWIDeviceType, TESTNET};
53+
use crate::types::{self, HWIBinaryExecutor, HWIDeviceType, HWIImplementation, TESTNET};
5454
use crate::HWIClient;
5555
use std::collections::BTreeMap;
5656
use std::str::FromStr;
@@ -447,27 +447,6 @@ mod tests {
447447
}
448448
}
449449
}
450-
451-
#[test]
452-
#[serial]
453-
#[ignore]
454-
fn test_wipe_device() {
455-
let devices = HWIClient::<$impl>::enumerate().unwrap();
456-
let unsupported = [
457-
HWIDeviceType::Ledger,
458-
HWIDeviceType::Coldcard,
459-
HWIDeviceType::Jade,
460-
];
461-
for device in devices {
462-
let device = device.unwrap();
463-
if unsupported.contains(&device.device_type) {
464-
// These devices don't support wipe
465-
continue;
466-
}
467-
let client = HWIClient::<$impl>::get_client(&device, true, TESTNET).unwrap();
468-
client.wipe_device().unwrap();
469-
}
470-
}
471450
};
472451
}
473452

@@ -495,4 +474,36 @@ mod tests {
495474
fn test_install_hwi() {
496475
HWIClient::<PythonHWIImplementation>::install_hwilib(Some("2.1.1")).unwrap();
497476
}
477+
478+
#[test]
479+
#[serial]
480+
#[ignore]
481+
fn test_wipe_device_pyhton() {
482+
wipe_device::<PythonHWIImplementation>();
483+
}
484+
485+
#[test]
486+
#[serial]
487+
#[ignore]
488+
fn test_wipe_device_binary() {
489+
wipe_device::<BinaryHWIImplementation<HWIBinaryExecutorImpl>>();
490+
}
491+
492+
fn wipe_device<T: HWIImplementation>() {
493+
let devices = HWIClient::<T>::enumerate().unwrap();
494+
let unsupported = [
495+
HWIDeviceType::Ledger,
496+
HWIDeviceType::Coldcard,
497+
HWIDeviceType::Jade,
498+
];
499+
for device in devices {
500+
let device = device.unwrap();
501+
if unsupported.contains(&device.device_type) {
502+
// These devices don't support wipe
503+
continue;
504+
}
505+
let client = HWIClient::<T>::get_client(&device, true, TESTNET).unwrap();
506+
client.wipe_device().unwrap();
507+
}
508+
}
498509
}

0 commit comments

Comments
 (0)