Skip to content

Commit ba0549f

Browse files
author
Antoine Riard
committed
Add utility macro to display txn
Aims to ease tests writing/debugging
1 parent 7961edb commit ba0549f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/ln/channelmanager.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4167,6 +4167,27 @@ mod tests {
41674167
nodes
41684168
}
41694169

4170+
macro_rules! display_txn {
4171+
($txn: expr, $in: expr, $out: expr) => {
4172+
println!("[{}]", stringify!($txn));
4173+
for (idx, tx) in $txn.iter().enumerate() {
4174+
println!("tx[{}] : {} inputs {} outputs {}", idx, tx.txid(), tx.input.len(), tx.output.len());
4175+
if $in == true {
4176+
for (idx, inp) in tx.input.iter().enumerate() {
4177+
println!(" input[{}] : spending output {} from tx {} with witness size {}", idx, inp.previous_output.vout, inp.previous_output.txid, inp.witness.last().unwrap().len());
4178+
}
4179+
}
4180+
if $out == true {
4181+
for (idx, out) in tx.output.iter().enumerate() {
4182+
println!(" output[{}] : output encumbered by {} with amount {}", idx, out.script_pubkey, out.value);
4183+
}
4184+
}
4185+
println!("");
4186+
}
4187+
println!("");
4188+
}
4189+
}
4190+
41704191
#[test]
41714192
fn test_async_inbound_update_fee() {
41724193
let mut nodes = create_network(2);

0 commit comments

Comments
 (0)