Skip to content

Commit

Permalink
use Hash256::default()
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed May 9, 2024
1 parent 41f3364 commit d49ab80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 46 deletions.
66 changes: 21 additions & 45 deletions src/spendpolicy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(99),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Err(ValidationError::InvalidHeight),
Expand All @@ -445,7 +445,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(99),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Ok(()),
Expand All @@ -460,7 +460,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(99),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Err(ValidationError::InvalidTimestamp),
Expand All @@ -475,7 +475,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Ok(()),
Expand All @@ -490,7 +490,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Err(ValidationError::MissingSignature),
Expand All @@ -505,18 +505,14 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![Signature::new([0; 64])],
preimages: vec![],
result: Err(ValidationError::InvalidSignature),
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::PublicKey(pk.public_key()),
Expand All @@ -535,12 +531,8 @@ mod tests {
}
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::Threshold(
Expand All @@ -565,12 +557,8 @@ mod tests {
}
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::Threshold(
Expand All @@ -595,12 +583,8 @@ mod tests {
}
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::Threshold(
Expand All @@ -625,12 +609,8 @@ mod tests {
}
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::Threshold(
Expand All @@ -655,12 +635,8 @@ mod tests {
}
},
{
let mut seed = [0; 32];
thread_rng().fill(&mut seed);
let pk = PrivateKey::from_seed(&seed);
let mut hash_bytes = [0; 32];
thread_rng().fill(&mut hash_bytes);
let sig_hash = Hash256::new(hash_bytes);
let pk = PrivateKey::from_seed(&random());
let sig_hash = Hash256::new(random());

PolicyTest {
policy: SpendPolicy::Threshold(
Expand Down Expand Up @@ -702,7 +678,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![],
result: Err(ValidationError::MissingPreimage),
Expand All @@ -726,7 +702,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![[0; 64].to_vec()],
result: Err(ValidationError::InvalidPreimage),
Expand All @@ -750,7 +726,7 @@ mod tests {
median_timestamp: time::UNIX_EPOCH + Duration::from_secs(100),
hardforks: NetworkHardforks::default(),
},
hash: Hash256::new([0; 32]),
hash: Hash256::default(),
signatures: vec![],
preimages: vec![preimage.to_vec()],
result: Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ mod tests {
#[test]
fn test_json_serialize_transaction_signature() {
let txn_sig = TransactionSignature {
parent_id: Hash256::new([0u8; 32]),
parent_id: Hash256::default(),
public_key_index: 1,
timelock: 2,
covered_fields: CoveredFields::default(),
Expand Down

0 comments on commit d49ab80

Please sign in to comment.