Skip to content

Commit 55cc2ac

Browse files
committed
fix clippy and fmt
1 parent f0efc7c commit 55cc2ac

12 files changed

+593
-631
lines changed

src/blake2b_internal.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn hash_blake2b_pair(prefix: &[u8], leaf1: &[u8], leaf2: &[u8]) -> Hash256 {
155155
mod test {
156156
use super::*;
157157

158-
cross_target_tests!{
158+
cross_target_tests! {
159159
fn test_accumulator_new() {
160160
let default_accumulator = Accumulator::default();
161161

@@ -167,51 +167,51 @@ mod test {
167167
}
168168

169169
fn test_accumulator_root_default() { assert_eq!(Accumulator::default().root(), Hash256::default()) }
170-
170+
171171
fn test_accumulator_root() {
172172
let mut accumulator = Accumulator::default();
173-
173+
174174
let timelock_leaf = timelock_leaf(0u64);
175175
accumulator.add_leaf(timelock_leaf);
176-
176+
177177
let pubkey = PublicKey::from_bytes(
178178
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
179179
)
180180
.unwrap();
181181
let pubkey_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey));
182182
accumulator.add_leaf(pubkey_leaf);
183-
183+
184184
let sigs_required_leaf = sigs_required_leaf(1u64);
185185
accumulator.add_leaf(sigs_required_leaf);
186-
186+
187187
let expected = Hash256::try_from("h:72b0762b382d4c251af5ae25b6777d908726d75962e5224f98d7f619bb39515d").unwrap();
188188
assert_eq!(accumulator.root(), expected);
189189
}
190-
190+
191191
fn test_accumulator_add_leaf_standard_unlock_hash() {
192192
let mut accumulator = Accumulator::default();
193-
193+
194194
let pubkey = PublicKey::from_bytes(
195195
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
196196
)
197197
.unwrap();
198-
198+
199199
let pubkey_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey));
200200
let timelock_leaf = timelock_leaf(0u64);
201201
let sigs_required_leaf = sigs_required_leaf(1u64);
202-
202+
203203
accumulator.add_leaf(timelock_leaf);
204204
accumulator.add_leaf(pubkey_leaf);
205205
accumulator.add_leaf(sigs_required_leaf);
206-
206+
207207
let root = accumulator.root();
208208
let expected = Hash256::try_from("h:72b0762b382d4c251af5ae25b6777d908726d75962e5224f98d7f619bb39515d").unwrap();
209209
assert_eq!(root, expected)
210210
}
211-
211+
212212
fn test_accumulator_add_leaf_2of2_multisig_unlock_hash() {
213213
let mut accumulator = Accumulator::default();
214-
214+
215215
let pubkey1 = PublicKey::from_bytes(
216216
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
217217
)
@@ -220,26 +220,26 @@ mod test {
220220
&hex::decode("0101010000000000000000000000000000000000000000000000000000000000").unwrap(),
221221
)
222222
.unwrap();
223-
223+
224224
let pubkey1_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey1));
225225
let pubkey2_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey2));
226-
226+
227227
let timelock_leaf = timelock_leaf(0u64);
228228
let sigs_required_leaf = sigs_required_leaf(2u64);
229-
229+
230230
accumulator.add_leaf(timelock_leaf);
231231
accumulator.add_leaf(pubkey1_leaf);
232232
accumulator.add_leaf(pubkey2_leaf);
233233
accumulator.add_leaf(sigs_required_leaf);
234-
234+
235235
let root = accumulator.root();
236236
let expected = Hash256::try_from("h:1e94357817d236167e54970a8c08bbd41b37bfceeeb52f6c1ce6dd01d50ea1e7").unwrap();
237237
assert_eq!(root, expected)
238238
}
239-
239+
240240
fn test_accumulator_add_leaf_1of2_multisig_unlock_hash() {
241241
let mut accumulator = Accumulator::default();
242-
242+
243243
let pubkey1 = PublicKey::from_bytes(
244244
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
245245
)
@@ -248,34 +248,34 @@ mod test {
248248
&hex::decode("0101010000000000000000000000000000000000000000000000000000000000").unwrap(),
249249
)
250250
.unwrap();
251-
251+
252252
let pubkey1_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey1));
253253
let pubkey2_leaf = public_key_leaf(&UnlockKey::Ed25519(pubkey2));
254-
254+
255255
let timelock_leaf = timelock_leaf(0u64);
256256
let sigs_required_leaf = sigs_required_leaf(1u64);
257-
257+
258258
accumulator.add_leaf(timelock_leaf);
259259
accumulator.add_leaf(pubkey1_leaf);
260260
accumulator.add_leaf(pubkey2_leaf);
261261
accumulator.add_leaf(sigs_required_leaf);
262-
262+
263263
let root = accumulator.root();
264264
let expected = Hash256::try_from("h:d7f84e3423da09d111a17f64290c8d05e1cbe4cab2b6bed49e3a4d2f659f0585").unwrap();
265265
assert_eq!(root, expected)
266266
}
267-
267+
268268
fn test_standard_unlock_hash() {
269269
let pubkey = PublicKey::from_bytes(
270270
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
271271
)
272272
.unwrap();
273-
273+
274274
let hash = standard_unlock_hash(&pubkey);
275275
let expected = Hash256::try_from("h:72b0762b382d4c251af5ae25b6777d908726d75962e5224f98d7f619bb39515d").unwrap();
276276
assert_eq!(hash, expected)
277277
}
278-
278+
279279
fn test_hash_blake2b_pair() {
280280
let left: [u8; 32] = hex::decode("cdcce3978a58ceb6c8480d218646db4eae85eb9ea9c2f5138fbacb4ce2c701e3")
281281
.unwrap()
@@ -285,36 +285,36 @@ mod test {
285285
.unwrap()
286286
.try_into()
287287
.unwrap();
288-
288+
289289
let hash = hash_blake2b_pair(&NODE_HASH_PREFIX, &left, &right);
290290
let expected = Hash256::try_from("h:72b0762b382d4c251af5ae25b6777d908726d75962e5224f98d7f619bb39515d").unwrap();
291291
assert_eq!(hash, expected)
292292
}
293-
293+
294294
fn test_timelock_leaf() {
295295
let hash = timelock_leaf(0);
296296
let expected = Hash256(STANDARD_TIMELOCK_BLAKE2B_HASH);
297297
assert_eq!(hash, expected)
298298
}
299-
299+
300300
fn test_sigs_required_leaf() {
301301
let hash = sigs_required_leaf(1u64);
302302
let expected = Hash256(STANDARD_SIGS_REQUIRED_BLAKE2B_HASH);
303303
assert_eq!(hash, expected)
304304
}
305-
305+
306306
fn test_hash_blake2b_single() {
307307
let hash = hash_blake2b_single(&hex::decode("006564323535313900000000000000000020000000000000000102030000000000000000000000000000000000000000000000000000000000").unwrap());
308308
let expected = Hash256::try_from("h:21ce940603a2ee3a283685f6bfb4b122254894fd1ed3eb59434aadbf00c75d5b").unwrap();
309309
assert_eq!(hash, expected)
310310
}
311-
311+
312312
fn test_public_key_leaf() {
313313
let pubkey = PublicKey::from_bytes(
314314
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
315315
)
316316
.unwrap();
317-
317+
318318
let hash = public_key_leaf(&UnlockKey::Ed25519(pubkey));
319319
let expected = Hash256::try_from("h:21ce940603a2ee3a283685f6bfb4b122254894fd1ed3eb59434aadbf00c75d5b").unwrap();
320320
assert_eq!(hash, expected)

src/encoding.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mod test {
6262
use super::*;
6363
use std::convert::TryFrom;
6464

65-
cross_target_tests!{
65+
cross_target_tests! {
6666
fn test_encoder_default_hash() {
6767
assert_eq!(
6868
Encoder::default().hash(),
@@ -143,4 +143,4 @@ mod test {
143143
);
144144
}
145145
}
146-
}
146+
}

src/tests/encoding.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
#[cfg(test)]
32
mod test {
43
use crate::blake2b_internal::standard_unlock_hash;
54
use crate::encoding::Encoder;
65
use crate::types::{Address, Hash256, PublicKey, SpendPolicy, UnlockCondition};
76
use std::convert::TryFrom;
87
use std::str::FromStr;
9-
10-
cross_target_tests!{
8+
9+
cross_target_tests! {
1110
fn test_unlock_condition_unlock_hash_2of2_multisig() {
1211
let pubkey = PublicKey::from_bytes(
1312
&hex::decode("0102030000000000000000000000000000000000000000000000000000000000").unwrap(),
@@ -172,4 +171,4 @@ mod test {
172171
assert_eq!(hash, expected);
173172
}
174173
}
175-
}
174+
}

0 commit comments

Comments
 (0)