Merge pull request #2954 from TheBlueMatt/2024-03-test-ci-beta-fail
authorElias Rohrer <dev@tnull.de>
Fri, 5 Apr 2024 10:53:40 +0000 (12:53 +0200)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2024 10:53:40 +0000 (12:53 +0200)
Fix new warnings causing CI build failures on rustc beta

68 files changed:
lightning-block-sync/src/init.rs
lightning-invoice/src/de.rs
lightning-invoice/src/utils.rs
lightning-invoice/tests/ser_de.rs
lightning-net-tokio/src/lib.rs
lightning-persister/src/fs_store.rs
lightning-rapid-gossip-sync/src/processing.rs
lightning/src/blinded_path/message.rs
lightning/src/blinded_path/payment.rs
lightning/src/blinded_path/utils.rs
lightning/src/chain/chaininterface.rs
lightning/src/chain/channelmonitor.rs
lightning/src/chain/mod.rs
lightning/src/chain/package.rs
lightning/src/crypto/chacha20.rs
lightning/src/crypto/poly1305.rs
lightning/src/events/mod.rs
lightning/src/lib.rs
lightning/src/ln/chan_utils.rs
lightning/src/ln/channel.rs
lightning/src/ln/features.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/inbound_payment.rs
lightning/src/ln/mod.rs
lightning/src/ln/msgs.rs
lightning/src/ln/onion_payment.rs
lightning/src/ln/onion_route_tests.rs
lightning/src/ln/onion_utils.rs
lightning/src/ln/peer_handler.rs
lightning/src/ln/priv_short_conf_tests.rs
lightning/src/ln/reload_tests.rs
lightning/src/ln/script.rs
lightning/src/ln/shutdown_tests.rs
lightning/src/ln/wire.rs
lightning/src/offers/invoice.rs
lightning/src/offers/invoice_error.rs
lightning/src/offers/invoice_request.rs
lightning/src/offers/merkle.rs
lightning/src/offers/offer.rs
lightning/src/offers/parse.rs
lightning/src/offers/payer.rs
lightning/src/offers/refund.rs
lightning/src/offers/signer.rs
lightning/src/offers/test_utils.rs
lightning/src/onion_message/offers.rs
lightning/src/routing/gossip.rs
lightning/src/routing/router.rs
lightning/src/routing/scoring.rs
lightning/src/routing/test_utils.rs
lightning/src/routing/utxo.rs
lightning/src/sign/ecdsa.rs
lightning/src/sign/mod.rs
lightning/src/sync/debug_sync.rs
lightning/src/util/base32.rs
lightning/src/util/errors.rs
lightning/src/util/indexed_map.rs
lightning/src/util/invoice.rs
lightning/src/util/message_signing.rs
lightning/src/util/persist.rs
lightning/src/util/scid_utils.rs
lightning/src/util/ser.rs
lightning/src/util/ser_macros.rs
lightning/src/util/string.rs
lightning/src/util/test_channel_signer.rs
lightning/src/util/test_utils.rs
lightning/src/util/time.rs
lightning/src/util/transaction_utils.rs
lightning/src/util/wakers.rs

index 8cb0ff70a2e67ee1dee3330ffa77532b8bd68b83..ba93d12f5bcd7ff49d703e530c448b27707bd1a5 100644 (file)
@@ -252,8 +252,6 @@ mod tests {
        use crate::test_utils::{Blockchain, MockChainListener};
        use super::*;
 
-       use bitcoin::network::constants::Network;
-
        #[tokio::test]
        async fn sync_from_same_chain() {
                let chain = Blockchain::default().with_height(4);
index 9284999b1884474a51a82a7637ce237fbf7fae65..56e5c53ba1f281e01fb274914b108b0f026ff660 100644 (file)
@@ -1,5 +1,6 @@
 #[cfg(feature = "std")]
 use std::error;
+#[cfg(not(feature = "std"))]
 use core::convert::TryFrom;
 use core::fmt;
 use core::fmt::{Display, Formatter};
index d45a4e8e6462b4256333ea9f6973367b1d586c10..1d6b9210afd967f58c79e7453f53a3eda856a9ee 100644 (file)
@@ -19,6 +19,7 @@ use secp256k1::PublicKey;
 use alloc::collections::{btree_map, BTreeMap};
 use core::ops::Deref;
 use core::time::Duration;
+#[cfg(not(feature = "std"))]
 use core::iter::Iterator;
 
 /// Utility to create an invoice that can be paid to one of multiple nodes, or a "phantom invoice."
index 92bc87bef63e86e98c7678b88dc2ce251352c874..e5e311fe669277b955ccf23e372478fd8386560b 100644 (file)
@@ -8,9 +8,6 @@ use bitcoin::address::WitnessVersion;
 use bitcoin::{PubkeyHash, ScriptHash};
 use bitcoin::hashes::hex::FromHex;
 use bitcoin::hashes::{sha256, Hash};
-use lightning::ln::PaymentSecret;
-use lightning::routing::gossip::RoutingFees;
-use lightning::routing::router::{RouteHint, RouteHintHop};
 use lightning_invoice::*;
 use secp256k1::PublicKey;
 use secp256k1::ecdsa::{RecoverableSignature, RecoveryId};
index be41a2401244f0bff743e44b9e7ec26482d95227..71d63ecadcfa96e3b7fbd4a2c7c1076af2470e25 100644 (file)
@@ -208,7 +208,12 @@ impl Connection {
                                                break Disconnect::CloseConnection;
                                        }
                                },
-                               SelectorOutput::B(_) => {},
+                               SelectorOutput::B(some) => {
+                                       // The mpsc Receiver should only return `None` if the write side has been
+                                       // dropped, but that shouldn't be possible since its referenced by the Self in
+                                       // `us`.
+                                       debug_assert!(some.is_some());
+                               },
                                SelectorOutput::C(res) => {
                                        if res.is_err() { break Disconnect::PeerDisconnected; }
                                        match reader.try_read(&mut buf) {
@@ -556,7 +561,6 @@ mod tests {
        use lightning::ln::features::*;
        use lightning::ln::msgs::*;
        use lightning::ln::peer_handler::{MessageHandler, PeerManager};
-       use lightning::ln::features::NodeFeatures;
        use lightning::routing::gossip::NodeId;
        use lightning::events::*;
        use lightning::util::test_utils::TestNodeSigner;
index 350b1cdd195636f937cd32a700da9464508fee8e..364a3ee706f5288fd61dc52df53d6c135799f1cd 100644 (file)
@@ -379,7 +379,6 @@ mod tests {
        use lightning::ln::functional_test_utils::*;
        use lightning::util::test_utils;
        use lightning::util::persist::read_channel_monitors;
-       use std::fs;
        use std::str::FromStr;
 
        impl Drop for FilesystemStore {
index 9023b9ba38ca52c16d003bebaa21e1511c946d2e..b3fae0ffd8bea8e19822c5a2cf9bc19d3fe33939 100644 (file)
@@ -19,7 +19,7 @@ use crate::{GraphSyncError, RapidGossipSync};
 #[cfg(all(feature = "std", not(test)))]
 use std::time::{SystemTime, UNIX_EPOCH};
 
-#[cfg(not(feature = "std"))]
+#[cfg(all(not(feature = "std"), not(test)))]
 use alloc::{vec::Vec, borrow::ToOwned};
 
 /// The purpose of this prefix is to identify the serialization format, should other rapid gossip
index 3a5541fa1468272f3859972bca2cdfb4f8053ee8..bdcbd7726f71189175407bc3dd125aad2c1db199 100644 (file)
@@ -1,12 +1,14 @@
 use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 use crate::blinded_path::{BlindedHop, BlindedPath};
 use crate::blinded_path::utils;
 use crate::io;
 use crate::io::Cursor;
 use crate::ln::onion_utils;
 use crate::onion_message::packet::ControlTlvs;
-use crate::prelude::*;
 use crate::sign::{NodeSigner, Recipient};
 use crate::crypto::streams::ChaChaPolyReadAdapter;
 use crate::util::ser::{FixedLengthReader, LengthReadableArgs, Writeable, Writer};
index 6467af568886bd1891a7e8c52ae6b5956736f6bd..3d56020a626d68cd1e233f53a905cfdfa8acf21c 100644 (file)
@@ -12,10 +12,10 @@ use crate::ln::channelmanager::CounterpartyForwardingInfo;
 use crate::ln::features::BlindedHopFeatures;
 use crate::ln::msgs::DecodeError;
 use crate::offers::invoice::BlindedPayInfo;
-use crate::prelude::*;
 use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, Writeable, Writer};
 
-use core::convert::TryFrom;
+#[allow(unused_imports)]
+use crate::prelude::*;
 
 /// An intermediate node, its outbound channel, and relay parameters.
 #[derive(Clone, Debug)]
index d4894a86aa1a9069abdc9b2e073cd0a31c789048..7e43f31453637a6fdea2309d4713f2b34567693f 100644 (file)
@@ -23,6 +23,8 @@ use crate::crypto::streams::ChaChaPolyWriteAdapter;
 use crate::util::ser::{Readable, Writeable};
 
 use crate::io;
+
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 // TODO: DRY with onion_utils::construct_onion_keys_callback
index 1f42dc2fe4251a26be3c7b659bae89505893b6e3..2bf6d6130e1123eef41a77fd3e5ffd1e5e3b72be 100644 (file)
@@ -14,7 +14,8 @@
 //! disconnections, transaction broadcasting, and feerate information requests.
 
 use core::{cmp, ops::Deref};
-use core::convert::TryInto;
+
+use crate::prelude::*;
 
 use bitcoin::blockdata::transaction::Transaction;
 
index 4352076e94d009928689dfd524c6214e5c3d06de..c2d3a43b1f4bd40d65ea041478313a878d49d7ca 100644 (file)
@@ -53,10 +53,11 @@ use crate::util::byte_utils;
 use crate::events::{ClosureReason, Event, EventHandler};
 use crate::events::bump_transaction::{AnchorDescriptor, BumpTransactionEvent};
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use core::{cmp, mem};
 use crate::io::{self, Error};
-use core::convert::TryInto;
 use core::ops::Deref;
 use crate::sync::{Mutex, LockTestExt};
 
@@ -4765,6 +4766,8 @@ mod tests {
        use crate::sync::{Arc, Mutex};
        use crate::io;
        use crate::ln::features::ChannelTypeFeatures;
+
+       #[allow(unused_imports)]
        use crate::prelude::*;
 
        use std::str::FromStr;
index 356520b5cba86e647acdec77fd0cb86b683e7d58..e22ccca986aacf622778c7c4c3c5320b3815e341 100644 (file)
@@ -21,6 +21,7 @@ use crate::ln::ChannelId;
 use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
 use crate::chain::transaction::{OutPoint, TransactionData};
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 pub mod chaininterface;
index e304b16ef3e4fb1d42630cf9b568cc2014034200..3023be604d3f9d0f47fd3538ea5bcb8aaf3c640c 100644 (file)
@@ -35,12 +35,13 @@ use crate::util::logger::Logger;
 use crate::util::ser::{Readable, Writer, Writeable, RequiredWrapper};
 
 use crate::io;
-use crate::prelude::*;
 use core::cmp;
-use core::convert::TryInto;
 use core::mem;
 use core::ops::Deref;
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 use super::chaininterface::LowerBoundedFeeEstimator;
 
 const MAX_ALLOC_SIZE: usize = 64*1024;
index d6fd3a7dee0013c1bbbfb466737e3fae16a415da..0c51d4562febf12168f9971f4f43d7a94cd875c2 100644 (file)
@@ -12,7 +12,6 @@
 #[cfg(not(fuzzing))]
 mod real_chacha {
        use core::cmp;
-       use core::convert::TryInto;
 
        #[derive(Clone, Copy, PartialEq, Eq)]
        #[allow(non_camel_case_types)]
@@ -335,11 +334,10 @@ pub use self::fuzzy_chacha::ChaCha20;
 
 #[cfg(test)]
 mod test {
-       use alloc::vec;
-       use alloc::vec::{Vec};
-       use core::convert::TryInto;
        use core::iter::repeat;
 
+       use crate::prelude::*;
+
        use super::ChaCha20;
 
        #[test]
index a1b9fbac5160c5ddd8d090e63844f92e6da744ae..593200210055e32605c9ab4822a9f32fd54a9e44 100644 (file)
@@ -8,7 +8,8 @@
 // https://github.com/floodyberry/poly1305-donna
 
 use core::cmp::min;
-use core::convert::TryInto;
+
+use crate::prelude::*;
 
 #[derive(Clone, Copy)]
 pub struct Poly1305 {
@@ -206,7 +207,6 @@ impl Poly1305 {
 #[cfg(test)]
 mod test {
        use core::iter::repeat;
-       use alloc::vec::Vec;
 
        use super::Poly1305;
 
index b43f2f9370d4370a70510af93c4828e2d3b93b92..f6e7f7164874f0de97fb56a8dc3c4294d2206c94 100644 (file)
@@ -38,11 +38,13 @@ use bitcoin::hashes::Hash;
 use bitcoin::hashes::sha256::Hash as Sha256;
 use bitcoin::secp256k1::PublicKey;
 use crate::io;
-use crate::prelude::*;
 use core::time::Duration;
 use core::ops::Deref;
 use crate::sync::Arc;
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 /// Some information provided on receipt of payment depends on whether the payment received is a
 /// spontaneous payment or a "conventional" lightning payment that's paying an invoice.
 #[derive(Clone, Debug, PartialEq, Eq)]
index 1adf3786b76d48a571665e73e2e8a551276a73f8..3b5a4ebfbf18171c9fc95b5d201693a171858b68 100644 (file)
@@ -165,11 +165,17 @@ mod io_extras {
 }
 
 mod prelude {
+       #![allow(unused_imports)]
+
        pub use alloc::{vec, vec::Vec, string::String, collections::VecDeque, boxed::Box};
 
        pub use alloc::borrow::ToOwned;
        pub use alloc::string::ToString;
 
+       pub use core::convert::{AsMut, AsRef, TryFrom, TryInto};
+       pub use core::default::Default;
+       pub use core::marker::Sized;
+
        pub(crate) use crate::util::hash_tables::*;
 }
 
index 18c4d83406c1bdbcdb673b0461062de62f400b0a..c002dfaea25f62297518d9f8b94dcc898004c7da 100644 (file)
@@ -37,7 +37,6 @@ use bitcoin::{secp256k1, Sequence, Witness};
 use bitcoin::PublicKey as BitcoinPublicKey;
 
 use crate::io;
-use crate::prelude::*;
 use core::cmp;
 use crate::ln::chan_utils;
 use crate::util::transaction_utils::sort_outputs;
@@ -48,6 +47,9 @@ use crate::ln::features::ChannelTypeFeatures;
 use crate::crypto::utils::{sign, sign_with_aux_rand};
 use super::channel_keys::{DelayedPaymentBasepoint, DelayedPaymentKey, HtlcKey, HtlcBasepoint, RevocationKey, RevocationBasepoint};
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 /// Maximum number of one-way in-flight HTLC (protocol-level value).
 pub const MAX_HTLCS: u16 = 483;
 /// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor variant.
@@ -1812,7 +1814,6 @@ pub fn get_commitment_transaction_number_obscure_factor(
 mod tests {
        use super::{CounterpartyCommitmentSecrets, ChannelPublicKeys};
        use crate::chain;
-       use crate::prelude::*;
        use crate::ln::chan_utils::{get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment};
        use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1};
        use crate::util::test_utils;
@@ -1825,6 +1826,9 @@ mod tests {
        use bitcoin::PublicKey as BitcoinPublicKey;
        use crate::ln::features::ChannelTypeFeatures;
 
+       #[allow(unused_imports)]
+       use crate::prelude::*;
+
        struct TestCommitmentTxBuilder {
                commitment_number: u64,
                holder_funding_pubkey: PublicKey,
index ed8c861d7bbc8f045c1cf225bf0e8560b7ffb52a..2698abee2d7db271c0e8a0a2c11d7e77ca976930 100644 (file)
@@ -50,7 +50,6 @@ use crate::util::scid_utils::scid_from_parts;
 use crate::io;
 use crate::prelude::*;
 use core::{cmp,mem,fmt};
-use core::convert::TryInto;
 use core::ops::Deref;
 #[cfg(any(test, fuzzing, debug_assertions))]
 use crate::sync::Mutex;
index 04ce90445f994b6216f1a9c58ee7fcccbfcd8501..ff91654a3f79a33f2ed42cf9d2d4017ebde8fbae 100644 (file)
 //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md
 //! [messages]: crate::ln::msgs
 
-use crate::{io, io_extras};
+#[allow(unused_imports)]
 use crate::prelude::*;
+
+use crate::{io, io_extras};
 use core::{cmp, fmt};
 use core::borrow::Borrow;
 use core::hash::{Hash, Hasher};
@@ -91,6 +93,7 @@ use crate::ln::msgs::DecodeError;
 use crate::util::ser::{Readable, WithoutLength, Writeable, Writer};
 
 mod sealed {
+       #[allow(unused_imports)]
        use crate::prelude::*;
        use crate::ln::features::Features;
 
index eee9ef49b60bcd14e5ebd962b7486a8af1b3880f..5ea3e6372c0d1c497c0b8fcde11961cfdb4206b0 100644 (file)
@@ -49,12 +49,9 @@ use bitcoin::OutPoint as BitcoinOutPoint;
 use bitcoin::secp256k1::Secp256k1;
 use bitcoin::secp256k1::{PublicKey,SecretKey};
 
-use regex;
-
 use crate::io;
 use crate::prelude::*;
 use alloc::collections::BTreeSet;
-use core::default::Default;
 use core::iter::repeat;
 use bitcoin::hashes::Hash;
 use crate::sync::{Arc, Mutex, RwLock};
index eeae514fdf3ce4097f79487ed09ceace231cadd4..f27d8aab1195284a0a03c74e9af2e093e8482a65 100644 (file)
@@ -9,7 +9,6 @@
 
 //! Utilities to generate inbound payment information in service of invoice creation.
 
-use alloc::string::ToString;
 use bitcoin::hashes::{Hash, HashEngine};
 use bitcoin::hashes::cmp::fixed_time_eq;
 use bitcoin::hashes::hmac::{Hmac, HmacEngine};
@@ -23,7 +22,9 @@ use crate::crypto::utils::hkdf_extract_expand_5x;
 use crate::util::errors::APIError;
 use crate::util::logger::Logger;
 
-use core::convert::{TryFrom, TryInto};
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 use core::ops::Deref;
 
 pub(crate) const IV_LEN: usize = 16;
index 25b32c4c79dda078d3daaac73b3ece86e9414c48..26a384dffd4768d9bb9e836c28fff2fa1849585a 100644 (file)
@@ -126,7 +126,9 @@ impl From<PaymentPreimage> for PaymentHash {
 #[derive(Hash, Copy, Clone, PartialEq, Eq, Debug, Ord, PartialOrd)]
 pub struct PaymentSecret(pub [u8; 32]);
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use bitcoin::bech32;
 use bitcoin::bech32::{Base32Len, FromBase32, ToBase32, WriteBase32, u5};
 
index 19fbbae31669b0fb9aad4132593c12ed6f261165..8040d8c420984f6dae30fbd986d21afc036e7acb 100644 (file)
@@ -38,9 +38,9 @@ use crate::ln::onion_utils;
 use crate::onion_message;
 use crate::sign::{NodeSigner, Recipient};
 
+#[allow(unused_imports)]
 use crate::prelude::*;
-#[cfg(feature = "std")]
-use core::convert::TryFrom;
+
 use core::fmt;
 use core::fmt::Debug;
 use core::ops::Deref;
@@ -1673,11 +1673,13 @@ pub struct FinalOnionHopData {
 mod fuzzy_internal_msgs {
        use bitcoin::secp256k1::PublicKey;
        use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay};
-       use crate::prelude::*;
        use crate::ln::{PaymentPreimage, PaymentSecret};
        use crate::ln::features::BlindedHopFeatures;
        use super::{FinalOnionHopData, TrampolineOnionPacket};
 
+       #[allow(unused_imports)]
+       use crate::prelude::*;
+
        // These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
        // them from untrusted input):
 
@@ -3163,7 +3165,6 @@ impl_writeable_msg!(GossipTimestampFilter, {
 
 #[cfg(test)]
 mod tests {
-       use std::convert::TryFrom;
        use bitcoin::{Transaction, TxIn, ScriptBuf, Sequence, Witness, TxOut};
        use hex::DisplayHex;
        use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
index a5560e2802014ce23eb2568979c2e301762a0995..aa8ee0ce9be6bfe3a46301c4cb5d9c57610f49c5 100644 (file)
@@ -20,7 +20,9 @@ use crate::ln::onion_utils::{HTLCFailReason, INVALID_ONION_BLINDING};
 use crate::sign::{NodeSigner, Recipient};
 use crate::util::logger::Logger;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use core::ops::Deref;
 
 /// Invalid inbound onion payment.
index 80c588e2562e993bdb0cd78cf84bff236aeca593..aeb175bc62660b6091c0a71a3960e4dc6ca1bc5e 100644 (file)
@@ -39,7 +39,6 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
 
 use crate::io;
 use crate::prelude::*;
-use core::default::Default;
 use bitcoin::hashes::hex::FromHex;
 
 use crate::ln::functional_test_utils::*;
index a946dae6779077396f03aeedc578fa0cadde2f90..f2b5c69e9e677fb10e3886e4240b58bacd66395a 100644 (file)
@@ -30,10 +30,11 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
 use bitcoin::secp256k1::{PublicKey, Scalar, Secp256k1, SecretKey};
 
 use crate::io::{Cursor, Read};
-use crate::prelude::*;
-use core::convert::{AsMut, TryInto};
 use core::ops::Deref;
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 pub(crate) struct OnionKeys {
        #[cfg(test)]
        pub(crate) shared_secret: SharedSecret,
@@ -1240,10 +1241,12 @@ mod tests {
        use crate::ln::features::{ChannelFeatures, NodeFeatures};
        use crate::ln::msgs;
        use crate::ln::PaymentHash;
-       use crate::prelude::*;
        use crate::routing::router::{Path, Route, RouteHop};
        use crate::util::ser::{VecWriter, Writeable, Writer};
 
+       #[allow(unused_imports)]
+       use crate::prelude::*;
+
        use bitcoin::hashes::hex::FromHex;
        use bitcoin::secp256k1::Secp256k1;
        use bitcoin::secp256k1::{PublicKey, SecretKey};
index 188023dc99c17316bf65f0190f09d01f14aa3e6d..9c27a23467ce7a8e7134225f352fc961a3998ace 100644 (file)
@@ -36,9 +36,10 @@ use crate::util::atomic_counter::AtomicCounter;
 use crate::util::logger::{Level, Logger, WithContext};
 use crate::util::string::PrintableString;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use crate::io;
-use alloc::collections::VecDeque;
 use crate::sync::{Mutex, MutexGuard, FairRwLock};
 use core::sync::atomic::{AtomicBool, AtomicU32, AtomicI32, Ordering};
 use core::{cmp, hash, fmt, mem};
@@ -2682,11 +2683,13 @@ mod tests {
        use bitcoin::blockdata::constants::ChainHash;
        use bitcoin::secp256k1::{PublicKey, SecretKey};
 
-       use crate::prelude::*;
        use crate::sync::{Arc, Mutex};
        use core::convert::Infallible;
        use core::sync::atomic::{AtomicBool, Ordering};
 
+       #[allow(unused_imports)]
+       use crate::prelude::*;
+
        #[derive(Clone)]
        struct FileDescriptor {
                fd: u16,
index 3d799df8d7327d5f0895804f66c64e94cfa94b7d..6fd8623d317376b5b6d156869c2a5949bca7e33d 100644 (file)
@@ -26,7 +26,6 @@ use crate::util::ser::Writeable;
 use crate::util::test_utils;
 
 use crate::prelude::*;
-use core::default::Default;
 
 use crate::ln::functional_test_utils::*;
 
index fa216bc15f4355f2b9b7fcd55cf844061451c1db..8b25f7701be5a2a48dad594c5bc48442c49e3253 100644 (file)
@@ -27,7 +27,6 @@ use crate::util::config::UserConfig;
 use bitcoin::hash_types::BlockHash;
 
 use crate::prelude::*;
-use core::default::Default;
 use crate::sync::Mutex;
 
 use crate::ln::functional_test_utils::*;
index dc733dd25a1f0ca154c773f1987d4861e4d30a23..1909eb0c5f7df5f347ea0484bfbdd08fa8a239f8 100644 (file)
@@ -12,9 +12,11 @@ use crate::ln::features::InitFeatures;
 use crate::ln::msgs::DecodeError;
 use crate::util::ser::{Readable, Writeable, Writer};
 
-use core::convert::TryFrom;
 use crate::io;
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 /// A script pubkey for shutting down a channel as defined by [BOLT #2].
 ///
 /// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md
@@ -167,13 +169,15 @@ impl core::fmt::Display for ShutdownScript{
 #[cfg(test)]
 mod shutdown_script_tests {
        use super::ShutdownScript;
+
+       use bitcoin::address::{WitnessProgram, WitnessVersion};
        use bitcoin::blockdata::opcodes;
        use bitcoin::blockdata::script::{Builder, ScriptBuf};
        use bitcoin::secp256k1::Secp256k1;
        use bitcoin::secp256k1::{PublicKey, SecretKey};
+
        use crate::ln::features::InitFeatures;
-       use core::convert::TryFrom;
-       use bitcoin::address::{WitnessProgram, WitnessVersion};
+       use crate::prelude::*;
 
        fn pubkey() -> bitcoin::key::PublicKey {
                let secp_ctx = Secp256k1::signing_only();
index c6d0cc58b9bf299a1fc2d6e06a34a9a6bc0b3958..7f004948ffeb5cb10790673e5fa36680950bef23 100644 (file)
@@ -25,6 +25,7 @@ use crate::util::test_utils::OnGetShutdownScriptpubkey;
 use crate::util::errors::APIError;
 use crate::util::config::UserConfig;
 use crate::util::string::UntrustedString;
+use crate::prelude::*;
 
 use bitcoin::{Transaction, TxOut};
 use bitcoin::blockdata::locktime::absolute::LockTime;
@@ -33,11 +34,6 @@ use bitcoin::blockdata::opcodes;
 use bitcoin::network::constants::Network;
 use bitcoin::address::{WitnessProgram, WitnessVersion};
 
-use regex;
-
-use core::default::Default;
-use std::convert::TryFrom;
-
 use crate::ln::functional_test_utils::*;
 
 #[test]
index 5087df33b83fee55bfd7edc788ae13459deb486e..dc4eecde6306748e972657423049eef17b879929 100644 (file)
@@ -617,7 +617,6 @@ impl Encode for msgs::GossipTimestampFilter {
 mod tests {
        use super::*;
        use crate::prelude::*;
-       use core::convert::TryInto;
        use crate::ln::peer_handler::IgnoringMessageHandler;
 
        // Big-endian wire encoding of Pong message (type = 19, byteslen = 2).
index fc8371023484d8ade7a2708340a0e2402685d710..f2fb387942dc303e2c895e4e4917777a07aa6492 100644 (file)
@@ -1,4 +1,4 @@
-// This file is Copyright its original authors, visible in version control
+    // This file is Copyright its original authors, visible in version control
 // history.
 //
 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
@@ -110,7 +110,6 @@ use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
 use bitcoin::secp256k1::schnorr::Signature;
 use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion};
 use bitcoin::key::TweakedPublicKey;
-use core::convert::{AsRef, TryFrom};
 use core::time::Duration;
 use crate::io;
 use crate::blinded_path::BlindedPath;
@@ -129,6 +128,7 @@ use crate::offers::signer;
 use crate::util::ser::{HighZeroBytesDroppedBigSize, Iterable, SeekReadable, WithoutLength, Writeable, Writer};
 use crate::util::string::PrintableString;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 #[cfg(feature = "std")]
@@ -1452,8 +1452,9 @@ mod tests {
        use bitcoin::secp256k1::{Message, Secp256k1, XOnlyPublicKey, self};
        use bitcoin::address::{Address, Payload, WitnessProgram, WitnessVersion};
        use bitcoin::key::TweakedPublicKey;
-       use core::convert::TryFrom;
+
        use core::time::Duration;
+
        use crate::blinded_path::{BlindedHop, BlindedPath};
        use crate::sign::KeyMaterial;
        use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
@@ -1462,6 +1463,7 @@ mod tests {
        use crate::offers::invoice_request::InvoiceRequestTlvStreamRef;
        use crate::offers::merkle::{SignError, SignatureTlvStreamRef, TaggedHash, self};
        use crate::offers::offer::{Amount, OfferTlvStreamRef, Quantity};
+       use crate::prelude::*;
        #[cfg(not(c_bindings))]
        use {
                crate::offers::offer::OfferBuilder,
index 5476ad551b7b627d5e1abac8d19fc836b673e54c..1b634525416acef1a249858a7d78cc44b3c03b06 100644 (file)
@@ -15,6 +15,7 @@ use crate::offers::parse::Bolt12SemanticError;
 use crate::util::ser::{HighZeroBytesDroppedBigSize, Readable, WithoutLength, Writeable, Writer};
 use crate::util::string::UntrustedString;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 /// An error in response to an [`InvoiceRequest`] or an [`Bolt12Invoice`].
index f282075d9333cf1f9002154519474518036b9336..5e3ed40ac08db2b2a8a662c357bb4eb475fb45fc 100644 (file)
@@ -61,7 +61,6 @@ use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::network::constants::Network;
 use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
 use bitcoin::secp256k1::schnorr::Signature;
-use core::convert::{AsRef, TryFrom};
 use core::ops::Deref;
 use crate::sign::EntropySource;
 use crate::io;
@@ -89,6 +88,7 @@ use {
        crate::offers::invoice::{InvoiceWithDerivedSigningPubkeyBuilder, InvoiceWithExplicitSigningPubkeyBuilder},
 };
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 /// Tag for the hash function used when signing an [`InvoiceRequest`]'s merkle root.
@@ -1103,7 +1103,6 @@ mod tests {
        use bitcoin::blockdata::constants::ChainHash;
        use bitcoin::network::constants::Network;
        use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey, self};
-       use core::convert::TryFrom;
        use core::num::NonZeroU64;
        #[cfg(feature = "std")]
        use core::time::Duration;
index 941bf196716d8b5ee2d2e51d2c4db95716bdf869..da3fab589966d8d3d5988437a72aec56bbc1b8d8 100644 (file)
 use bitcoin::hashes::{Hash, HashEngine, sha256};
 use bitcoin::secp256k1::{Message, PublicKey, Secp256k1, self};
 use bitcoin::secp256k1::schnorr::Signature;
-use core::convert::AsRef;
 use crate::io;
 use crate::util::ser::{BigSize, Readable, Writeable, Writer};
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 /// Valid type range for signature TLV records.
index bf5e50deb77b8c290c1385f3459b76fb17bfbd6d..7f48be23e004689d4584b4a3c0ea3653db3b408d 100644 (file)
@@ -79,7 +79,6 @@
 use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::network::constants::Network;
 use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
-use core::convert::TryFrom;
 use core::hash::{Hash, Hasher};
 use core::num::NonZeroU64;
 use core::ops::Deref;
@@ -107,6 +106,7 @@ use {
        crate::offers::invoice_request::{InvoiceRequestWithDerivedPayerIdBuilder, InvoiceRequestWithExplicitPayerIdBuilder},
 };
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 #[cfg(feature = "std")]
@@ -1066,7 +1066,6 @@ mod tests {
        use bitcoin::blockdata::constants::ChainHash;
        use bitcoin::network::constants::Network;
        use bitcoin::secp256k1::Secp256k1;
-       use core::convert::TryFrom;
        use core::num::NonZeroU64;
        use core::time::Duration;
        use crate::blinded_path::{BlindedHop, BlindedPath};
index 400cf51a2944d47cc0afd19e227acb3216242959..72c4c380d52592f8c87b59c9f50653a449fec0b9 100644 (file)
 
 use bitcoin::bech32;
 use bitcoin::secp256k1;
-use core::convert::TryFrom;
 use crate::io;
 use crate::ln::msgs::DecodeError;
 use crate::util::ser::SeekReadable;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 #[cfg(not(fuzzing))]
@@ -27,10 +27,10 @@ pub use sealed::Bech32Encode;
 mod sealed {
        use bitcoin::bech32;
        use bitcoin::bech32::{FromBase32, ToBase32};
-       use core::convert::TryFrom;
        use core::fmt;
        use super::Bolt12ParseError;
 
+       #[allow(unused_imports)]
        use crate::prelude::*;
 
        /// Indicates a message can be encoded using bech32.
index 19aef23363d8e0afc9a5ddd758d5808098d1d03f..22180ce5f66fef52a2cba2a434c61e769cb287b8 100644 (file)
@@ -12,6 +12,7 @@
 use crate::offers::signer::Metadata;
 use crate::util::ser::WithoutLength;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 /// An unpredictable sequence of bytes typically containing information needed to derive
index 42177960868ab553ee1385f2569146dc8209e2bf..73b48521ae670659bb4781f7f670a694b862dea2 100644 (file)
@@ -84,7 +84,6 @@
 use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::network::constants::Network;
 use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
-use core::convert::TryFrom;
 use core::hash::{Hash, Hasher};
 use core::ops::Deref;
 use core::str::FromStr;
@@ -115,6 +114,7 @@ use {
        crate::offers::invoice::{InvoiceWithDerivedSigningPubkeyBuilder, InvoiceWithExplicitSigningPubkeyBuilder},
 };
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 #[cfg(feature = "std")]
@@ -894,8 +894,9 @@ mod tests {
        use bitcoin::blockdata::constants::ChainHash;
        use bitcoin::network::constants::Network;
        use bitcoin::secp256k1::{KeyPair, Secp256k1, SecretKey};
-       use core::convert::TryFrom;
+
        use core::time::Duration;
+
        use crate::blinded_path::{BlindedHop, BlindedPath};
        use crate::sign::KeyMaterial;
        use crate::ln::channelmanager::PaymentId;
@@ -909,6 +910,7 @@ mod tests {
        use crate::offers::test_utils::*;
        use crate::util::ser::{BigSize, Writeable};
        use crate::util::string::PrintableString;
+       use crate::prelude::*;
 
        trait ToBytes {
                fn to_bytes(&self) -> Vec<u8>;
index e0abd82767f6c9fd51dc0a7e425f7236631a0f67..c5a96cbf18491e3f22eb830c879eb4d274e9abc3 100644 (file)
@@ -14,7 +14,6 @@ use bitcoin::hashes::cmp::fixed_time_eq;
 use bitcoin::hashes::hmac::{Hmac, HmacEngine};
 use bitcoin::hashes::sha256::Hash as Sha256;
 use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey, self};
-use core::convert::TryFrom;
 use core::fmt;
 use crate::ln::channelmanager::PaymentId;
 use crate::ln::inbound_payment::{ExpandedKey, IV_LEN, Nonce};
index 29bed53d83f561f030e4966373c4403020ac6ffc..b4329803016fadb395689bf696e30d78c2984e97 100644 (file)
@@ -11,7 +11,7 @@
 
 use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
 use bitcoin::secp256k1::schnorr::Signature;
-use core::convert::AsRef; 
+
 use core::time::Duration;
 use crate::blinded_path::{BlindedHop, BlindedPath};
 use crate::sign::EntropySource;
@@ -20,6 +20,9 @@ use crate::ln::features::BlindedHopFeatures;
 use crate::offers::invoice::BlindedPayInfo;
 use crate::offers::merkle::TaggedHash;
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 pub(crate) fn fail_sign<T: AsRef<TaggedHash>>(_message: &T) -> Result<Signature, ()> {
        Err(())
 }
index 6672b5dfcdd0f3e33025c4bfe0654d6cfd2b0e56..faf539f868261a97768e6051b22451861db737ca 100644 (file)
@@ -9,7 +9,6 @@
 
 //! Message handling for BOLT 12 Offers.
 
-use core::convert::TryFrom;
 use core::fmt;
 use crate::io::{self, Read};
 use crate::ln::msgs::DecodeError;
index 045772486ba7aa150636a1e7b5420a606e87ce64..42bf20a78a51684056f896b50fc510d18b279d0f 100644 (file)
@@ -38,7 +38,6 @@ use crate::io;
 use crate::io_extras::{copy, sink};
 use crate::prelude::*;
 use core::{cmp, fmt};
-use core::convert::TryFrom;
 use crate::sync::{RwLock, RwLockReadGuard, LockTestExt};
 #[cfg(feature = "std")]
 use core::sync::atomic::{AtomicUsize, Ordering};
index 8d37182266b11debdda0d96787358c36c87dcd59..e8276712ee89504e002b619aa70544a147467840 100644 (file)
@@ -3259,8 +3259,6 @@ mod tests {
        use crate::prelude::*;
        use crate::sync::Arc;
 
-       use core::convert::TryInto;
-
        fn get_channel_details(short_channel_id: Option<u64>, node_id: PublicKey,
                        features: InitFeatures, outbound_capacity_msat: u64) -> channelmanager::ChannelDetails {
                channelmanager::ChannelDetails {
@@ -8344,17 +8342,14 @@ pub(crate) mod bench_utils {
        use std::time::Duration;
 
        use bitcoin::hashes::Hash;
-       use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
+       use bitcoin::secp256k1::SecretKey;
 
        use crate::chain::transaction::OutPoint;
        use crate::routing::scoring::ScoreUpdate;
-       use crate::sign::{EntropySource, KeysManager};
+       use crate::sign::KeysManager;
        use crate::ln::ChannelId;
-       use crate::ln::channelmanager::{self, ChannelCounterparty, ChannelDetails};
-       use crate::ln::features::Bolt11InvoiceFeatures;
-       use crate::routing::gossip::NetworkGraph;
+       use crate::ln::channelmanager::{self, ChannelCounterparty};
        use crate::util::config::UserConfig;
-       use crate::util::ser::ReadableArgs;
        use crate::util::test_utils::TestLogger;
 
        /// Tries to open a network graph file, or panics with a URL to fetch it.
index bb043164a0e8895f8bbe95c8d0f50b7025d8365b..4850479b8992905cc20e6d1e219dab6251081b28 100644 (file)
@@ -64,7 +64,6 @@ use crate::util::logger::Logger;
 
 use crate::prelude::*;
 use core::{cmp, fmt};
-use core::convert::TryInto;
 use core::ops::{Deref, DerefMut};
 use core::time::Duration;
 use crate::io::{self, Read};
index 9f03b4451eff025665517769934b9a62fd09be47..6aca76a21678ceabc25f3e66ded06c96b1f883aa 100644 (file)
@@ -21,6 +21,7 @@ use bitcoin::network::constants::Network;
 use bitcoin::secp256k1::{PublicKey,SecretKey};
 use bitcoin::secp256k1::{Secp256k1, All};
 
+#[allow(unused)]
 use crate::prelude::*;
 use crate::sync::{self, Arc};
 
index ada90345ee6861ac53a7d81191ea04bfe93a508d..e775e2628f6ca1df9e497a084506be7dd7eed6eb 100644 (file)
@@ -563,7 +563,6 @@ mod tests {
        use super::*;
        use crate::routing::gossip::tests::*;
        use crate::util::test_utils::{TestChainSource, TestLogger};
-       use crate::ln::msgs;
 
        use bitcoin::secp256k1::{Secp256k1, SecretKey};
 
index 070f48f122f9d6365bade472bb87fe3af8ee1b47..45152cf6937d668496b66166c42d96614f084e54 100644 (file)
@@ -11,7 +11,9 @@ use crate::ln::PaymentPreimage;
 use crate::ln::chan_utils::{HTLCOutputInCommitment, HolderCommitmentTransaction, CommitmentTransaction, ClosingTransaction};
 use crate::ln::msgs::UnsignedChannelAnnouncement;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use crate::sign::{ChannelSigner, HTLCDescriptor};
 
 /// A trait to sign Lightning channel transactions as described in
index a7237493be7592676d0d22b2d6e00e43cf929995..c959b115cf0236a7d073a2f77ca17bbe897d6289 100644 (file)
@@ -53,7 +53,6 @@ use crate::offers::invoice::UnsignedBolt12Invoice;
 use crate::offers::invoice_request::UnsignedInvoiceRequest;
 
 use crate::prelude::*;
-use core::convert::TryInto;
 use core::ops::Deref;
 use core::sync::atomic::{AtomicUsize, Ordering};
 #[cfg(taproot)]
index 2b75e095380ec09f22d07d4d1bd636dd93e53c61..5968a79ee4daa50439a3cac96478c49d3803458b 100644 (file)
@@ -103,7 +103,9 @@ fn locate_call_symbol(backtrace: &Backtrace) -> (String, Option<u32>) {
                        }
                }
        }
-       let symbol = symbol_after_latest_debug_sync.expect("Couldn't find lock call symbol");
+       let symbol = symbol_after_latest_debug_sync.unwrap_or_else(|| {
+               panic!("Couldn't find lock call symbol in trace {:?}", backtrace);
+       });
        (format!("{}:{}", symbol.filename().unwrap().display(), symbol.lineno().unwrap()), symbol.colno())
 }
 
index 2e66d59383fb9d7db7d81fdbafdf1beb8d4e31d7..e116dccbf59ad5bee31f1aa50bb7e2323f127774 100644 (file)
@@ -6,7 +6,7 @@
 // Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or
 // MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
 
-
+#[allow(unused)]
 use crate::prelude::*;
 
 /// RFC4648 encoding table
index 4ffde9a72d2cba94927e36373125d0d06fdb73d4..735ce044f810b6a4f9aa97e500c1c628cd43ee4d 100644 (file)
@@ -11,7 +11,9 @@
 
 use crate::ln::script::ShutdownScript;
 
-use alloc::string::String;
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 use core::fmt;
 
 /// Indicates an error on the client's part (usually some variant of attempting to use too-low or
index d4c20f722154fe499c68a296c45f25d8dd55aff4..4f694bd2b6ec723e5dcaed614db36bdad0ea2aeb 100644 (file)
@@ -1,10 +1,8 @@
 //! This module has a map which can be iterated in a deterministic order. See the [`IndexedMap`].
 
 use crate::prelude::*;
-use alloc::vec::Vec;
 use alloc::slice::Iter;
 use core::hash::Hash;
-use core::cmp::Ord;
 use core::ops::{Bound, RangeBounds};
 
 /// A map which can be iterated in a deterministic order.
index 8c22200b9b2c2fecebfb4276228a91ce97db1274..b6cf452ffc955935a55a3e4cb801c649fb10d915 100644 (file)
@@ -1,6 +1,8 @@
 //! Low level invoice utilities.
 
 use bitcoin::bech32::{u5, FromBase32};
+
+#[allow(unused)]
 use crate::prelude::*;
 
 /// Construct the invoice's HRP and signatureless data into a preimage to be hashed.
index 88ff18ff204c8ae96ee723bd0a718bed0ae3394a..79572f31246a7ae53fa1885b13ee3cc282c68d50 100644 (file)
@@ -20,6 +20,7 @@
 //! <https://lightning.readthedocs.io/lightning-signmessage.7.html>
 //! <https://api.lightning.community/#signmessage>
 
+#[allow(unused)]
 use crate::prelude::*;
 use crate::util::base32;
 use bitcoin::hashes::{sha256d, Hash};
index a7b4bda6f31110a569645affba56f6a9a862e465..6fd0048daf7ddeec9e3f754c0f368e44572891d4 100644 (file)
 //! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
 
 use core::cmp;
-use core::convert::{TryFrom, TryInto};
 use core::ops::Deref;
 use core::str::FromStr;
 use bitcoin::{BlockHash, Txid};
 
 use crate::{io, log_error};
-use crate::alloc::string::ToString;
 use crate::prelude::*;
 
 use crate::chain;
@@ -837,7 +835,6 @@ impl From<u64> for UpdateName {
 #[cfg(test)]
 mod tests {
        use super::*;
-       use crate::chain::chainmonitor::Persist;
        use crate::chain::ChannelMonitorUpdateStatus;
        use crate::events::{ClosureReason, MessageSendEventsProvider};
        use crate::ln::functional_test_utils::*;
index 38be0eb88fc3bdc0767c6725e30fb7437f3bbec4..c9485b60b70be78fd88b52eb45703c74f4da5af1 100644 (file)
@@ -76,8 +76,8 @@ pub(crate) mod fake_scid {
        use crate::sign::EntropySource;
        use crate::crypto::chacha20::ChaCha20;
        use crate::util::scid_utils;
+       use crate::prelude::*;
 
-       use core::convert::TryInto;
        use core::ops::Deref;
 
        const TEST_SEGWIT_ACTIVATION_HEIGHT: u32 = 1;
index 7ff6b248cfb423feabf6d5277a0178aceaef82d7..f88d9f36a72832ef1161c4ff65b48abb9e66a14a 100644 (file)
@@ -19,7 +19,6 @@ use crate::io_extras::{copy, sink};
 use core::hash::Hash;
 use crate::sync::{Mutex, RwLock};
 use core::cmp;
-use core::convert::TryFrom;
 use core::ops::Deref;
 
 use alloc::collections::BTreeMap;
@@ -35,7 +34,6 @@ use bitcoin::{consensus, Witness};
 use bitcoin::consensus::Encodable;
 use bitcoin::hashes::sha256d::Hash as Sha256dHash;
 use bitcoin::hash_types::{Txid, BlockHash};
-use core::marker::Sized;
 use core::time::Duration;
 use crate::chain::ClaimId;
 use crate::ln::msgs::DecodeError;
@@ -1494,10 +1492,10 @@ impl Readable for ClaimId {
 
 #[cfg(test)]
 mod tests {
-       use core::convert::TryFrom;
        use bitcoin::hashes::hex::FromHex;
        use bitcoin::secp256k1::ecdsa;
        use crate::util::ser::{Readable, Hostname, Writeable};
+       use crate::prelude::*;
 
        #[test]
        fn hostname_conversion() {
index dce160a7c5eecd5325ef30b9a219f8a067bf5fce..312fe7d9f98424ea2a0ad3dc3231cd765d50e624 100644 (file)
@@ -1112,8 +1112,10 @@ macro_rules! impl_writeable_tlv_based_enum_upgradable {
 
 #[cfg(test)]
 mod tests {
-       use crate::io::{self, Cursor};
+       #[allow(unused_imports)]
        use crate::prelude::*;
+
+       use crate::io::{self, Cursor};
        use crate::ln::msgs::DecodeError;
        use crate::util::ser::{Writeable, HighZeroBytesDroppedBigSize, VecWriter};
        use bitcoin::hashes::hex::FromHex;
index 6949c936e00e575ad8b4a848e61ee892a65b3eca..ab12486a0d8ebfbac985dd3289b8e6dbeb23f3f2 100644 (file)
@@ -9,12 +9,14 @@
 
 //! Utilities for strings.
 
-use alloc::string::String;
 use core::fmt;
 use crate::io::{self, Read};
 use crate::ln::msgs;
 use crate::util::ser::{Writeable, Writer, Readable};
 
+#[allow(unused_imports)]
+use crate::prelude::*;
+
 /// Struct to `Display` fields in a safe way using `PrintableString`
 #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
 pub struct UntrustedString(pub String);
index bfa3e32c91f5b3d683c26d5b9f9bf2700512efb6..43ac9ff87e95f20d792aead9348a341dbb25b9e5 100644 (file)
@@ -14,7 +14,9 @@ use crate::ln::{msgs, PaymentPreimage};
 use crate::sign::{InMemorySigner, ChannelSigner};
 use crate::sign::ecdsa::{EcdsaChannelSigner, WriteableEcdsaChannelSigner};
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use core::cmp;
 use crate::sync::{Mutex, Arc};
 #[cfg(test)] use crate::sync::MutexGuard;
index 15cc07466d603b4f049d00fc52df7bb546765107..305dc40a0a296e701add66f2066d8182c0eb4d78 100644 (file)
@@ -13,6 +13,7 @@ use crate::chain;
 use crate::chain::WatchedOutput;
 use crate::chain::chaininterface;
 use crate::chain::chaininterface::ConfirmationTarget;
+#[cfg(test)]
 use crate::chain::chaininterface::FEERATE_FLOOR_SATS_PER_KW;
 use crate::chain::chainmonitor;
 use crate::chain::chainmonitor::{MonitorUpdateId, UpdateOrigin};
@@ -25,6 +26,7 @@ use crate::events;
 use crate::events::bump_transaction::{WalletSource, Utxo};
 use crate::ln::ChannelId;
 use crate::ln::channelmanager::{ChannelDetails, self};
+#[cfg(test)]
 use crate::ln::chan_utils::CommitmentTransaction;
 use crate::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
 use crate::ln::{msgs, wire};
@@ -59,9 +61,6 @@ use bitcoin::secp256k1::ecdh::SharedSecret;
 use bitcoin::secp256k1::ecdsa::{RecoverableSignature, Signature};
 use bitcoin::secp256k1::schnorr;
 
-#[cfg(any(test, feature = "_test_utils"))]
-use regex;
-
 use crate::io;
 use crate::prelude::*;
 use core::cell::RefCell;
@@ -399,12 +398,14 @@ impl<'a> chain::Watch<TestChannelSigner> for TestChainMonitor<'a> {
        }
 }
 
+#[cfg(test)]
 struct JusticeTxData {
        justice_tx: Transaction,
        value: u64,
        commitment_number: u64,
 }
 
+#[cfg(test)]
 pub(crate) struct WatchtowerPersister {
        persister: TestPersister,
        /// Upon a new commitment_signed, we'll get a
@@ -418,6 +419,7 @@ pub(crate) struct WatchtowerPersister {
        destination_script: ScriptBuf,
 }
 
+#[cfg(test)]
 impl WatchtowerPersister {
        #[cfg(test)]
        pub(crate) fn new(destination_script: ScriptBuf) -> Self {
@@ -448,6 +450,7 @@ impl WatchtowerPersister {
        }
 }
 
+#[cfg(test)]
 impl<Signer: sign::ecdsa::WriteableEcdsaChannelSigner> chainmonitor::Persist<Signer> for WatchtowerPersister {
        fn persist_new_channel(&self, funding_txo: OutPoint,
                data: &channelmonitor::ChannelMonitor<Signer>, id: MonitorUpdateId
index a6e6f4d1fda6b6e58a102a0baeb97cbed102159f..bedeab1d4890ac78c0dbda3f2506e8a28ee9f07d 100644 (file)
@@ -16,16 +16,8 @@ pub trait Time: Copy + Sub<Duration, Output = Self> where Self: Sized {
        /// Returns an instance corresponding to the current moment.
        fn now() -> Self;
 
-       /// Returns the amount of time elapsed since `self` was created.
-       fn elapsed(&self) -> Duration;
-
        /// Returns the amount of time passed between `earlier` and `self`.
        fn duration_since(&self, earlier: Self) -> Duration;
-
-       /// Returns the amount of time passed since the beginning of [`Time`].
-       ///
-       /// Used during (de-)serialization.
-       fn duration_since_epoch() -> Duration;
 }
 
 /// A state in which time has no meaning.
@@ -40,14 +32,6 @@ impl Time for Eternity {
        fn duration_since(&self, _earlier: Self) -> Duration {
                Duration::from_secs(0)
        }
-
-       fn duration_since_epoch() -> Duration {
-               Duration::from_secs(0)
-       }
-
-       fn elapsed(&self) -> Duration {
-               Duration::from_secs(0)
-       }
 }
 
 impl Sub<Duration> for Eternity {
@@ -82,15 +66,6 @@ impl Time for MonotonicTime {
                let now = Self::now();
                if now.0 > earlier.0 { now.0 - earlier.0 } else { Duration::from_secs(0) }
        }
-
-       fn duration_since_epoch() -> Duration {
-               use std::time::SystemTime;
-               SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap()
-       }
-
-       fn elapsed(&self) -> Duration {
-               Self::now().0 - self.0
-       }
 }
 
 #[cfg(feature = "std")]
@@ -127,20 +102,12 @@ pub mod tests {
 
        impl Time for SinceEpoch {
                fn now() -> Self {
-                       Self(Self::duration_since_epoch())
+                       Self(Self::ELAPSED.with(|elapsed| elapsed.get()))
                }
 
                fn duration_since(&self, earlier: Self) -> Duration {
                        self.0 - earlier.0
                }
-
-               fn duration_since_epoch() -> Duration {
-                       Self::ELAPSED.with(|elapsed| elapsed.get())
-               }
-
-               fn elapsed(&self) -> Duration {
-                       Self::duration_since_epoch() - self.0
-               }
        }
 
        impl Sub<Duration> for SinceEpoch {
@@ -154,36 +121,20 @@ pub mod tests {
        #[test]
        fn time_passes_when_advanced() {
                let now = SinceEpoch::now();
-               assert_eq!(now.elapsed(), Duration::from_secs(0));
 
                SinceEpoch::advance(Duration::from_secs(1));
                SinceEpoch::advance(Duration::from_secs(1));
 
-               let elapsed = now.elapsed();
                let later = SinceEpoch::now();
 
-               assert_eq!(elapsed, Duration::from_secs(2));
-               assert_eq!(later - elapsed, now);
+               assert_eq!(now.0 + Duration::from_secs(2), later.0);
        }
 
        #[test]
        fn time_never_passes_in_an_eternity() {
                let now = Eternity::now();
-               let elapsed = now.elapsed();
                let later = Eternity::now();
 
-               assert_eq!(now.elapsed(), Duration::from_secs(0));
-               assert_eq!(later - elapsed, now);
-       }
-
-       #[test]
-       #[cfg(feature = "std")]
-       fn monotonic_time_subtracts() {
-               let now = super::MonotonicTime::now();
-               assert!(now.elapsed() < Duration::from_secs(10));
-
-               let ten_years = Duration::from_secs(10 * 365 * 24 * 60 * 60);
-               let past = now - ten_years;
-               assert!(past.elapsed() >= ten_years);
+               assert_eq!(later, now);
        }
 }
index 12b504a69ef8dd50aceeeaed1ea9431fd905d8eb..59b7be6073c1dd9a1516adb25f3a41af1d0222f5 100644 (file)
@@ -14,7 +14,9 @@ use bitcoin::consensus::encode::VarInt;
 
 use crate::ln::msgs::MAX_VALUE_MSAT;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
+
 use crate::io_extras::sink;
 use core::cmp::Ordering;
 
@@ -72,8 +74,8 @@ mod tests {
        use super::*;
 
        use bitcoin::blockdata::locktime::absolute::LockTime;
-       use bitcoin::blockdata::transaction::{Transaction, TxOut, TxIn, OutPoint};
-       use bitcoin::blockdata::script::{ScriptBuf, Builder};
+       use bitcoin::blockdata::transaction::{TxIn, OutPoint};
+       use bitcoin::blockdata::script::Builder;
        use bitcoin::hash_types::{PubkeyHash, Txid};
        use bitcoin::hashes::Hash;
        use bitcoin::hashes::hex::FromHex;
index b2c9d21b998e790dba23570d49be13a2be6d2053..c95b3dbef3d90e66b118f92790256073a2f67dce 100644 (file)
@@ -17,6 +17,7 @@ use alloc::sync::Arc;
 use core::mem;
 use crate::sync::Mutex;
 
+#[allow(unused_imports)]
 use crate::prelude::*;
 
 #[cfg(feature = "std")]
@@ -305,7 +306,7 @@ mod tests {
        use super::*;
        use core::sync::atomic::{AtomicBool, Ordering};
        use core::future::Future as FutureTrait;
-       use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
+       use core::task::{RawWaker, RawWakerVTable};
 
        #[test]
        fn notifier_pre_notified_future() {