44use bitcoin:: hash_types:: BlockHash ;
55
66use lightning:: chain:: channelmonitor;
7+ use lightning:: util:: ser:: { ReadableArgs , Writeable , Writer } ;
78use lightning:: util:: test_channel_signer:: TestChannelSigner ;
8- use lightning:: util:: ser:: { ReadableArgs , Writer , Writeable } ;
99use lightning:: util:: test_utils:: OnlyReadsKeysInterface ;
1010
1111use crate :: utils:: test_logger;
@@ -22,10 +22,19 @@ impl Writer for VecWriter {
2222
2323#[ inline]
2424pub fn do_test < Out : test_logger:: Output > ( data : & [ u8 ] , _out : Out ) {
25- if let Ok ( ( latest_block_hash, monitor) ) = <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read ( & mut Cursor :: new ( data) , ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ) {
25+ if let Ok ( ( latest_block_hash, monitor) ) =
26+ <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read (
27+ & mut Cursor :: new ( data) ,
28+ ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ,
29+ ) {
2630 let mut w = VecWriter ( Vec :: new ( ) ) ;
2731 monitor. write ( & mut w) . unwrap ( ) ;
28- let deserialized_copy = <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read ( & mut Cursor :: new ( & w. 0 ) , ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ) . unwrap ( ) ;
32+ let deserialized_copy =
33+ <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read (
34+ & mut Cursor :: new ( & w. 0 ) ,
35+ ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ,
36+ )
37+ . unwrap ( ) ;
2938 assert ! ( latest_block_hash == deserialized_copy. 0 ) ;
3039 assert ! ( monitor == deserialized_copy. 1 ) ;
3140 }
@@ -37,5 +46,5 @@ pub fn chanmon_deser_test<Out: test_logger::Output>(data: &[u8], out: Out) {
3746
3847#[ no_mangle]
3948pub extern "C" fn chanmon_deser_run ( data : * const u8 , datalen : usize ) {
40- do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
49+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
4150}
0 commit comments