From: Elias Rohrer Date: Sat, 16 Dec 2023 12:55:48 +0000 (+0100) Subject: Fix unused imports in `lightning-invoice` no-std tests X-Git-Tag: v0.0.120~20^2~5 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=be574f5c273a8bf6147f2a221d58aa7085ad359f;p=rust-lightning Fix unused imports in `lightning-invoice` no-std tests --- diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 59622a84a..6f21af72d 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -2045,7 +2045,7 @@ mod test { use lightning::routing::router::RouteHintHop; use secp256k1::Secp256k1; use secp256k1::{SecretKey, PublicKey}; - use std::time::{UNIX_EPOCH, Duration}; + use std::time::Duration; let secp_ctx = Secp256k1::new(); @@ -2134,7 +2134,7 @@ mod test { assert_eq!(invoice.currency(), Currency::BitcoinTestnet); #[cfg(feature = "std")] assert_eq!( - invoice.timestamp().duration_since(UNIX_EPOCH).unwrap().as_secs(), + invoice.timestamp().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(), 1234567 ); assert_eq!(invoice.payee_pub_key(), Some(&public_key)); diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index b8f564ef5..8196fa9eb 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -85,14 +85,12 @@ mod tests { use super::*; use crate::{InvoiceBuilder, Currency}; use bitcoin::hashes::sha256::Hash as Sha256; - use lightning::events::Event; - use lightning::ln::channelmanager::{Retry, PaymentId}; - use lightning::ln::msgs::ChannelMessageHandler; use lightning::ln::PaymentSecret; - use lightning::ln::functional_test_utils::*; use lightning::routing::router::Payee; use secp256k1::{SecretKey, PublicKey, Secp256k1}; - use std::time::{SystemTime, Duration}; + use core::time::Duration; + #[cfg(feature = "std")] + use std::time::SystemTime; fn duration_since_epoch() -> Duration { #[cfg(feature = "std")] @@ -171,6 +169,10 @@ mod tests { #[test] #[cfg(feature = "std")] fn payment_metadata_end_to_end() { + use lightning::events::Event; + use lightning::ln::channelmanager::{Retry, PaymentId}; + use lightning::ln::msgs::ChannelMessageHandler; + use lightning::ln::functional_test_utils::*; // Test that a payment metadata read from an invoice passed to `pay_invoice` makes it all // the way out through the `PaymentClaimable` event. let chanmon_cfgs = create_chanmon_cfgs(2); diff --git a/lightning-invoice/src/utils.rs b/lightning-invoice/src/utils.rs index 3a337a9a4..5e8b72467 100644 --- a/lightning-invoice/src/utils.rs +++ b/lightning-invoice/src/utils.rs @@ -816,14 +816,15 @@ impl<'a, 'b, L: Deref> WithChannelDetails<'a, 'b, L> where L::Target: Logger { #[cfg(test)] mod test { - use core::cell::RefCell; use core::time::Duration; use crate::{Currency, Description, Bolt11InvoiceDescription, SignOrCreationError, CreationError}; use bitcoin::hashes::{Hash, sha256}; use bitcoin::hashes::sha256::Hash as Sha256; use lightning::sign::PhantomKeysManager; - use lightning::events::{MessageSendEvent, MessageSendEventsProvider, Event, EventsProvider}; - use lightning::ln::{PaymentPreimage, PaymentHash}; + use lightning::events::{MessageSendEvent, MessageSendEventsProvider}; + use lightning::ln::PaymentHash; + #[cfg(feature = "std")] + use lightning::ln::PaymentPreimage; use lightning::ln::channelmanager::{PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY_DELTA, PaymentId, RecipientOnionFields, Retry}; use lightning::ln::functional_test_utils::*; use lightning::ln::msgs::ChannelMessageHandler; @@ -1294,6 +1295,9 @@ mod test { #[cfg(feature = "std")] fn do_test_multi_node_receive(user_generated_pmt_hash: bool) { + use lightning::events::{Event, EventsProvider}; + use core::cell::RefCell; + let mut chanmon_cfgs = create_chanmon_cfgs(3); let seed_1 = [42u8; 32]; let seed_2 = [43u8; 32];