Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
ledger test is broken, add correct loggin format
Browse files Browse the repository at this point in the history
* So locally on my machine Linux Ubuntu 17.10 the test doesn't panic but on the CI server libusb::Context::new()
fails which I don't understand because it has worked before
* Additionally the ledger test is optional so I lean toward ignoring it the CI Server
  • Loading branch information
niklasad1 committed Mar 27, 2018
1 parent 844a90a commit 763d880
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions hw/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Manager {
// More info can be found: <http://libusb.sourceforge.net/api-1.0/group__hotplug.html#gae6c5f1add6cc754005549c7259dc35ea>
usb_context.register_callback(
Some(LEDGER_VID), None, Some(USB_DEVICE_CLASS_DEVICE),
Box::new(EventHandler::new(Arc::downgrade(&manager))))?;
Box::new(EventHandler::new(Arc::downgrade(&manager)))).expect("usb_callback");

// Ledger event handler thread
thread::Builder::new()
Expand Down Expand Up @@ -213,7 +213,7 @@ impl Manager {
return Err(Error::Protocol("No status word"));
}
let status = (message[message.len() - 2] as usize) << 8 | (message[message.len() - 1] as usize);
debug!("Read status {:x}", status);
debug!(target: "hw", "Read status {:x}", status);
match status {
0x6700 => Err(Error::Protocol("Incorrect length")),
0x6982 => Err(Error::Protocol("Security status not satisfied (Canceled by user)")),
Expand Down Expand Up @@ -318,14 +318,14 @@ impl <'a>Wallet<'a> for Manager {
}
match self.read_device(&usb, &device) {
Ok(info) => {
debug!("Found device: {:?}", info);
debug!(target: "hw", "Found device: {:?}", info);
if !self.devices.read().iter().any(|d| d.path == info.path) {
num_new_devices += 1;
}
new_devices.push(info);

}
Err(e) => debug!("Error reading device info: {}", e),
Err(e) => debug!(target: "hw", "Error reading device info: {}", e),
};
}
*self.devices.write() = new_devices;
Expand Down Expand Up @@ -444,9 +444,11 @@ impl libusb::Hotplug for EventHandler {
#[test]
fn smoke() {
use rustc_hex::FromHex;
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new().unwrap()));
let manager = Manager::new(hidapi.clone(), Arc::new(AtomicBool::new(false))).unwrap();
manager.update_devices().unwrap();
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new().expect("HidApi couldn't be instanced")));
let manager = Manager::new(hidapi.clone(), Arc::new(AtomicBool::new(false))).expect("Ledger::Manager");

assert_eq!(try_connect_polling(manager.clone(), Duration::from_millis(500)), true);

for d in &*manager.devices.read() {
println!("Device: {:?}", d);
}
Expand Down

0 comments on commit 763d880

Please sign in to comment.