Skip to content

Commit 4630c45

Browse files
committed
Make dummy ChannelUpdate timestamp dynamic in tests
1 parent 8b991c3 commit 4630c45

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lightning/src/util/test_utils.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,12 +963,21 @@ fn get_dummy_channel_announcement(short_chan_id: u64) -> msgs::ChannelAnnounceme
963963
fn get_dummy_channel_update(short_chan_id: u64) -> msgs::ChannelUpdate {
964964
use bitcoin::secp256k1::ffi::Signature as FFISignature;
965965
let network = Network::Testnet;
966+
967+
#[allow(unused_mut, unused_assignments)]
968+
let mut timestamp = 0;
969+
#[cfg(feature = "std")]
970+
{
971+
use std::time::{SystemTime, UNIX_EPOCH};
972+
timestamp = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 60 * 60 * 24 * 7 * 2;
973+
}
974+
966975
msgs::ChannelUpdate {
967976
signature: Signature::from(unsafe { FFISignature::new() }),
968977
contents: msgs::UnsignedChannelUpdate {
969978
chain_hash: ChainHash::using_genesis_block(network),
970979
short_channel_id: short_chan_id,
971-
timestamp: 0,
980+
timestamp: timestamp as u32,
972981
message_flags: 1, // Only must_be_one
973982
channel_flags: 0,
974983
cltv_expiry_delta: 0,

0 commit comments

Comments
 (0)