use bitcoin::blockdata::transaction::Transaction;
use bitcoin::blockdata::script::Script;
-use bitcoin::util::hash::Sha256dHash;
+use bitcoin_hashes::sha256d::Hash as Sha256dHash;
use bitcoin::network::constants::Network;
use secp256k1::{SecretKey, PublicKey};
use std::sync::{Arc,Mutex};
use std::{mem};
-struct VecWriter(Vec<u8>);
-impl Writer for VecWriter {
+pub struct TestVecWriter(pub Vec<u8>);
+impl Writer for TestVecWriter {
fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> {
self.0.extend_from_slice(buf);
Ok(())
fn add_update_monitor(&self, funding_txo: OutPoint, monitor: channelmonitor::ChannelMonitor) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
// At every point where we get a monitor update, we should be able to send a useful monitor
// to a watchtower and disk...
- let mut w = VecWriter(Vec::new());
+ let mut w = TestVecWriter(Vec::new());
monitor.write_for_disk(&mut w).unwrap();
assert!(<(Sha256dHash, channelmonitor::ChannelMonitor)>::read(
&mut ::std::io::Cursor::new(&w.0), Arc::new(TestLogger::new())).unwrap().1 == monitor);
pub struct TestKeysInterface {
backing: keysinterface::KeysManager,
pub override_session_priv: Mutex<Option<SecretKey>>,
+ pub override_channel_id_priv: Mutex<Option<[u8; 32]>>,
}
impl keysinterface::KeysInterface for TestKeysInterface {
None => self.backing.get_session_key()
}
}
+
+ fn get_channel_id(&self) -> [u8; 32] {
+ match *self.override_channel_id_priv.lock().unwrap() {
+ Some(key) => key.clone(),
+ None => self.backing.get_channel_id()
+ }
+ }
}
impl TestKeysInterface {
Self {
backing: keysinterface::KeysManager::new(seed, network, logger),
override_session_priv: Mutex::new(None),
+ override_channel_id_priv: Mutex::new(None),
}
}
}