From 33528ee5feb350a6823539b162464db3588a71d5 Mon Sep 17 00:00:00 2001 From: Expenses Date: Sun, 22 Sep 2019 20:26:57 +1200 Subject: [PATCH 1/7] Migrated code and updated dependencies --- fixed-hash/Cargo.toml | 9 +++++---- fixed-hash/src/hash.rs | 2 +- fixed-hash/src/lib.rs | 21 ++++++++++----------- fixed-hash/src/tests.rs | 22 +++++++++++----------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index 9947ceaa2..8ba72d626 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fixed-hash" -version = "0.4.0" +version = "0.4.1" authors = ["Parity Technologies "] license = "MIT" homepage = "https://github.com/paritytech/parity-common" @@ -8,16 +8,17 @@ repository = "https://github.com/paritytech/parity-common" description = "Macros to define custom fixed-size hash types" documentation = "https://docs.rs/fixed-hash/" readme = "README.md" +edition = "2018" [package.metadata.docs.rs] features = ["quickcheck", "api-dummy"] [dependencies] -rand = { version = "0.5", optional = true, default-features = false } +rand = { version = "0.7", optional = true, default-features = false } rustc-hex = { version = "2.0", optional = true, default-features = false } -quickcheck = { version = "0.7", optional = true } +quickcheck = { version = "0.9", optional = true } byteorder = { version = "1.2", optional = true, default-features = false } -static_assertions = "0.2" +static_assertions = "0.3" [target.'cfg(not(target_os = "unknown"))'.dependencies] libc = { version = "0.2", optional = true, default-features = false } diff --git a/fixed-hash/src/hash.rs b/fixed-hash/src/hash.rs index 95c762848..521aeb308 100644 --- a/fixed-hash/src/hash.rs +++ b/fixed-hash/src/hash.rs @@ -512,7 +512,7 @@ macro_rules! impl_rand_for_fixed_hash { /// Assign `self` to a cryptographically random value. pub fn randomize(&mut self) { - let mut rng = $crate::rand::rngs::EntropyRng::new(); + let mut rng = $crate::rand::rngs::OsRng::default(); self.randomize_using(&mut rng); } diff --git a/fixed-hash/src/lib.rs b/fixed-hash/src/lib.rs index 061c33854..182c9ec7a 100644 --- a/fixed-hash/src/lib.rs +++ b/fixed-hash/src/lib.rs @@ -9,27 +9,26 @@ #![cfg_attr(not(feature = "std"), no_std)] // Re-export liballoc using an alias so that the macros can work without -// requiring `extern crate alloc` downstream. +// requiring `use alloc` downstream. #[cfg(not(feature = "std"))] #[doc(hidden)] -pub extern crate alloc as alloc_; +pub use alloc as alloc_; // Re-export libcore using an alias so that the macros can work without -// requiring `extern crate core` downstream. +// requiring `use core` downstream. #[doc(hidden)] -pub extern crate core as core_; +pub use core as core_; #[cfg(all(feature = "libc", not(target_os = "unknown")))] #[doc(hidden)] -pub extern crate libc; +pub use libc; // This disables a warning for unused #[macro_use(..)] // which is incorrect since the compiler does not check // for all available configurations. #[allow(unused_imports)] -#[macro_use(const_assert)] #[doc(hidden)] -pub extern crate static_assertions; +pub use static_assertions; // Export `const_assert` macro so that users of this crate do not // have to import the `static_assertions` crate themselves. @@ -38,7 +37,7 @@ pub use static_assertions::const_assert; #[cfg(feature = "byteorder")] #[doc(hidden)] -pub extern crate byteorder; +pub use byteorder; #[cfg(not(feature = "libc"))] #[doc(hidden)] @@ -46,15 +45,15 @@ pub mod libc {} #[cfg(feature = "rustc-hex")] #[doc(hidden)] -pub extern crate rustc_hex; +pub use rustc_hex; #[cfg(feature = "rand")] #[doc(hidden)] -pub extern crate rand; +pub use rand; #[cfg(feature = "quickcheck")] #[doc(hidden)] -pub extern crate quickcheck; +pub use quickcheck; #[macro_use] mod hash; diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index 66869d002..b1445f3e4 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -250,29 +250,29 @@ mod from_low_u64 { #[cfg(feature = "rand")] mod rand { use super::*; - use rand::{SeedableRng, XorShiftRng}; + use ::rand::{SeedableRng, rngs::StdRng}; #[test] fn random() { - let default_seed = ::Seed::default(); - let mut rng = XorShiftRng::from_seed(default_seed); + let default_seed = ::Seed::default(); + let mut rng = StdRng::from_seed(default_seed); assert_eq!( H32::random_using(&mut rng), - H32::from([0x43, 0xCA, 0x64, 0xED]) + H32::from([0x76, 0xa0, 0x40, 0x53]) ); } #[test] fn randomize() { - let default_seed = ::Seed::default(); - let mut rng = XorShiftRng::from_seed(default_seed); + let default_seed = ::Seed::default(); + let mut rng = StdRng::from_seed(default_seed); assert_eq!( { let mut ret = H32::zero(); ret.randomize_using(&mut rng); ret }, - H32::from([0x43, 0xCA, 0x64, 0xED]) + H32::from([0x76, 0xa0, 0x40, 0x53]) ) } } @@ -283,7 +283,7 @@ mod from_str { #[test] fn valid() { - use core_::str::FromStr; + use crate::core_::str::FromStr; assert_eq!( H64::from_str("0123456789ABCDEF").unwrap(), @@ -293,19 +293,19 @@ mod from_str { #[test] fn empty_str() { - use core_::str::FromStr; + use crate::core_::str::FromStr; assert!(H64::from_str("").is_err()) } #[test] fn invalid_digits() { - use core_::str::FromStr; + use crate::core_::str::FromStr; assert!(H64::from_str("Hello, World!").is_err()) } #[test] fn too_many_digits() { - use core_::str::FromStr; + use crate::core_::str::FromStr; assert!(H64::from_str("0123456789ABCDEF0").is_err()) } } From 57ae6b5a5d880318ac1054383eae8008bab5a21b Mon Sep 17 00:00:00 2001 From: Expenses Date: Sun, 22 Sep 2019 20:28:21 +1200 Subject: [PATCH 2/7] . --- fixed-hash/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index b1445f3e4..76086d8ea 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -250,7 +250,7 @@ mod from_low_u64 { #[cfg(feature = "rand")] mod rand { use super::*; - use ::rand::{SeedableRng, rngs::StdRng}; + use crate::rand::{SeedableRng, rngs::StdRng}; #[test] fn random() { From b18f039b1bfa14a487f5157af9a15de335f56ecd Mon Sep 17 00:00:00 2001 From: Expenses Date: Sun, 22 Sep 2019 21:00:50 +1200 Subject: [PATCH 3/7] Revert "." This reverts commit 57ae6b5a5d880318ac1054383eae8008bab5a21b. --- fixed-hash/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index 76086d8ea..b1445f3e4 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -250,7 +250,7 @@ mod from_low_u64 { #[cfg(feature = "rand")] mod rand { use super::*; - use crate::rand::{SeedableRng, rngs::StdRng}; + use ::rand::{SeedableRng, rngs::StdRng}; #[test] fn random() { From 2b82c6a18ddbb71aed9f3d8d8e9363f94f6e0b95 Mon Sep 17 00:00:00 2001 From: Expenses Date: Sun, 22 Sep 2019 21:08:07 +1200 Subject: [PATCH 4/7] Downgrade rand to 0.6 due to breaking changes with 0.7 --- fixed-hash/Cargo.toml | 2 +- fixed-hash/src/hash.rs | 2 +- fixed-hash/src/tests.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index 8ba72d626..d912ce643 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" features = ["quickcheck", "api-dummy"] [dependencies] -rand = { version = "0.7", optional = true, default-features = false } +rand = { version = "0.6", optional = true, default-features = false } rustc-hex = { version = "2.0", optional = true, default-features = false } quickcheck = { version = "0.9", optional = true } byteorder = { version = "1.2", optional = true, default-features = false } diff --git a/fixed-hash/src/hash.rs b/fixed-hash/src/hash.rs index 521aeb308..95c762848 100644 --- a/fixed-hash/src/hash.rs +++ b/fixed-hash/src/hash.rs @@ -512,7 +512,7 @@ macro_rules! impl_rand_for_fixed_hash { /// Assign `self` to a cryptographically random value. pub fn randomize(&mut self) { - let mut rng = $crate::rand::rngs::OsRng::default(); + let mut rng = $crate::rand::rngs::EntropyRng::new(); self.randomize_using(&mut rng); } diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index b1445f3e4..746fab641 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -258,7 +258,7 @@ mod rand { let mut rng = StdRng::from_seed(default_seed); assert_eq!( H32::random_using(&mut rng), - H32::from([0x76, 0xa0, 0x40, 0x53]) + H32::from([0x82, 0xa0, 0x7f, 0x0e]) ); } @@ -272,7 +272,7 @@ mod rand { ret.randomize_using(&mut rng); ret }, - H32::from([0x76, 0xa0, 0x40, 0x53]) + H32::from([0x82, 0xa0, 0x7f, 0x0e]) ) } } From 86b27e0c874cd41178a9063d6cfe8e9bbb572139 Mon Sep 17 00:00:00 2001 From: Ashley Date: Tue, 1 Oct 2019 09:55:44 +1300 Subject: [PATCH 5/7] Update fixed-hash/Cargo.toml Co-Authored-By: Andronik Ordian --- fixed-hash/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index d912ce643..5f70d9f57 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fixed-hash" -version = "0.4.1" +version = "0.5.0" authors = ["Parity Technologies "] license = "MIT" homepage = "https://github.com/paritytech/parity-common" From a9ee83f959bcb491f5b90b34be7f50a981fa949a Mon Sep 17 00:00:00 2001 From: Ashley Date: Mon, 7 Oct 2019 19:57:23 +1300 Subject: [PATCH 6/7] Fixed some things --- fixed-hash/src/lib.rs | 2 +- fixed-hash/src/tests.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fixed-hash/src/lib.rs b/fixed-hash/src/lib.rs index 495451ec5..f2ffdf218 100644 --- a/fixed-hash/src/lib.rs +++ b/fixed-hash/src/lib.rs @@ -12,7 +12,7 @@ // requiring `use alloc` downstream. #[cfg(not(feature = "std"))] #[doc(hidden)] -pub use alloc as alloc_; +pub extern crate alloc as alloc_; // Re-export libcore using an alias so that the macros can work without // requiring `use core` downstream. diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index e3c5dfe01..b1445f3e4 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -250,8 +250,7 @@ mod from_low_u64 { #[cfg(feature = "rand")] mod rand { use super::*; - use rand::SeedableRng; - use rand_xorshift::XorShiftRng; + use ::rand::{SeedableRng, rngs::StdRng}; #[test] fn random() { @@ -259,7 +258,7 @@ mod rand { let mut rng = StdRng::from_seed(default_seed); assert_eq!( H32::random_using(&mut rng), - H32::from([0x82, 0xa0, 0x7f, 0x0e]) + H32::from([0x76, 0xa0, 0x40, 0x53]) ); } @@ -273,7 +272,7 @@ mod rand { ret.randomize_using(&mut rng); ret }, - H32::from([0x82, 0xa0, 0x7f, 0x0e]) + H32::from([0x76, 0xa0, 0x40, 0x53]) ) } } From 04bf40ec06b1f52a4e80dd25b42860b6930faef9 Mon Sep 17 00:00:00 2001 From: Ashley Date: Mon, 7 Oct 2019 19:58:22 +1300 Subject: [PATCH 7/7] fix comment --- fixed-hash/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-hash/src/lib.rs b/fixed-hash/src/lib.rs index f2ffdf218..9c841f885 100644 --- a/fixed-hash/src/lib.rs +++ b/fixed-hash/src/lib.rs @@ -9,7 +9,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // Re-export liballoc using an alias so that the macros can work without -// requiring `use alloc` downstream. +// requiring `extern crate alloc` downstream. #[cfg(not(feature = "std"))] #[doc(hidden)] pub extern crate alloc as alloc_;