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

Commit 01c52c2

Browse files
committed
ledger test is broken, add correct logging format
* 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
1 parent d870e42 commit 01c52c2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

hw/src/ledger.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Manager {
124124
// More info can be found: <http://libusb.sourceforge.net/api-1.0/group__hotplug.html#gae6c5f1add6cc754005549c7259dc35ea>
125125
usb_context.register_callback(
126126
Some(LEDGER_VID), None, Some(USB_DEVICE_CLASS_DEVICE),
127-
Box::new(EventHandler::new(Arc::downgrade(&manager))))?;
127+
Box::new(EventHandler::new(Arc::downgrade(&manager)))).expect("usb_callback");
128128

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

327327
}
328-
Err(e) => debug!("Error reading device info: {}", e),
328+
Err(e) => debug!(target: "hw", "Error reading device info: {}", e),
329329
};
330330
}
331331
*self.devices.write() = new_devices;
@@ -444,9 +444,11 @@ impl libusb::Hotplug for EventHandler {
444444
#[test]
445445
fn smoke() {
446446
use rustc_hex::FromHex;
447-
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new().unwrap()));
448-
let manager = Manager::new(hidapi.clone(), Arc::new(AtomicBool::new(false))).unwrap();
449-
manager.update_devices().unwrap();
447+
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new().expect("HidApi couldn't be instanced")));
448+
let manager = Manager::new(hidapi.clone(), Arc::new(AtomicBool::new(false))).expect("Ledger::Manager");
449+
450+
assert_eq!(try_connect_polling(manager.clone(), Duration::from_millis(500)), true);
451+
450452
for d in &*manager.devices.read() {
451453
println!("Device: {:?}", d);
452454
}

0 commit comments

Comments
 (0)