Stop using the deprecated `from_timestamp_opt`
This commit is contained in:
parent
2b3eafff7c
commit
450d659930
|
@ -1,6 +1,6 @@
|
|||
//! Generate large transparent blocks and transactions for testing.
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::DateTime;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
|
@ -42,18 +42,6 @@ pub fn transaction() -> (Transaction, Vec<u8>) {
|
|||
(transaction, transaction_bytes)
|
||||
}
|
||||
|
||||
/// 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_naive_utc_and_offset(
|
||||
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();
|
||||
|
||||
(lock_time, lock_time_bytes)
|
||||
}
|
||||
|
||||
/// Returns a generated transparent input, and its canonical serialized bytes.
|
||||
pub fn input() -> (transparent::Input, Vec<u8>) {
|
||||
// Some of the test vectors are in a non-canonical format,
|
||||
|
@ -182,8 +170,8 @@ fn single_transaction_block_many_inputs(oversized: bool) -> Block {
|
|||
// A block header
|
||||
let (block_header, block_header_bytes) = block_header();
|
||||
|
||||
// A LockTime
|
||||
let (lock_time, lock_time_bytes) = lock_time();
|
||||
let lock_time = LockTime::Time(DateTime::from_timestamp(61, 0).unwrap());
|
||||
let lock_time_bytes = lock_time.zcash_serialize_to_vec().unwrap();
|
||||
|
||||
// Calculate the number of inputs we need,
|
||||
// subtracting the bytes used to serialize the expected input count,
|
||||
|
@ -256,8 +244,8 @@ fn single_transaction_block_many_outputs(oversized: bool) -> Block {
|
|||
// A block header
|
||||
let (block_header, block_header_bytes) = block_header();
|
||||
|
||||
// A LockTime
|
||||
let (lock_time, lock_time_bytes) = lock_time();
|
||||
let lock_time = LockTime::Time(DateTime::from_timestamp(61, 0).unwrap());
|
||||
let lock_time_bytes = lock_time.zcash_serialize_to_vec().unwrap();
|
||||
|
||||
// Calculate the number of outputs we need,
|
||||
// subtracting the bytes used to serialize the expected output count,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Fixed test vectors for transactions.
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::DateTime;
|
||||
use color_eyre::eyre::Result;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
|
@ -221,13 +221,6 @@ fn deserialize_large_transaction() {
|
|||
let output =
|
||||
transparent::Output::zcash_deserialize(&zebra_test::vectors::DUMMY_OUTPUT1[..]).unwrap();
|
||||
|
||||
// Create a lock time.
|
||||
let lock_time = LockTime::Time(DateTime::<Utc>::from_naive_utc_and_offset(
|
||||
NaiveDateTime::from_timestamp_opt(61, 0)
|
||||
.expect("in-range number of seconds and valid nanosecond"),
|
||||
Utc,
|
||||
));
|
||||
|
||||
// Serialize the input so that we can determine its serialized size.
|
||||
let mut input_data = Vec::new();
|
||||
input
|
||||
|
@ -242,14 +235,12 @@ fn deserialize_large_transaction() {
|
|||
.take(tx_inputs_num)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let outputs = vec![output];
|
||||
|
||||
// Create an oversized transaction. Adding the output and lock time causes
|
||||
// the transaction to overflow the threshold.
|
||||
let oversized_tx = Transaction::V1 {
|
||||
inputs,
|
||||
outputs,
|
||||
lock_time,
|
||||
outputs: vec![output],
|
||||
lock_time: LockTime::Time(DateTime::from_timestamp(61, 0).unwrap()),
|
||||
};
|
||||
|
||||
// Serialize the transaction.
|
||||
|
|
Loading…
Reference in New Issue