Skip to content

Commit b6daa97

Browse files
committed
Merge rust-bitcoin/rust-miniscript#463: Fix inconsistent naming in the dummy key hash structs
af5d2d2 Fix inconsistent naming in the dummy key hash structs (Alekos Filini) 637f5ce MSRV fixes for once_cell (sanket1729) Pull request description: Also derive `Default` for `DummyHash` and all of its hash types since they are all empty structs. ACKs for top commit: apoelstra: ACK af5d2d2 Tree-SHA512: 6ecee59932573fbfd2784bfabad0efbab1f9840f16cd4ab78c11c2ddcabab08307723c54c52a4bb4d00201ab91df9480185ace9da99f241fb986fc93cf07dfdd
2 parents cddc22d + af5d2d2 commit b6daa97

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

contrib/test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ if cargo --version | grep "1\.41\.0"; then
1616
MSRV=true
1717
fi
1818

19+
if cargo --version | grep "1\.47\.0"; then
20+
cargo update -p once_cell --precise 1.13.1
21+
fi
22+
1923
# form_urlencoded 1.1.0 breaks MSRV.
2024
if [ "$MSRV" = true ]; then
2125
cargo update -p url --precise 2.2.2
2226
cargo update -p form_urlencoded --precise 1.0.1
27+
cargo update -p once_cell --precise 1.13.1
2328
fi
2429

2530
# Format if told to

src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl ToPublicKey for bitcoin::secp256k1::XOnlyPublicKey {
358358
}
359359

360360
/// Dummy key which de/serializes to the empty string; useful sometimes for testing
361-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
361+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
362362
pub struct DummyKey;
363363

364364
impl str::FromStr for DummyKey {
@@ -375,7 +375,7 @@ impl str::FromStr for DummyKey {
375375
impl MiniscriptKey for DummyKey {
376376
type RawPkHash = DummyKeyHash;
377377
type Sha256 = DummySha256Hash;
378-
type Hash256 = DummyHash256;
378+
type Hash256 = DummyHash256Hash;
379379
type Ripemd160 = DummyRipemd160Hash;
380380
type Hash160 = DummyHash160Hash;
381381

@@ -413,7 +413,7 @@ impl ToPublicKey for DummyKey {
413413
.unwrap()
414414
}
415415

416-
fn to_hash256(_hash: &DummyHash256) -> hash256::Hash {
416+
fn to_hash256(_hash: &DummyHash256Hash) -> hash256::Hash {
417417
hash256::Hash::from_str("50863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352")
418418
.unwrap()
419419
}
@@ -428,7 +428,7 @@ impl ToPublicKey for DummyKey {
428428
}
429429

430430
/// Dummy keyhash which de/serializes to the empty string; useful sometimes for testing
431-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
431+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
432432
pub struct DummyKeyHash;
433433

434434
impl str::FromStr for DummyKeyHash {
@@ -455,7 +455,7 @@ impl hash::Hash for DummyKeyHash {
455455
}
456456

457457
/// Dummy keyhash which de/serializes to the empty string; useful for testing
458-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
458+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
459459
pub struct DummySha256Hash;
460460

461461
impl str::FromStr for DummySha256Hash {
@@ -482,22 +482,22 @@ impl hash::Hash for DummySha256Hash {
482482
}
483483

484484
/// Dummy keyhash which de/serializes to the empty string; useful for testing
485-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
486-
pub struct DummyHash256;
485+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
486+
pub struct DummyHash256Hash;
487487

488-
impl str::FromStr for DummyHash256 {
488+
impl str::FromStr for DummyHash256Hash {
489489
type Err = &'static str;
490-
fn from_str(x: &str) -> Result<DummyHash256, &'static str> {
490+
fn from_str(x: &str) -> Result<DummyHash256Hash, &'static str> {
491491
if x.is_empty() {
492-
Ok(DummyHash256)
492+
Ok(DummyHash256Hash)
493493
} else {
494494
Err("non empty dummy hash")
495495
}
496496
}
497497
}
498498

499499
/// Dummy keyhash which de/serializes to the empty string; useful for testing
500-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
500+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
501501
pub struct DummyRipemd160Hash;
502502

503503
impl str::FromStr for DummyRipemd160Hash {
@@ -511,7 +511,7 @@ impl str::FromStr for DummyRipemd160Hash {
511511
}
512512
}
513513

514-
impl fmt::Display for DummyHash256 {
514+
impl fmt::Display for DummyHash256Hash {
515515
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
516516
f.write_str("")
517517
}
@@ -522,7 +522,7 @@ impl fmt::Display for DummyRipemd160Hash {
522522
}
523523
}
524524

525-
impl hash::Hash for DummyHash256 {
525+
impl hash::Hash for DummyHash256Hash {
526526
fn hash<H: hash::Hasher>(&self, state: &mut H) {
527527
"DummySha256Hash".hash(state);
528528
}
@@ -535,7 +535,7 @@ impl hash::Hash for DummyRipemd160Hash {
535535
}
536536

537537
/// Dummy keyhash which de/serializes to the empty string; useful for testing
538-
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
538+
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug, Default)]
539539
pub struct DummyHash160Hash;
540540

541541
impl str::FromStr for DummyHash160Hash {

0 commit comments

Comments
 (0)