Skip to content

Commit eb57001

Browse files
committed
Remove dead string search in fuzz SearchingOutput
The searched-for log message ("Outbound update_fee HTLC buffer overflow") no longer exists in the lightning crate, so the from_utf8 + contains check on every log line was pure waste. AI tools were used in preparing this commit.
1 parent ab31f99 commit eb57001

1 file changed

Lines changed: 5 additions & 49 deletions

File tree

fuzz/src/chanmon_consistency.rs

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,8 @@ fn assert_action_timeout_awaiting_response(action: &msgs::ErrorAction) {
864864

865865
#[inline]
866866
pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
867-
data: &[u8], underlying_out: Out, anchors: bool,
867+
data: &[u8], out: Out, anchors: bool,
868868
) {
869-
let out = SearchingOutput::new(underlying_out);
870869
let broadcast_a = Arc::new(TestBroadcaster { txn_broadcasted: RefCell::new(Vec::new()) });
871870
let broadcast_b = Arc::new(TestBroadcaster { txn_broadcasted: RefCell::new(Vec::new()) });
872871
let broadcast_c = Arc::new(TestBroadcaster { txn_broadcasted: RefCell::new(Vec::new()) });
@@ -1793,11 +1792,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
17931792
// Can be generated as a result of calling `timer_tick_occurred` enough
17941793
// times while peers are disconnected
17951794
},
1796-
_ => if out.may_fail.load(atomic::Ordering::Acquire) {
1797-
return;
1798-
} else {
1799-
panic!("Unhandled message event {:?}", event)
1800-
},
1795+
_ => panic!("Unhandled message event {:?}", event),
18011796
}
18021797
if $limit_events != ProcessMessages::AllMessages {
18031798
break;
@@ -1837,13 +1832,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
18371832
MessageSendEvent::HandleError { ref action, .. } => {
18381833
assert_action_timeout_awaiting_response(action);
18391834
},
1840-
_ => {
1841-
if out.may_fail.load(atomic::Ordering::Acquire) {
1842-
return;
1843-
} else {
1844-
panic!("Unhandled message event")
1845-
}
1846-
},
1835+
_ => panic!("Unhandled message event"),
18471836
}
18481837
}
18491838
push_excess_b_events!(
@@ -1865,13 +1854,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
18651854
MessageSendEvent::HandleError { ref action, .. } => {
18661855
assert_action_timeout_awaiting_response(action);
18671856
},
1868-
_ => {
1869-
if out.may_fail.load(atomic::Ordering::Acquire) {
1870-
return;
1871-
} else {
1872-
panic!("Unhandled message event")
1873-
}
1874-
},
1857+
_ => panic!("Unhandled message event"),
18751858
}
18761859
}
18771860
push_excess_b_events!(
@@ -1980,13 +1963,7 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
19801963
},
19811964
events::Event::SpliceFailed { .. } => {},
19821965

1983-
_ => {
1984-
if out.may_fail.load(atomic::Ordering::Acquire) {
1985-
return;
1986-
} else {
1987-
panic!("Unhandled event")
1988-
}
1989-
},
1966+
_ => panic!("Unhandled event"),
19901967
}
19911968
}
19921969
while nodes[$node].needs_pending_htlc_processing() {
@@ -2809,27 +2786,6 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(
28092786
}
28102787
}
28112788

2812-
/// We actually have different behavior based on if a certain log string has been seen, so we have
2813-
/// to do a bit more tracking.
2814-
#[derive(Clone)]
2815-
struct SearchingOutput<O: Output> {
2816-
output: O,
2817-
may_fail: Arc<atomic::AtomicBool>,
2818-
}
2819-
impl<O: Output> Output for SearchingOutput<O> {
2820-
fn locked_write(&self, data: &[u8]) {
2821-
// We hit a design limitation of LN state machine (see CONCURRENT_INBOUND_HTLC_FEE_BUFFER)
2822-
if std::str::from_utf8(data).unwrap().contains("Outbound update_fee HTLC buffer overflow - counterparty should force-close this channel") {
2823-
self.may_fail.store(true, atomic::Ordering::Release);
2824-
}
2825-
self.output.locked_write(data)
2826-
}
2827-
}
2828-
impl<O: Output> SearchingOutput<O> {
2829-
pub fn new(output: O) -> Self {
2830-
Self { output, may_fail: Arc::new(atomic::AtomicBool::new(false)) }
2831-
}
2832-
}
28332789

28342790
pub fn chanmon_consistency_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], out: Out) {
28352791
do_test(data, out.clone(), false);

0 commit comments

Comments
 (0)