Skip to content

Commit

Permalink
Merge of #4898
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 28, 2022
2 parents 8227dab + 5b021d9 commit 2815962
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 68 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions zebra-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rand_core = "0.6.3"
ripemd = "0.1.1"
# Matches version used by hdwallet
secp256k1 = { version = "0.21.3", features = ["serde"] }
sha2 = { version = "0.9.9", features=["compress"] }
sha2 = { version = "0.9.9", features = ["compress"] }
subtle = "2.4.1"
uint = "0.9.1"
x25519-dalek = { version = "1.2.0", features = ["serde"] }
Expand All @@ -49,7 +49,7 @@ zcash_note_encryption = "0.1"
zcash_primitives = { version = "0.7.0", features = ["transparent-inputs"] }

# Time
chrono = { version = "0.4.19", features = ["serde"] }
chrono = { version = "0.4.20", default-features = false, features = ["clock", "std", "serde"] }
humantime = "2.1.0"

# Error Handling & Formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl NetworkChainTipHeightEstimator {
let target_spacing_seconds = self.current_target_spacing.num_seconds();
let time_to_activation = Duration::seconds(remaining_blocks * target_spacing_seconds);

self.current_block_time = self.current_block_time + time_to_activation;
self.current_block_time += time_to_activation;
self.current_height = max_height;
}
}
Expand Down
4 changes: 2 additions & 2 deletions zebra-chain/src/serialization/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::convert::TryInto;

use chrono::{TimeZone, Utc, MAX_DATETIME, MIN_DATETIME};
use chrono::{DateTime, TimeZone, Utc};
use proptest::{arbitrary::any, prelude::*};

use super::{
Expand Down Expand Up @@ -41,7 +41,7 @@ impl Arbitrary for DateTime32 {
pub fn datetime_full() -> impl Strategy<Value = chrono::DateTime<Utc>> {
(
// TODO: should we be subtracting 1 from the maximum timestamp?
MIN_DATETIME.timestamp()..=MAX_DATETIME.timestamp(),
DateTime::<Utc>::MIN_UTC.timestamp()..=DateTime::<Utc>::MAX_UTC.timestamp(),
0..2_000_000_000_u32,
)
.prop_map(|(secs, nsecs)| Utc.timestamp(secs, nsecs))
Expand Down
2 changes: 1 addition & 1 deletion zebra-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jubjub = "0.9.0"
rand = { version = "0.8.5", package = "rand" }
rayon = "1.5.3"

chrono = "0.4.19"
chrono = { version = "0.4.20", default-features = false, features = ["clock", "std"] }
dirs = "4.0.0"
displaydoc = "0.2.3"
lazy_static = "1.4.0"
Expand Down
77 changes: 37 additions & 40 deletions zebra-consensus/src/transaction/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! Tests for Zcash transaction consensus checks.
use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
sync::Arc,
};
use std::{collections::HashMap, sync::Arc};

use chrono::{DateTime, Utc};
use color_eyre::eyre::Report;
use halo2::pasta::{group::ff::PrimeField, pallas};
use tower::{service_fn, ServiceExt};

Expand All @@ -27,10 +25,9 @@ use zebra_chain::{
transparent::{self, CoinbaseData},
};

use super::{check, Request, Verifier};

use crate::error::TransactionError;
use color_eyre::eyre::Report;

use super::{check, Request, Verifier};

#[cfg(test)]
mod prop;
Expand Down Expand Up @@ -264,7 +261,7 @@ async fn v5_transaction_is_rejected_before_nu5_activation() {
height: canopy
.activation_height(network)
.expect("Canopy activation height is specified"),
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -327,7 +324,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network)
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height: expiry_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -377,7 +374,7 @@ async fn v4_transaction_with_transparent_transfer_is_accepted() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -416,7 +413,7 @@ async fn v4_transaction_with_last_valid_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -461,7 +458,7 @@ async fn v4_coinbase_transaction_with_low_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -503,7 +500,7 @@ async fn v4_transaction_with_too_low_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -548,7 +545,7 @@ async fn v4_transaction_with_exceeding_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -601,7 +598,7 @@ async fn v4_coinbase_transaction_with_exceeding_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -652,7 +649,7 @@ async fn v4_coinbase_transaction_is_accepted() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -702,7 +699,7 @@ async fn v4_transaction_with_transparent_transfer_is_rejected_by_the_script() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -752,7 +749,7 @@ async fn v4_transaction_with_conflicting_transparent_spend_is_rejected() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -818,7 +815,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -889,7 +886,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejecte
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -943,7 +940,7 @@ async fn v5_transaction_with_transparent_transfer_is_accepted() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -983,7 +980,7 @@ async fn v5_transaction_with_last_valid_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1026,7 +1023,7 @@ async fn v5_coinbase_transaction_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand All @@ -1047,7 +1044,7 @@ async fn v5_coinbase_transaction_expiry_height() {
transaction: Arc::new(new_transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand All @@ -1072,7 +1069,7 @@ async fn v5_coinbase_transaction_expiry_height() {
transaction: Arc::new(new_transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand All @@ -1099,7 +1096,7 @@ async fn v5_coinbase_transaction_expiry_height() {
transaction: Arc::new(new_transaction.clone()),
known_utxos: Arc::new(HashMap::new()),
height: new_expiry_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1141,7 +1138,7 @@ async fn v5_transaction_with_too_low_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1187,7 +1184,7 @@ async fn v5_transaction_with_exceeding_expiry_height() {
transaction: Arc::new(transaction.clone()),
known_utxos: Arc::new(known_utxos),
height: block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1241,7 +1238,7 @@ async fn v5_coinbase_transaction_is_accepted() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1293,7 +1290,7 @@ async fn v5_transaction_with_transparent_transfer_is_rejected_by_the_script() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1345,7 +1342,7 @@ async fn v5_transaction_with_conflicting_transparent_spend_is_rejected() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
height: transaction_block_height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1390,7 +1387,7 @@ fn v4_with_signed_sprout_transfer_is_accepted() {
transaction,
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1463,7 +1460,7 @@ async fn v4_with_joinsplit_is_rejected_for_modification(
transaction,
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1499,7 +1496,7 @@ fn v4_with_sapling_spends() {
transaction,
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1542,7 +1539,7 @@ fn v4_with_duplicate_sapling_spends() {
transaction,
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1587,7 +1584,7 @@ fn v4_with_sapling_outputs_and_no_spends() {
transaction,
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1636,7 +1633,7 @@ fn v5_with_sapling_spends() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1680,7 +1677,7 @@ fn v5_with_duplicate_sapling_spends() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down Expand Up @@ -1743,7 +1740,7 @@ fn v5_with_duplicate_orchard_action() {
transaction: Arc::new(transaction),
known_utxos: Arc::new(HashMap::new()),
height,
time: chrono::MAX_DATETIME,
time: DateTime::<Utc>::MAX_UTC,
})
.await;

Expand Down
Loading

0 comments on commit 2815962

Please sign in to comment.