Skip to content

Commit

Permalink
Rename FundingLocked to ChannelReady.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed May 30, 2022
1 parent a534a5e commit 427dd8c
Show file tree
Hide file tree
Showing 22 changed files with 313 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
compile_error!("Fuzz targets need cfg=fuzzing");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_funding_locked::*;
use lightning_fuzz::msg_targets::msg_channel_ready::*;

#[cfg(feature = "afl")]
#[macro_use] extern crate afl;
#[cfg(feature = "afl")]
fn main() {
fuzz!(|data| {
msg_funding_locked_run(data.as_ptr(), data.len());
msg_channel_ready_run(data.as_ptr(), data.len());
});
}

Expand All @@ -33,7 +33,7 @@ fn main() {
fn main() {
loop {
fuzz!(|data| {
msg_funding_locked_run(data.as_ptr(), data.len());
msg_channel_ready_run(data.as_ptr(), data.len());
});
}
}
Expand All @@ -42,7 +42,7 @@ fn main() {
#[macro_use] extern crate libfuzzer_sys;
#[cfg(feature = "libfuzzer_fuzz")]
fuzz_target!(|data: &[u8]| {
msg_funding_locked_run(data.as_ptr(), data.len());
msg_channel_ready_run(data.as_ptr(), data.len());
});

#[cfg(feature = "stdin_fuzz")]
Expand All @@ -51,7 +51,7 @@ fn main() {

let mut data = Vec::with_capacity(8192);
std::io::stdin().read_to_end(&mut data).unwrap();
msg_funding_locked_run(data.as_ptr(), data.len());
msg_channel_ready_run(data.as_ptr(), data.len());
}

#[test]
Expand All @@ -63,11 +63,11 @@ fn run_test_cases() {
use std::sync::{atomic, Arc};
{
let data: Vec<u8> = vec![0];
msg_funding_locked_run(data.as_ptr(), data.len());
msg_channel_ready_run(data.as_ptr(), data.len());
}
let mut threads = Vec::new();
let threads_running = Arc::new(atomic::AtomicUsize::new(0));
if let Ok(tests) = fs::read_dir("test_cases/msg_funding_locked") {
if let Ok(tests) = fs::read_dir("test_cases/msg_channel_ready") {
for test in tests {
let mut data: Vec<u8> = Vec::new();
let path = test.unwrap().path();
Expand All @@ -82,7 +82,7 @@ fn run_test_cases() {

let panic_logger = string_logger.clone();
let res = if ::std::panic::catch_unwind(move || {
msg_funding_locked_test(&data, panic_logger);
msg_channel_ready_test(&data, panic_logger);
}).is_err() {
Some(string_logger.into_string())
} else { None };
Expand Down
12 changes: 6 additions & 6 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
}
for (idx, node_event) in node_events.iter().enumerate() {
for event in node_event {
if let events::MessageSendEvent::SendFundingLocked { ref node_id, ref msg } = event {
if let events::MessageSendEvent::SendChannelReady { ref node_id, ref msg } = event {
for node in $nodes.iter() {
if node.get_our_node_id() == *node_id {
node.handle_funding_locked(&$nodes[idx].get_our_node_id(), msg);
node.handle_channel_ready(&$nodes[idx].get_our_node_id(), msg);
}
}
} else { panic!("Wrong event type"); }
Expand Down Expand Up @@ -597,7 +597,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
if Some(*node_id) == expect_drop_id { panic!("peer_disconnected should drop msgs bound for the disconnected peer"); }
*node_id == a_id
},
events::MessageSendEvent::SendFundingLocked { .. } => continue,
events::MessageSendEvent::SendChannelReady { .. } => continue,
events::MessageSendEvent::SendAnnouncementSignatures { .. } => continue,
events::MessageSendEvent::SendChannelUpdate { ref node_id, ref msg } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
Expand Down Expand Up @@ -725,7 +725,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
}
}
},
events::MessageSendEvent::SendFundingLocked { .. } => {
events::MessageSendEvent::SendChannelReady { .. } => {
// Can be generated as a reestablish response
},
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {
Expand Down Expand Up @@ -771,7 +771,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
events::MessageSendEvent::UpdateHTLCs { .. } => {},
events::MessageSendEvent::SendRevokeAndACK { .. } => {},
events::MessageSendEvent::SendChannelReestablish { .. } => {},
events::MessageSendEvent::SendFundingLocked { .. } => {},
events::MessageSendEvent::SendChannelReady { .. } => {},
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {},
events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
Expand All @@ -792,7 +792,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
events::MessageSendEvent::UpdateHTLCs { .. } => {},
events::MessageSendEvent::SendRevokeAndACK { .. } => {},
events::MessageSendEvent::SendChannelReestablish { .. } => {},
events::MessageSendEvent::SendFundingLocked { .. } => {},
events::MessageSendEvent::SendChannelReady { .. } => {},
events::MessageSendEvent::SendAnnouncementSignatures { .. } => {},
events::MessageSendEvent::SendChannelUpdate { ref msg, .. } => {
assert_eq!(msg.contents.flags & 2, 0); // The disable bit must never be set!
Expand Down
12 changes: 6 additions & 6 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,12 @@ mod tests {
// 0c0000 - connect a block with no transactions
// 0c0000 - connect a block with no transactions
// 0c0000 - connect a block with no transactions
// - by now client should have sent a funding_locked (CHECK 3: SendFundingLocked to 03000000 for chan 3d000000)
// - by now client should have sent a channel_ready (CHECK 3: SendChannelReady to 03000000 for chan 3d000000)
//
// 030012 - inbound read from peer id 0 of len 18
// 0043 03000000000000000000000000000000 - message header indicating message length 67
// 030053 - inbound read from peer id 0 of len 83
// 0024 3d00000000000000000000000000000000000000000000000000000000000000 020800000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000 - funding_locked and mac
// 0024 3d00000000000000000000000000000000000000000000000000000000000000 020800000000000000000000000000000000000000000000000000000000000000 03000000000000000000000000000000 - channel_ready and mac
//
// 01 - new inbound connection with id 1
// 030132 - inbound read from peer id 1 of len 50
Expand Down Expand Up @@ -775,12 +775,12 @@ mod tests {
// 0023 3a00000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000007c0001000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000 - funding_signed message and mac
//
// 0b - broadcast funding transaction
// - by now client should have sent a funding_locked (CHECK 4: SendFundingLocked to 03020000 for chan 3f000000)
// - by now client should have sent a channel_ready (CHECK 4: SendChannelReady to 03020000 for chan 3f000000)
//
// 030112 - inbound read from peer id 1 of len 18
// 0043 01000000000000000000000000000000 - message header indicating message length 67
// 030153 - inbound read from peer id 1 of len 83
// 0024 3a00000000000000000000000000000000000000000000000000000000000000 026700000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000 - funding_locked and mac
// 0024 3a00000000000000000000000000000000000000000000000000000000000000 026700000000000000000000000000000000000000000000000000000000000000 01000000000000000000000000000000 - channel_ready and mac
//
// 030012 - inbound read from peer id 0 of len 18
// 05ac 03000000000000000000000000000000 - message header indicating message length 1452
Expand Down Expand Up @@ -964,8 +964,8 @@ mod tests {
let log_entries = logger.lines.lock().unwrap();
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendAcceptChannel event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel ff4f00f805273c1b203bb5ebf8436bfde57b3be8c2f5e95d9491dbb181909679".to_string())), Some(&1)); // 1
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendFundingSigned event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 2
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendFundingLocked event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 3
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendFundingLocked event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 for channel 3a00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 4
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendChannelReady event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 3
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendChannelReady event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 for channel 3a00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&1)); // 4
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling SendRevokeAndACK event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&4)); // 5
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030000000000000000000000000000000000000000000000000000000000000002 with 0 adds, 0 fulfills, 0 fails for channel 3d00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&3)); // 6
assert_eq!(log_entries.get(&("lightning::ln::peer_handler".to_string(), "Handling UpdateHTLCs event in peer_handler for node 030200000000000000000000000000000000000000000000000000000000000000 with 1 adds, 0 fulfills, 0 fails for channel 3a00000000000000000000000000000000000000000000000000000000000000".to_string())), Some(&3)); // 7
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/msg_targets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod msg_announcement_signatures;
pub mod msg_closing_signed;
pub mod msg_commitment_signed;
pub mod msg_funding_created;
pub mod msg_funding_locked;
pub mod msg_channel_ready;
pub mod msg_funding_signed;
pub mod msg_gossip_timestamp_filter;
pub mod msg_init;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use msg_targets::utils::VecWriter;
use utils::test_logger;

#[inline]
pub fn msg_funding_locked_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
test_msg_simple!(msgs::FundingLocked, data);
pub fn msg_channel_ready_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
test_msg_simple!(msgs::ChannelReady, data);
}

#[no_mangle]
pub extern "C" fn msg_funding_locked_run(data: *const u8, datalen: usize) {
pub extern "C" fn msg_channel_ready_run(data: *const u8, datalen: usize) {
let data = unsafe { std::slice::from_raw_parts(data, datalen) };
test_msg_simple!(msgs::FundingLocked, data);
test_msg_simple!(msgs::ChannelReady, data);
}
2 changes: 1 addition & 1 deletion fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
unspendable_punishment_reserve: None,
confirmations_required: None,
force_close_spend_delay: None,
is_outbound: true, is_funding_locked: true,
is_outbound: true, is_channel_ready: true,
is_usable: true, is_public: true,
balance_msat: 0,
outbound_capacity_msat: capacity.saturating_mul(1000),
Expand Down
8 changes: 4 additions & 4 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,12 @@ mod tests {

// Confirm the funding transaction.
confirm_transaction(&mut nodes[0], &funding_tx);
let as_funding = get_event_msg!(nodes[0], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id());
let as_funding = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id());
confirm_transaction(&mut nodes[1], &funding_tx);
let bs_funding = get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id());
nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &bs_funding);
let bs_funding = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id());
nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &bs_funding);
let _as_channel_update = get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &as_funding);
nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_funding);
let _bs_channel_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());

assert!(bg_processor.stop().is_ok());
Expand Down
12 changes: 6 additions & 6 deletions lightning-invoice/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,10 @@ mod test {
connect_blocks(&nodes[2], CHAN_CONFIRM_DEPTH - 1);
confirm_transaction_at(&nodes[0], &tx, conf_height);
connect_blocks(&nodes[0], CHAN_CONFIRM_DEPTH - 1);
let as_funding_locked = get_event_msg!(nodes[2], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id());
nodes[2].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingLocked, nodes[2].node.get_our_node_id()));
let as_channel_ready = get_event_msg!(nodes[2], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id());
nodes[2].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendChannelReady, nodes[2].node.get_our_node_id()));
get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());
nodes[0].node.handle_funding_locked(&nodes[2].node.get_our_node_id(), &as_funding_locked);
nodes[0].node.handle_channel_ready(&nodes[2].node.get_our_node_id(), &as_channel_ready);
get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());

// As `msgs::ChannelUpdate` was never handled for the participating node(s) of the second
Expand Down Expand Up @@ -1059,10 +1059,10 @@ mod test {
connect_blocks(&nodes[1], CHAN_CONFIRM_DEPTH - 1);
confirm_transaction_at(&nodes[3], &tx, conf_height);
connect_blocks(&nodes[3], CHAN_CONFIRM_DEPTH - 1);
let as_funding_locked = get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[3].node.get_our_node_id());
nodes[1].node.handle_funding_locked(&nodes[3].node.get_our_node_id(), &get_event_msg!(nodes[3], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id()));
let as_channel_ready = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[3].node.get_our_node_id());
nodes[1].node.handle_channel_ready(&nodes[3].node.get_our_node_id(), &get_event_msg!(nodes[3], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[3].node.get_our_node_id());
nodes[3].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &as_funding_locked);
nodes[3].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
get_event_msg!(nodes[3], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());

// As `msgs::ChannelUpdate` was never handled for the participating node(s) of the third
Expand Down
2 changes: 1 addition & 1 deletion lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ mod tests {
fn handle_accept_channel(&self, _their_node_id: &PublicKey, _their_features: InitFeatures, _msg: &AcceptChannel) {}
fn handle_funding_created(&self, _their_node_id: &PublicKey, _msg: &FundingCreated) {}
fn handle_funding_signed(&self, _their_node_id: &PublicKey, _msg: &FundingSigned) {}
fn handle_funding_locked(&self, _their_node_id: &PublicKey, _msg: &FundingLocked) {}
fn handle_channel_ready(&self, _their_node_id: &PublicKey, _msg: &ChannelReady) {}
fn handle_shutdown(&self, _their_node_id: &PublicKey, _their_features: &InitFeatures, _msg: &Shutdown) {}
fn handle_closing_signed(&self, _their_node_id: &PublicKey, _msg: &ClosingSigned) {}
fn handle_update_add_htlc(&self, _their_node_id: &PublicKey, _msg: &UpdateAddHTLC) {}
Expand Down
Loading

0 comments on commit 427dd8c

Please sign in to comment.