Skip to content

Commit 1f1ae97

Browse files
committed
Add a macro for creating custom TLVs in tests
1 parent 6b09235 commit 1f1ae97

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ macro_rules! encode_tlv_stream {
141141
} }
142142
}
143143

144+
/// Serializes a TLV stream and returns a vector a bytes.
145+
/// This is exported for use in custom TLV tests, do not use directly.
146+
#[doc(hidden)]
147+
#[macro_export]
148+
macro_rules! _get_encoded_tlv_stream {
149+
({$(($type: expr, $field: expr, $fieldty: tt)),* $(,)*}) => { {
150+
let mut tlvs = Vec::new();
151+
let mut write_tlvs = || -> Result<(), $crate::io::Error> {
152+
encode_tlv_stream!(&mut tlvs, {$(($type, $field, $fieldty)),*});
153+
Ok(())
154+
};
155+
write_tlvs().unwrap();
156+
tlvs
157+
} }
158+
}
159+
144160
/// Adds the length of the serialized field to a [`LengthCalculatingWriter`].
145161
/// This is exported for use by other exported macros, do not use directly.
146162
///

0 commit comments

Comments
 (0)