Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async payments message encoding and prefactor #3125

16 changes: 15 additions & 1 deletion lightning/src/util/ser_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ macro_rules! impl_writeable_msg {
$($crate::_init_tlv_field_var!($tlvfield, $fieldty);)*
$crate::decode_tlv_stream!(r, {$(($type, $tlvfield, $fieldty)),*});
Ok(Self {
$($field),*,
$($field,)*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this commit is no longer required but it still seemed like a nice fix.

$($tlvfield),*
})
}
Expand Down Expand Up @@ -1531,4 +1531,18 @@ mod tests {
fn simple_test_tlv_write() {
do_simple_test_tlv_write().unwrap();
}

#[derive(Debug, Eq, PartialEq)]
struct EmptyMsg {}
impl_writeable_msg!(EmptyMsg, {}, {});

#[test]
fn impl_writeable_msg_empty() {
let msg = EmptyMsg {};
let mut encoded_msg = msg.encode();
assert!(encoded_msg.is_empty());
let mut encoded_msg_stream = Cursor::new(&mut encoded_msg);
let decoded_msg: EmptyMsg = Readable::read(&mut encoded_msg_stream).unwrap();
assert_eq!(msg, decoded_msg);
}
}