Stop using Hash::from_slice

This function is deprecated, stop using it in favour of
`Hash::from_byte_array`.

Patch only touches test code, I'm guessing that is why lint warnings
were no showing up.
This commit is contained in:
Tobin C. Harding 2025-02-17 12:37:13 +11:00
parent 4712e81b70
commit 50c0af7138
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
5 changed files with 5 additions and 5 deletions

View File

@ -373,7 +373,7 @@ mod test {
// The genesis block hash is a double-sha256 and it is displayed backwards.
let genesis_hash = genesis_block(network).block_hash();
// We abuse the sha256 hash here so we get a LowerHex impl that does not print the hex backwards.
let hash = sha256::Hash::from_slice(genesis_hash.as_byte_array()).unwrap();
let hash = sha256::Hash::from_byte_array(genesis_hash.to_byte_array());
let want = format!("{:02x}", hash);
let chain_hash = ChainHash::using_genesis_block_const(network);

View File

@ -716,7 +716,7 @@ mod test {
use crate::script::ScriptBuf;
use crate::transaction::Transaction;
fn hash(slice: [u8; 32]) -> sha256d::Hash { sha256d::Hash::from_slice(&slice).unwrap() }
fn hash(array: [u8; 32]) -> sha256d::Hash { sha256d::Hash::from_byte_array(array) }
#[test]
fn full_round_ser_der_raw_network_message() {

View File

@ -118,7 +118,7 @@ mod tests {
0xf1, 0x4a, 0xca, 0xd7,
];
let hash = hash160::Hash::from_slice(&HASH_BYTES).expect("right number of bytes");
let hash = hash160::Hash::from_byte_array(HASH_BYTES);
assert_tokens(&hash.compact(), &[Token::BorrowedBytes(&HASH_BYTES[..])]);
assert_tokens(&hash.readable(), &[Token::Str("132072df690933835eb8b6ad0b77e7b6f14acad7")]);
}

View File

@ -122,7 +122,7 @@ mod tests {
0xb7, 0x65, 0x44, 0x8c, 0x86, 0x35, 0xfb, 0x6c,
];
let hash = sha256d::Hash::from_slice(&HASH_BYTES).expect("right number of bytes");
let hash = sha256d::Hash::from_byte_array(HASH_BYTES);
assert_tokens(&hash.compact(), &[Token::BorrowedBytes(&HASH_BYTES[..])]);
assert_tokens(
&hash.readable(),

View File

@ -321,7 +321,7 @@ mod tests {
for i in 0..64 {
vin[i] = i as u8;
let vec = Hash::from_slice(&vecs[i]).unwrap();
let vec = Hash::from_byte_array(vecs[i]);
let out = Hash::hash_with_keys(k0, k1, &vin[0..i]);
assert_eq!(vec, out, "vec #{}", i);