From 5dcdac9c74bafcaa1daeb0a093825adb041d8240 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 9 Feb 2024 18:30:16 +0000 Subject: [PATCH 1/2] Fix MSRV build and tests --- contrib/test.sh | 21 ++++++++++++++++++--- src/language/mod.rs | 4 ++-- src/lib.rs | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/contrib/test.sh b/contrib/test.sh index 6784190..63bf7c5 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -2,14 +2,15 @@ set -ex -FEATURES="serde rand zeroize all-languages chinese-simplified chinese-traditional czech french italian japanese korean portuguese spanish" +FEATURES="serde rand all-languages chinese-simplified chinese-traditional czech french italian japanese korean portuguese spanish" cargo --version rustc --version # Pin dependencies as required if we are using MSRV toolchain. -# if cargo --version | grep "1\.41"; then -# fi +if cargo --version | grep "1\.41"; then + cargo update --package "bitcoin_hashes" --precise "0.12.0" +fi echo "********* Testing std *************" # Test without any features other than std first @@ -19,6 +20,16 @@ echo "********* Testing default *************" # Then test with the default features cargo test --verbose +# Build specific features +for feature in ${FEATURES} +do + cargo build --verbose --features="$feature" --no-default-features +done + +if cargo --version | grep -v "1\.41"; then + cargo build --verbose --features="zeroize" --no-default-features +fi + if [ "$DO_NO_STD" = true ] then echo "********* Testing no-std build *************" @@ -38,6 +49,10 @@ then do cargo build --verbose --features="$feature" --no-default-features done + + if cargo --version | grep -v "1\.41"; then + cargo build --verbose --features="zeroize" --no-default-features + fi fi # Test each feature diff --git a/src/language/mod.rs b/src/language/mod.rs index 3f454bc..6aabb33 100644 --- a/src/language/mod.rs +++ b/src/language/mod.rs @@ -337,10 +337,10 @@ mod tests { Language::Korean, ]; - for lang in languages { + for lang in languages.iter() { let mut list = lang.word_list().to_vec(); list.sort(); - assert_eq!(list, lang.word_list()); + assert_eq!(&list[..], &lang.word_list()[..]); } } diff --git a/src/lib.rs b/src/lib.rs index 7d63b62..593bf8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -899,7 +899,7 @@ mod tests { ); assert_eq!(&entropy, &mnemonic.to_entropy(), "failed vector: {}", mnemonic_str); assert_eq!( - &entropy, + &entropy[..], &mnemonic.to_entropy_array().0[0..entropy.len()], "failed vector: {}", mnemonic_str From 28991bd150be00ac471accac746d59d5c8ca99df Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Fri, 9 Feb 2024 18:32:38 +0000 Subject: [PATCH 2/2] readme: Inform user bitcoin_hashes needs to be pinned for MSRV --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2573776..aecd61f 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,10 @@ Use the `all-languages` feature to enable all languages. This crate supports Rust v1.41.1 and up and works with `no_std`. +When using older version of Rust, you might have to pin the version of the +`bitcoin_hashes` crate used as such: +``` +$ cargo update --package "bitcoin_hashes" --precise "0.12.0" +``` + If you enable the `zeroize` feature the MSRV becomes 1.51.