X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ftest_utils.rs;h=4f3d800be5dd8479f79a7999318fc627017e7078;hb=c502e8d1015f6000efa98182b8075392c1910f4d;hp=3682a0e8f0af02d1ac654853bff16e3096f4025a;hpb=b20aea1cb0fb9f19c646e96518ef9845e6593264;p=rust-lightning diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 3682a0e8..4f3d800b 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -31,7 +31,7 @@ use bitcoin::blockdata::constants::genesis_block; use bitcoin::blockdata::transaction::{Transaction, TxOut}; use bitcoin::blockdata::script::{Builder, Script}; use bitcoin::blockdata::opcodes; -use bitcoin::blockdata::block::BlockHeader; +use bitcoin::blockdata::block::Block; use bitcoin::network::constants::Network; use bitcoin::hash_types::{BlockHash, Txid}; @@ -116,6 +116,11 @@ impl<'a> TestChainMonitor<'a> { expect_channel_force_closed: Mutex::new(None), } } + + pub fn complete_sole_pending_chan_update(&self, channel_id: &[u8; 32]) { + let (outpoint, _, latest_update) = self.latest_monitor_update_id.lock().unwrap().get(channel_id).unwrap().clone(); + self.chain_monitor.channel_monitor_updated(outpoint, latest_update).unwrap(); + } } impl<'a> chain::Watch for TestChainMonitor<'a> { fn watch_channel(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), chain::ChannelMonitorUpdateErr> { @@ -224,11 +229,11 @@ impl chainmonitor::Persist for TestPersiste pub struct TestBroadcaster { pub txn_broadcasted: Mutex>, - pub blocks: Arc>>, + pub blocks: Arc>>, } impl TestBroadcaster { - pub fn new(blocks: Arc>>) -> TestBroadcaster { + pub fn new(blocks: Arc>>) -> TestBroadcaster { TestBroadcaster { txn_broadcasted: Mutex::new(Vec::new()), blocks } } } @@ -302,8 +307,8 @@ impl msgs::ChannelMessageHandler for TestChannelMessageHandler { fn handle_funding_signed(&self, _their_node_id: &PublicKey, msg: &msgs::FundingSigned) { self.received_msg(wire::Message::FundingSigned(msg.clone())); } - fn handle_funding_locked(&self, _their_node_id: &PublicKey, msg: &msgs::FundingLocked) { - self.received_msg(wire::Message::FundingLocked(msg.clone())); + fn handle_channel_ready(&self, _their_node_id: &PublicKey, msg: &msgs::ChannelReady) { + self.received_msg(wire::Message::ChannelReady(msg.clone())); } fn handle_shutdown(&self, _their_node_id: &PublicKey, _their_features: &InitFeatures, msg: &msgs::Shutdown) { self.received_msg(wire::Message::Shutdown(msg.clone()));