Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
clippy nightly fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CAGS295 committed Oct 2, 2023
1 parent a50cb37 commit ef3430b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 34 deletions.
2 changes: 0 additions & 2 deletions romeo/src/stacks_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ mod tests {

let nonce_info = stacks_client.get_nonce_info().await.unwrap();
assert_eq!(nonce_info.possible_next_nonce, 122);

assert!(true);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
Expand Down
40 changes: 18 additions & 22 deletions sbtc-core/src/operations/op_return/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,32 +327,28 @@ mod tests {
let contract_name_length: u8 =
rng.gen_range(1..CONTRACT_MAX_NAME_LENGTH as u8);

let contract_name = {
let mut contract_name_char_iter =
rng.sample_iter(&Alphanumeric).map(char::from);

let first_letter = loop {
let letter = contract_name_char_iter.next().unwrap();

if letter.is_digit(10) {
continue;
} else {
break letter;
};
};

let other_letters =
contract_name_char_iter.take(contract_name_length as usize - 1);
let mut contract_name_char_iter =
rng.sample_iter(&Alphanumeric).map(char::from);

let contract_name_string = [first_letter]
.into_iter()
.chain(other_letters)
.collect::<String>();
let first_letter = loop {
let letter = contract_name_char_iter.next().unwrap();

ContractName::new(&contract_name_string).unwrap()
if letter.is_ascii_digit() {
continue;
} else {
break letter;
};
};

contract_name
let other_letters =
contract_name_char_iter.take(contract_name_length as usize - 1);

let contract_name_string = [first_letter]
.into_iter()
.chain(other_letters)
.collect::<String>();

ContractName::new(&contract_name_string).unwrap()
}

fn generate_standard_principal_data(rng: &mut impl Rng) -> PrincipalData {
Expand Down
4 changes: 2 additions & 2 deletions stacks-core/src/c32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ mod tests {
#[test]
fn test_c32_encode() {
let input = vec![1, 2, 3, 4, 6, 1, 2, 6, 2, 3, 6, 9, 4, 0, 0];
let encoded = encode(&input);
let encoded = encode(input);

assert_eq!(encoded, "41061060410C0G30R4G8000");
}
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {
let bytes = rng.gen::<[u8; 20]>();

for version in AddressVersion::iter() {
let encoded = encode_address(version, &bytes);
let encoded = encode_address(version, bytes);
let (decoded_version, decoded) =
decode_address(encoded).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions stacks-core/src/crypto/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ mod tests {

#[test]
fn should_convert_to_uint_correctly() {
let expected_num = Uint256::from(0xDEADBEEFDEADBEEF as u64) << 64
| Uint256::from(0x0102030405060708 as u64);
let expected_num = Uint256::from(0xDEADBEEFDEADBEEF_u64) << 64
| Uint256::from(0x0102030405060708_u64);
let num_bytes = hex::decode(
"0807060504030201efbeaddeefbeadde00000000000000000000000000000000",
)
Expand Down
12 changes: 6 additions & 6 deletions stacks-core/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ mod tests {

impl<const N: usize> Uint<N> {
fn bit(&self, index: usize) -> bool {
let &Uint(ref arr) = self;
let Uint(arr) = self;

arr[index / 64] & (1 << (index % 64)) != 0
}
Expand All @@ -615,7 +615,7 @@ mod tests {
}

fn mask(&self, n: usize) -> Self {
let &Uint(ref arr) = self;
let Uint(arr) = self;

let mut ret = [0; N];
for i in 0..N {
Expand Down Expand Up @@ -961,21 +961,21 @@ mod tests {
let hex_init =
"0807060504030201efbeaddeefbeadde00000000000000000000000000000000";
assert_eq!(
Uint256::from_le_bytes(&hex::decode(hex_init).unwrap()).unwrap(),
Uint256::from_le_bytes(hex::decode(hex_init).unwrap()).unwrap(),
init
);
assert_eq!(hex::encode(init.to_le_bytes()), hex_init);
assert_eq!(Uint256::from_le_bytes(&init.to_le_bytes()).unwrap(), init);
assert_eq!(Uint256::from_le_bytes(init.to_le_bytes()).unwrap(), init);

// big-endian representation
let hex_init =
"00000000000000000000000000000000deadbeefdeadbeef0102030405060708";
assert_eq!(
Uint256::from_be_bytes(&hex::decode(hex_init).unwrap()).unwrap(),
Uint256::from_be_bytes(hex::decode(hex_init).unwrap()).unwrap(),
init
);
assert_eq!(hex::encode(init.to_be_bytes()), hex_init);
assert_eq!(Uint256::from_be_bytes(&init.to_be_bytes()).unwrap(), init);
assert_eq!(Uint256::from_be_bytes(init.to_be_bytes()).unwrap(), init);
}

#[test]
Expand Down

0 comments on commit ef3430b

Please sign in to comment.