projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
23f07aa
)
Test that txn pay at least a minimum relay fee in functional tests
author
Matt Corallo
<git@bluematt.me>
Mon, 2 Mar 2020 16:44:11 +0000
(11:44 -0500)
committer
Matt Corallo
<git@bluematt.me>
Mon, 25 May 2020 19:36:58 +0000
(15:36 -0400)
lightning/src/ln/functional_test_utils.rs
patch
|
blob
|
history
diff --git
a/lightning/src/ln/functional_test_utils.rs
b/lightning/src/ln/functional_test_utils.rs
index a8c4d279763950e8dda2b5d326c7587c4e089214..d21dc792185b0eeb2f1899b3e35fb95e3b98476c 100644
(file)
--- a/
lightning/src/ln/functional_test_utils.rs
+++ b/
lightning/src/ln/functional_test_utils.rs
@@
-475,14
+475,25
@@
pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a
macro_rules! check_spends {
($tx: expr, $($spends_txn: expr),*) => {
{
macro_rules! check_spends {
($tx: expr, $($spends_txn: expr),*) => {
{
-
$tx.verify(|out_p
oint| {
+
let get_output = |out_point: &bitcoin::blockdata::transaction::OutP
oint| {
$(
if out_point.txid == $spends_txn.txid() {
return $spends_txn.output.get(out_point.vout as usize).cloned()
}
)*
None
$(
if out_point.txid == $spends_txn.txid() {
return $spends_txn.output.get(out_point.vout as usize).cloned()
}
)*
None
- }).unwrap();
+ };
+ let mut total_value_in = 0;
+ for input in $tx.input.iter() {
+ total_value_in += get_output(&input.previous_output).unwrap().value;
+ }
+ let mut total_value_out = 0;
+ for output in $tx.output.iter() {
+ total_value_out += output.value;
+ }
+ let min_fee = $tx.get_weight() as u64 / 4; // One sat per vbyte
+ assert!(total_value_out + min_fee <= total_value_in); // Must not be equal as there must be a fee!
+ $tx.verify(get_output).unwrap();
}
}
}
}
}
}