build(deps): bump chrono from 0.4.22 to 0.4.23 (#5629)

* build(deps): bump chrono from 0.4.22 to 0.4.23

Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.22 to 0.4.23.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.22...v0.4.23)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* uses Utx::timestamp_opt instead of timestamp

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: arya2 <aryasolhi@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2022-11-16 16:47:45 +00:00 committed by GitHub
parent 844ebf0dbd
commit 2680e3c6b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 56 additions and 20 deletions

4
Cargo.lock generated
View File

@ -608,9 +608,9 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.22"
version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
dependencies = [
"iana-time-zone",
"js-sys",

View File

@ -64,7 +64,7 @@ zcash_note_encryption = "0.2.0"
zcash_primitives = { version = "0.8.1", features = ["transparent-inputs"] }
# Time
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std", "serde"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std", "serde"] }
humantime = "2.1.0"
# Error Handling & Formatting

View File

@ -87,7 +87,12 @@ impl ZcashDeserialize for Header {
merkle_root: merkle::Root(reader.read_32_bytes()?),
commitment_bytes: reader.read_32_bytes()?,
// This can't panic, because all u32 values are valid `Utc.timestamp`s
time: Utc.timestamp(reader.read_u32::<LittleEndian>()?.into(), 0),
time: Utc
.timestamp_opt(reader.read_u32::<LittleEndian>()?.into(), 0)
.single()
.ok_or(SerializationError::Parse(
"out-of-range number of seconds and/or invalid nanosecond",
))?,
difficulty_threshold: CompactDifficulty(reader.read_u32::<LittleEndian>()?),
nonce: reader.read_32_bytes()?,
solution: equihash::Solution::zcash_deserialize(reader)?,

View File

@ -45,7 +45,8 @@ pub fn transaction() -> (Transaction, Vec<u8>) {
/// Returns a generated transparent lock time, and its canonical serialized bytes.
pub fn lock_time() -> (LockTime, Vec<u8>) {
let lock_time = LockTime::Time(DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(61, 0),
NaiveDateTime::from_timestamp_opt(61, 0)
.expect("in-range number of seconds and valid nanosecond"),
Utc,
));
let lock_time_bytes = lock_time.zcash_serialize_to_vec().unwrap();

View File

@ -44,7 +44,11 @@ pub fn datetime_full() -> impl Strategy<Value = chrono::DateTime<Utc>> {
DateTime::<Utc>::MIN_UTC.timestamp()..=DateTime::<Utc>::MAX_UTC.timestamp(),
0..2_000_000_000_u32,
)
.prop_map(|(secs, nsecs)| Utc.timestamp(secs, nsecs))
.prop_map(|(secs, nsecs)| {
Utc.timestamp_opt(secs, nsecs)
.single()
.expect("in-range number of seconds and valid nanosecond")
})
}
/// Returns a strategy that produces an arbitrary time from a [`u32`] number

View File

@ -228,7 +228,9 @@ impl From<&u32> for DateTime32 {
impl From<DateTime32> for chrono::DateTime<Utc> {
fn from(value: DateTime32) -> Self {
// chrono::DateTime is guaranteed to hold 32-bit values
Utc.timestamp(value.timestamp.into(), 0)
Utc.timestamp_opt(value.timestamp.into(), 0)
.single()
.expect("in-range number of seconds and valid nanosecond")
}
}

View File

@ -534,8 +534,13 @@ impl Arbitrary for LockTime {
prop_oneof![
(block::Height::MIN.0..=LockTime::MAX_HEIGHT.0)
.prop_map(|n| LockTime::Height(block::Height(n))),
(LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP)
.prop_map(|n| { LockTime::Time(Utc.timestamp(n, 0)) })
(LockTime::MIN_TIMESTAMP..=LockTime::MAX_TIMESTAMP).prop_map(|n| {
LockTime::Time(
Utc.timestamp_opt(n, 0)
.single()
.expect("in-range number of seconds and valid nanosecond"),
)
})
]
.boxed()
}

View File

@ -71,7 +71,11 @@ impl LockTime {
//
// TODO: replace Utc.timestamp with DateTime32 (#2211)
pub fn min_lock_time_timestamp() -> LockTime {
LockTime::Time(Utc.timestamp(Self::MIN_TIMESTAMP, 0))
LockTime::Time(
Utc.timestamp_opt(Self::MIN_TIMESTAMP, 0)
.single()
.expect("in-range number of seconds and valid nanosecond"),
)
}
/// Returns the maximum [`LockTime::Time`], as a [`LockTime`].
@ -81,7 +85,11 @@ impl LockTime {
//
// TODO: replace Utc.timestamp with DateTime32 (#2211)
pub fn max_lock_time_timestamp() -> LockTime {
LockTime::Time(Utc.timestamp(Self::MAX_TIMESTAMP, 0))
LockTime::Time(
Utc.timestamp_opt(Self::MAX_TIMESTAMP, 0)
.single()
.expect("in-range number of seconds and valid nanosecond"),
)
}
}
@ -108,7 +116,11 @@ impl ZcashDeserialize for LockTime {
Ok(LockTime::Height(block::Height(n)))
} else {
// This can't panic, because all u32 values are valid `Utc.timestamp`s.
Ok(LockTime::Time(Utc.timestamp(n.into(), 0)))
Ok(LockTime::Time(
Utc.timestamp_opt(n.into(), 0)
.single()
.expect("in-range number of seconds and valid nanosecond"),
))
}
}
}

View File

@ -223,7 +223,8 @@ fn deserialize_large_transaction() {
// Create a lock time.
let lock_time = LockTime::Time(DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp(61, 0),
NaiveDateTime::from_timestamp_opt(61, 0)
.expect("in-range number of seconds and valid nanosecond"),
Utc,
));

View File

@ -19,7 +19,7 @@ jubjub = "0.9.0"
rand = { version = "0.8.5", package = "rand" }
rayon = "1.5.3"
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
dirs = "4.0.0"
displaydoc = "0.2.3"
lazy_static = "1.4.0"

View File

@ -17,7 +17,7 @@ proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl"]
bitflags = "1.3.2"
byteorder = "1.4.3"
bytes = "1.2.1"
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
hex = "0.4.3"
humantime-serde = "1.1.1"
indexmap = { version = "1.9.1", features = ["serde"] }

View File

@ -608,7 +608,10 @@ where
// To try to stay within the range where zcashd will ignore our clock skew,
// truncate the timestamp to the nearest 5 minutes.
let now = Utc::now().timestamp();
let timestamp = Utc.timestamp(now - now.rem_euclid(5 * 60), 0);
let timestamp = Utc
.timestamp_opt(now - now.rem_euclid(5 * 60), 0)
.single()
.expect("in-range number of seconds and valid nanosecond");
let (their_addr, our_services, our_listen_addr) = match connected_addr {
// Version messages require an address, so we use

View File

@ -738,7 +738,10 @@ mod tests {
lazy_static! {
static ref VERSION_TEST_VECTOR: Message = {
let services = PeerServices::NODE_NETWORK;
let timestamp = Utc.timestamp(1_568_000_000, 0);
let timestamp = Utc
.timestamp_opt(1_568_000_000, 0)
.single()
.expect("in-range number of seconds and valid nanosecond");
VersionMessage {
version: crate::constants::CURRENT_NETWORK_PROTOCOL_VERSION,

View File

@ -30,7 +30,7 @@ proptest-impl = [
]
[dependencies]
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
futures = "0.3.25"
# lightwalletd sends JSON-RPC requests over HTTP 1.1

View File

@ -24,7 +24,7 @@ proptest-impl = [
[dependencies]
bincode = "1.3.3"
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
dirs = "4.0.0"
displaydoc = "0.2.3"
futures = "0.3.25"

View File

@ -93,7 +93,7 @@ zebra-state = { path = "../zebra-state" }
abscissa_core = "0.5"
gumdrop = { version = "0.7", features = ["default_expr"]}
chrono = { version = "0.4.22", default-features = false, features = ["clock", "std"] }
chrono = { version = "0.4.23", default-features = false, features = ["clock", "std"] }
humantime = "2.1.0"
humantime-serde = "1.1.1"
indexmap = "1.9.1"