+// 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
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
//! Test that no series of bytes received over the wire/connections created/payments sent can
//! result in a crash. We do this by standing up a node and then reading bytes from input to denote
//! actions such as creating new inbound/outbound connections, bytes to be read from a connection,
use bitcoin::blockdata::opcodes;
use bitcoin::consensus::encode::deserialize;
use bitcoin::network::constants::Network;
-use bitcoin::util::hash::BitcoinHash;
use bitcoin::hashes::Hash as TraitImport;
use bitcoin::hashes::HashEngine as TraitImportEngine;
hash_map::Entry::Vacant(e) => {
e.insert(self.height);
txn.push(tx);
- txn_idxs.push(idx as u32 + 1);
+ txn_idxs.push(idx + 1);
},
_ => {},
}
self.manager.block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
(*self.monitor).block_connected(&header, self.height as u32, &txn[..], &txn_idxs[..]);
if self.header_hashes.len() > self.height {
- self.header_hashes[self.height] = header.bitcoin_hash();
+ self.header_hashes[self.height] = header.block_hash();
} else {
assert_eq!(self.header_hashes.len(), self.height);
- self.header_hashes.push(header.bitcoin_hash());
+ self.header_hashes.push(header.block_hash());
}
self.max_height = cmp::max(self.height, self.max_height);
}
})
}
- fn get_onion_rand(&self) -> (SecretKey, [u8; 32]) {
- let ctr = self.counter.fetch_add(1, Ordering::Relaxed) as u8;
- (SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, ctr]).unwrap(),
- [0; 32])
- }
-
- fn get_channel_id(&self) -> [u8; 32] {
+ fn get_secure_random_bytes(&self) -> [u8; 32] {
let ctr = self.counter.fetch_add(1, Ordering::Relaxed);
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
(ctr >> 8*7) as u8, (ctr >> 8*6) as u8, (ctr >> 8*5) as u8, (ctr >> 8*4) as u8, (ctr >> 8*3) as u8, (ctr >> 8*2) as u8, (ctr >> 8*1) as u8, 14, (ctr >> 8*0) as u8]
},
4 => {
let value = slice_to_be24(get_slice!(3)) as u64;
- let route = match get_route(&our_id, &net_graph_msg_handler, &get_pubkey!(), None, &Vec::new(), value, 42, Arc::clone(&logger)) {
+ let route = match get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &get_pubkey!(), None, &Vec::new(), value, 42, Arc::clone(&logger)) {
Ok(route) => route,
Err(_) => return,
};
},
15 => {
let value = slice_to_be24(get_slice!(3)) as u64;
- let mut route = match get_route(&our_id, &net_graph_msg_handler, &get_pubkey!(), None, &Vec::new(), value, 42, Arc::clone(&logger)) {
+ let mut route = match get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &get_pubkey!(), None, &Vec::new(), value, 42, Arc::clone(&logger)) {
Ok(route) => route,
Err(_) => return,
};