Skip to content

Commit

Permalink
rustfmt: apply 'visual' indent style config change
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinewallace committed Jan 6, 2020
1 parent 03d396d commit b0ed084
Show file tree
Hide file tree
Showing 30 changed files with 11,266 additions and 13,679 deletions.
623 changes: 305 additions & 318 deletions fuzz/src/chanmon_consistency.rs

Large diffs are not rendered by default.

411 changes: 179 additions & 232 deletions fuzz/src/full_stack.rs

Large diffs are not rendered by default.

68 changes: 32 additions & 36 deletions fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ impl ChainWatchInterface for DummyChainWatcher {
fn filter_block<'a>(&self, _block: &'a Block) -> (Vec<&'a Transaction>, Vec<u32>) { (Vec::new(), Vec::new()) }
fn reentered(&self) -> usize { 0 }

fn get_chain_utxo(
&self,
_genesis_hash: Sha256dHash,
_unspent_tx_output_identifier: u64,
) -> Result<(Script, u64), ChainError> {
fn get_chain_utxo(&self,
_genesis_hash: Sha256dHash,
_unspent_tx_output_identifier: u64)
-> Result<(Script, u64), ChainError> {
match self.input.get_slice(2) {
Some(&[0, _]) => Err(ChainError::NotSupported),
Some(&[1, _]) => Err(ChainError::NotWatched),
Expand All @@ -97,10 +96,8 @@ impl ChainWatchInterface for DummyChainWatcher {

#[inline]
pub fn do_test(data: &[u8]) {
let input = Arc::new(InputData {
data: data.to_vec(),
read_pos: AtomicUsize::new(0),
});
let input = Arc::new(InputData { data: data.to_vec(),
read_pos: AtomicUsize::new(0) });
macro_rules! get_slice_nonadvancing {
($len: expr) => {
match input.get_slice_nonadvancing($len as usize) {
Expand Down Expand Up @@ -155,9 +152,7 @@ pub fn do_test(data: &[u8]) {
}

let logger: Arc<dyn Logger> = Arc::new(test_logger::TestLogger::new("".to_owned()));
let chain_monitor = Arc::new(DummyChainWatcher {
input: Arc::clone(&input),
});
let chain_monitor = Arc::new(DummyChainWatcher { input: Arc::clone(&input) });

let our_pubkey = get_pubkey!();
let router = Router::new(our_pubkey.clone(), chain_monitor, Arc::clone(&logger));
Expand All @@ -167,7 +162,8 @@ pub fn do_test(data: &[u8]) {
0 => {
let start_len = slice_to_be16(&get_slice_nonadvancing!(64 + 2)[64..64 + 2]) as usize;
let addr_len = slice_to_be16(
&get_slice_nonadvancing!(64 + start_len + 2 + 74)[64 + start_len + 2 + 72..64 + start_len + 2 + 74],
&get_slice_nonadvancing!(64 + start_len + 2 + 74)
[64 + start_len + 2 + 72..64 + start_len + 2 + 74],
);
if addr_len > (37 + 1) * 4 {
return;
Expand Down Expand Up @@ -207,16 +203,18 @@ pub fn do_test(data: &[u8]) {
1 => {
let count = slice_to_be16(get_slice!(2));
for _ in 0..count {
first_hops_vec.push(ChannelDetails {
channel_id: [0; 32],
short_channel_id: Some(slice_to_be64(get_slice!(8))),
remote_network_id: get_pubkey!(),
channel_value_satoshis: slice_to_be64(get_slice!(8)),
user_id: 0,
inbound_capacity_msat: 0,
is_live: true,
outbound_capacity_msat: 0,
});
first_hops_vec.push(ChannelDetails { channel_id: [0; 32],
short_channel_id: Some(slice_to_be64(get_slice!(
8
))),
remote_network_id: get_pubkey!(),
channel_value_satoshis: slice_to_be64(get_slice!(
8
)),
user_id: 0,
inbound_capacity_msat: 0,
is_live: true,
outbound_capacity_msat: 0, });
}
Some(&first_hops_vec[..])
},
Expand All @@ -226,23 +224,21 @@ pub fn do_test(data: &[u8]) {
let last_hops = {
let count = slice_to_be16(get_slice!(2));
for _ in 0..count {
last_hops_vec.push(RouteHint {
src_node_id: get_pubkey!(),
short_channel_id: slice_to_be64(get_slice!(8)),
fee_base_msat: slice_to_be32(get_slice!(4)),
fee_proportional_millionths: slice_to_be32(get_slice!(4)),
cltv_expiry_delta: slice_to_be16(get_slice!(2)),
htlc_minimum_msat: slice_to_be64(get_slice!(8)),
});
last_hops_vec.push(RouteHint { src_node_id: get_pubkey!(),
short_channel_id: slice_to_be64(get_slice!(8)),
fee_base_msat: slice_to_be32(get_slice!(4)),
fee_proportional_millionths: slice_to_be32(get_slice!(4)),
cltv_expiry_delta: slice_to_be16(get_slice!(2)),
htlc_minimum_msat: slice_to_be64(get_slice!(8)), });
}
&last_hops_vec[..]
};
let _ = router.get_route(
&target,
first_hops,
last_hops,
slice_to_be64(get_slice!(8)),
slice_to_be32(get_slice!(4)),
&target,
first_hops,
last_hops,
slice_to_be64(get_slice!(8)),
slice_to_be32(get_slice!(4)),
);
},
_ => return,
Expand Down
20 changes: 9 additions & 11 deletions fuzz/src/utils/test_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ pub struct TestLogger {

impl TestLogger {
pub fn new(_id: String) -> TestLogger {
TestLogger {
#[cfg(test)]
id: _id,
}
TestLogger { #[cfg(test)]
id: _id }
}
}

impl Logger for TestLogger {
fn log(&self, record: &Record) {
#[cfg(test)]
println!(
"{:<5} {} [{} : {}, {}] {}",
record.level.to_string(),
self.id,
record.module_path,
record.file,
record.line,
record.args
"{:<5} {} [{} : {}, {}] {}",
record.level.to_string(),
self.id,
record.module_path,
record.file,
record.line,
record.args
);
#[cfg(not(test))]
let _ = format!("{}", record.args);
Expand Down
Loading

0 comments on commit b0ed084

Please sign in to comment.