Skip to content

Commit

Permalink
Restart simulator when testing wipe command twice
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-kaufman committed Aug 30, 2024
1 parent 7e61b2c commit e99761b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ jobs:
run: ./get_hwi.sh
- name: Test
run: cargo test --features ${{ matrix.rust.features }} -- --test-threads=1
- name: Wipe
run: cargo test test_wipe_device -- --ignored --test-threads=1
- name: Wipe python
run: cargo test test_wipe_device_pyhton -- --ignored --test-threads=1
- name: Restart simulator
run: docker restart simulator
- name: Wipe binary
run: cargo test test_wipe_device_binary -- --ignored --test-threads=1
test-readme-examples:
runs-on: ubuntu-22.04
steps:
Expand Down
55 changes: 33 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod tests {
use crate::error::Error;
use crate::implementations::binary_implementation::BinaryHWIImplementation;
use crate::implementations::python_implementation::PythonHWIImplementation;
use crate::types::{self, HWIBinaryExecutor, HWIDeviceType, TESTNET};
use crate::types::{self, HWIBinaryExecutor, HWIDeviceType, HWIImplementation, TESTNET};
use crate::HWIClient;
use std::collections::BTreeMap;
use std::str::FromStr;
Expand Down Expand Up @@ -447,27 +447,6 @@ mod tests {
}
}
}

#[test]
#[serial]
#[ignore]
fn test_wipe_device() {
let devices = HWIClient::<$impl>::enumerate().unwrap();
let unsupported = [
HWIDeviceType::Ledger,
HWIDeviceType::Coldcard,
HWIDeviceType::Jade,
];
for device in devices {
let device = device.unwrap();
if unsupported.contains(&device.device_type) {
// These devices don't support wipe
continue;
}
let client = HWIClient::<$impl>::get_client(&device, true, TESTNET).unwrap();
client.wipe_device().unwrap();
}
}
};
}

Expand Down Expand Up @@ -495,4 +474,36 @@ mod tests {
fn test_install_hwi() {
HWIClient::<PythonHWIImplementation>::install_hwilib(Some("2.1.1")).unwrap();
}

#[test]
#[serial]
#[ignore]
fn test_wipe_device_pyhton() {
wipe_device::<PythonHWIImplementation>();
}

#[test]
#[serial]
#[ignore]
fn test_wipe_device_binary() {
wipe_device::<BinaryHWIImplementation<HWIBinaryExecutorImpl>>();
}

fn wipe_device<T: HWIImplementation>() {
let devices = HWIClient::<T>::enumerate().unwrap();
let unsupported = [
HWIDeviceType::Ledger,
HWIDeviceType::Coldcard,
HWIDeviceType::Jade,
];
for device in devices {
let device = device.unwrap();
if unsupported.contains(&device.device_type) {
// These devices don't support wipe
continue;
}
let client = HWIClient::<T>::get_client(&device, true, TESTNET).unwrap();
client.wipe_device().unwrap();
}
}
}

0 comments on commit e99761b

Please sign in to comment.