X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-background-processor%2Fsrc%2Flib.rs;h=4719d7e5c1aba8a7dd15c1bdf47f1447f872d39a;hb=5e3056e988c57b5285f976e3404f03fdfa2657cd;hp=b612dd96f6aa65fbb789dc32ed98b465df64ff07;hpb=92bf4602927ea6346e81f82ffbddda1a83b1541a;p=rust-lightning diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index b612dd96..4719d7e5 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -27,7 +27,7 @@ use lightning::chain::chainmonitor::{ChainMonitor, Persist}; use lightning::events::{Event, PathFailure}; #[cfg(feature = "std")] use lightning::events::EventHandler; -#[cfg(any(feature = "std", feature = "futures"))] +#[cfg(feature = "std")] use lightning::events::EventsProvider; use lightning::ln::channelmanager::AChannelManager; @@ -57,8 +57,6 @@ use std::time::Instant; #[cfg(not(feature = "std"))] use alloc::boxed::Box; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; /// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep /// Rust-Lightning running properly, and (2) either can or should be run in the background. Its @@ -915,13 +913,14 @@ impl Drop for BackgroundProcessor { #[cfg(all(feature = "std", test))] mod tests { - use bitcoin::{ScriptBuf, Txid}; + use bitcoin::{Amount, ScriptBuf, Txid}; use bitcoin::blockdata::constants::{genesis_block, ChainHash}; use bitcoin::blockdata::locktime::absolute::LockTime; use bitcoin::blockdata::transaction::{Transaction, TxOut}; use bitcoin::hashes::Hash; - use bitcoin::network::constants::Network; + use bitcoin::network::Network; use bitcoin::secp256k1::{SecretKey, PublicKey, Secp256k1}; + use bitcoin::transaction::Version; use lightning::chain::{BestBlock, Confirm, chainmonitor, Filter}; use lightning::chain::channelmonitor::ANTI_REORG_DELAY; use lightning::sign::{InMemorySigner, KeysManager, ChangeDestinationSource}; @@ -1352,8 +1351,8 @@ mod tests { assert_eq!(channel_value_satoshis, $channel_value); assert_eq!(user_channel_id, 42); - let tx = Transaction { version: 1 as i32, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut { - value: channel_value_satoshis, script_pubkey: output_script.clone(), + let tx = Transaction { version: Version::ONE, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut { + value: Amount::from_sat(channel_value_satoshis), script_pubkey: output_script.clone(), }]}; (temporary_channel_id, tx) }, @@ -1462,7 +1461,8 @@ mod tests { } // Force-close the channel. - nodes[0].node.force_close_broadcasting_latest_txn(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 }), &nodes[1].node.get_our_node_id()).unwrap(); + let error_message = "Channel force-closed"; + nodes[0].node.force_close_broadcasting_latest_txn(&ChannelId::v1_from_funding_outpoint(OutPoint { txid: tx.txid(), index: 0 }), &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap(); // Check that the force-close updates are persisted. check_persisted_data!(nodes[0].node, filepath.clone()); @@ -1658,7 +1658,8 @@ mod tests { let bg_processor = BackgroundProcessor::start(persister, event_handler, nodes[0].chain_monitor.clone(), nodes[0].node.clone(), Some(nodes[0].messenger.clone()), nodes[0].no_gossip_sync(), nodes[0].peer_manager.clone(), nodes[0].logger.clone(), Some(nodes[0].scorer.clone())); // Force close the channel and check that the SpendableOutputs event was handled. - nodes[0].node.force_close_broadcasting_latest_txn(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id()).unwrap(); + let error_message = "Channel force-closed"; + nodes[0].node.force_close_broadcasting_latest_txn(&nodes[0].node.list_channels()[0].channel_id, &nodes[1].node.get_our_node_id(), error_message.to_string()).unwrap(); let commitment_tx = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().pop().unwrap(); confirm_transaction_depth(&mut nodes[0], &commitment_tx, BREAKDOWN_TIMEOUT as u32);