projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Push the route benchmark results into a separate uninlined function
[rust-lightning]
/
lightning-block-sync
/
src
/
utils.rs
diff --git
a/lightning-block-sync/src/utils.rs
b/lightning-block-sync/src/utils.rs
index b841f5f9d413d90dfa45ebe8cf18516490a9092e..98a720a2eb2778a48224bf91b963e35b72c2954c 100644
(file)
--- a/
lightning-block-sync/src/utils.rs
+++ b/
lightning-block-sync/src/utils.rs
@@
-1,7
+1,7
@@
-use bitcoin::hashes::hex::
FromHex
;
+use bitcoin::hashes::hex::
{FromHex, HexToArrayError}
;
use bitcoin::pow::Work;
use bitcoin::pow::Work;
-pub fn hex_to_work(hex: &str) -> Result<Work,
bitcoin::hashes::hex::
Error> {
+pub fn hex_to_work(hex: &str) -> Result<Work,
HexToArray
Error> {
let bytes = <[u8; 32]>::from_hex(hex)?;
Ok(Work::from_be_bytes(bytes))
}
let bytes = <[u8; 32]>::from_hex(hex)?;
Ok(Work::from_be_bytes(bytes))
}
@@
-9,6
+9,7
@@
pub fn hex_to_work(hex: &str) -> Result<Work, bitcoin::hashes::hex::Error> {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(test)]
mod tests {
use super::*;
+ use bitcoin::hashes::hex::HexToBytesError;
use bitcoin::pow::Work;
#[test]
use bitcoin::pow::Work;
#[test]
@@
-19,25
+20,25
@@
mod tests {
#[test]
fn hex_to_work_too_short_str() {
let hex = String::from_utf8(vec![b'0'; 32]).unwrap();
#[test]
fn hex_to_work_too_short_str() {
let hex = String::from_utf8(vec![b'0'; 32]).unwrap();
- assert_eq!(hex_to_work(&hex), Err(
bitcoin::hashes::hex::Error::InvalidLength(64, 32
)));
+ assert_eq!(hex_to_work(&hex), Err(
HexToArrayError::InvalidLength(32, 64
)));
}
#[test]
fn hex_to_work_too_long_str() {
let hex = String::from_utf8(vec![b'0'; 128]).unwrap();
}
#[test]
fn hex_to_work_too_long_str() {
let hex = String::from_utf8(vec![b'0'; 128]).unwrap();
- assert_eq!(hex_to_work(&hex), Err(
bitcoin::hashes::hex::Error::InvalidLength(64, 128
)));
+ assert_eq!(hex_to_work(&hex), Err(
HexToArrayError::InvalidLength(128, 64
)));
}
#[test]
fn hex_to_work_odd_length_str() {
let hex = String::from_utf8(vec![b'0'; 65]).unwrap();
}
#[test]
fn hex_to_work_odd_length_str() {
let hex = String::from_utf8(vec![b'0'; 65]).unwrap();
- assert_eq!(hex_to_work(&hex), Err(
bitcoin::hashes::hex::Error::OddLengthString(65
)));
+ assert_eq!(hex_to_work(&hex), Err(
HexToArrayError::Conversion(HexToBytesError::OddLengthString(65)
)));
}
#[test]
fn hex_to_work_invalid_char() {
let hex = String::from_utf8(vec![b'G'; 64]).unwrap();
}
#[test]
fn hex_to_work_invalid_char() {
let hex = String::from_utf8(vec![b'G'; 64]).unwrap();
- assert_eq!(hex_to_work(&hex), Err(
bitcoin::hashes::hex::Error::InvalidChar(b'G'
)));
+ assert_eq!(hex_to_work(&hex), Err(
HexToArrayError::Conversion(HexToBytesError::InvalidChar(b'G')
)));
}
#[test]
}
#[test]